Class RoundList

  • All Implemented Interfaces:
    Serializable, Serializable

    public class RoundList
    extends Object
    implements Serializable
    Implementation of a RoundList with get/insert methods relative to the current element
    Version:
    $Date$ $Revision$
    Author:
    Fabio Bellifemine - TILab
    See Also:
    Serialized Form
    • Constructor Detail

      • RoundList

        public RoundList()
        Default constructor.
    • Method Detail

      • add

        public boolean add​(Object element)
        Inserts the element before the current element. If the list was empty, the inserted element becomes also the current element. Note that this implementation uses a LinkedList and therefore it is not synchronized.
        Parameters:
        element - the element to insert
        Returns:
        true (as per the general contract of Collection.add).
      • get

        public Object get()
                   throws NoSuchElementException
        Returns the current element in the list and updates the pointer such that the current becomes the next element in the list.
        Notice that if the list contains just 1 element each call to this method will return the same element.
        Take care in avoiding infinite loops in calling this method. It must be called no more than size() times
        Throws:
        NoSuchElementException - if the list is empty
      • remove

        public boolean remove​(Object element)
        Removes the first occurrence of the specified element in this list and updates the pointer to the current element. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (element==null ? get(i)==null : element.equals(get(i))) (if such an element exists).
        Parameters:
        element - the element to be removed from this list, if present.
        Returns:
        true if the list contained the specified element.
      • contains

        public boolean contains​(Object element)
        Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (element==null ? e==null : element.equals(e)).
        Parameters:
        element - whose presence in this list is to be tested.
        Returns:
        true if this list contains the specified element.
      • size

        public int size()
        Returns the number of elements in this list.
        Returns:
        the number of elements in this list.
      • iterator

        public Iterator iterator()
        Returns an Iterator over the elements in this list.
        Returns:
        an Iterator over the elements in this list.
      • toArray

        public Object[] toArray()
      • toString

        public String toString()
        Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its get() method, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).
        Overrides:
        toString in class Object
        Returns:
        a String representation of this list
      • main

        public static void main​(String[] args)
        Just for Debugging this implementation.