Package jade.util.leap
Class RoundList
- java.lang.Object
-
- jade.util.leap.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 Summary
Constructors Constructor Description RoundList()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object element)Inserts theelementbefore the current element.booleancontains(Object element)Returns true if this list contains the specified element.Objectget()Returns the currentelementin the list and updates the pointer such that the current becomes the next element in the list.Iteratoriterator()Returns an Iterator over the elements in this list.static voidmain(String[] args)Just for Debugging this implementation.booleanremove(Object element)Removes the first occurrence of the specified element in this list and updates the pointer to the current element.intsize()Returns the number of elements in this list.Object[]toArray()StringtoString()Returns a string representation of this collection.
-
-
-
Method Detail
-
add
public boolean add(Object element)
Inserts theelementbefore the current element. If the list was empty, the inserted element becomes also the current element. Note that this implementation uses aLinkedListand 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 currentelementin 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 thansize()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 byString.valueOf(Object).
-
main
public static void main(String[] args)
Just for Debugging this implementation.
-
-