it.unimi.dsi.fastutil.objects
Class AbstractReferenceList

java.lang.Object
  extended byit.unimi.dsi.fastutil.objects.AbstractReferenceCollection
      extended byit.unimi.dsi.fastutil.objects.AbstractReferenceList
All Implemented Interfaces:
Collection, List, ReferenceCollection, ReferenceList, Stack
Direct Known Subclasses:
ReferenceArrayList, ReferenceLists.Singleton

public abstract class AbstractReferenceList
extends AbstractReferenceCollection
implements ReferenceList, Stack

An abstract class providing basic methods for lists implementing a type-specific list interface.

As an additional bonus, this class implements on top of the list operations a type-specific stack.


Method Summary
 void add(int index, Object k)
           
 boolean addAll(Collection c)
          Delegates to a more generic method.
 boolean addAll(int index, Collection c)
           
 boolean addAll(int index, ReferenceCollection c)
          Delegates to a more generic method.
 boolean addAll(int index, ReferenceList l)
          Delegates to a more generic method.
 boolean addAll(ReferenceCollection c)
          Delegates to a more generic method.
 boolean addAll(ReferenceList l)
          Delegates to a more generic method.
 void addElements(int index, Object[] a)
          Add (hopefully quickly) elements to this type-specific list.
 void addElements(int index, Object[] a, int offset, int length)
          Adds elements to this type-specific list one-by-one.
 boolean contains(Object k)
           
 boolean equals(Object o)
           
 void getElements(int from, Object[] a, int offset, int length)
          Copies element of this type-specific list into the given array one-by-one.
 int hashCode()
          Returns the hash code for this list, which is identical to List.hashCode().
 int indexOf(Object k)
           
 int lastIndexOf(Object k)
           
 ListIterator listIterator()
          Delegates to the corresponding type-specific method.
 ListIterator listIterator(int index)
          Delegates to the corresponding type-specific method.
 ObjectIterator objectIterator()
          Delegates to the corresponding list-iterator method.
 ObjectListIterator objectListIterator()
          Delegates to the corresponding list-iterator method.
 Object peek(int i)
          Peeks at an element on the stack (optional operation).
 Object pop()
          Pops the top off the stack.
 void push(Object o)
          Pushes the given object on the stack.
 ReferenceList referenceSubList(int from, int to)
           
 boolean rem(Object k)
           
 Object remove(int i)
           
 void removeElements(int from, int to)
          Removes elements of this type-specific list one-by-one.
 Object set(int index, Object k)
           
 void size(int size)
          Sets the size of this list.
 List subList(int from, int to)
          Delegates to the corresponding type-specific method.
 Object top()
          Peeks at the top of the stack (optional operation).
 String toString()
           
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractReferenceCollection
add, clear, containsAll, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.objects.ReferenceList
objectListIterator
 
Methods inherited from interface java.util.List
add, clear, containsAll, get, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Method Detail

add

public void add(int index,
                Object k)
Specified by:
add in interface List

rem

public boolean rem(Object k)
Overrides:
rem in class AbstractReferenceCollection

remove

public Object remove(int i)
Specified by:
remove in interface List

set

public Object set(int index,
                  Object k)
Specified by:
set in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      ReferenceCollection c)
Delegates to a more generic method.


addAll

public boolean addAll(int index,
                      ReferenceList l)
Delegates to a more generic method.


addAll

public boolean addAll(Collection c)
Delegates to a more generic method.

Specified by:
addAll in interface List
Overrides:
addAll in class AbstractReferenceCollection
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

addAll

public boolean addAll(ReferenceCollection c)
Delegates to a more generic method.


addAll

public boolean addAll(ReferenceList l)
Delegates to a more generic method.


listIterator

public ListIterator listIterator()
Delegates to the corresponding type-specific method.

Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Delegates to the corresponding type-specific method.

Specified by:
listIterator in interface List

objectIterator

public ObjectIterator objectIterator()
Delegates to the corresponding list-iterator method.

Specified by:
objectIterator in interface ReferenceCollection
See Also:
Collection.iterator()

objectListIterator

public ObjectListIterator objectListIterator()
Delegates to the corresponding list-iterator method.

Specified by:
objectListIterator in interface ReferenceList
See Also:
List.listIterator()

contains

public boolean contains(Object k)
Specified by:
contains in interface List

indexOf

public int indexOf(Object k)
Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object k)
Specified by:
lastIndexOf in interface List

size

public void size(int size)
Description copied from interface: ReferenceList
Sets the size of this list.

If the specified size is smaller than the current size, the last elements are discarded. Otherwise, they are filled with 0/null/false.

Specified by:
size in interface ReferenceList
Parameters:
size - the new size.

referenceSubList

public ReferenceList referenceSubList(int from,
                                      int to)
Specified by:
referenceSubList in interface ReferenceList
See Also:
List.subList(int,int)

subList

public List subList(int from,
                    int to)
Delegates to the corresponding type-specific method.

Specified by:
subList in interface List

removeElements

public void removeElements(int from,
                           int to)
Removes elements of this type-specific list one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
removeElements in interface ReferenceList
Parameters:
from - the start index (inclusive).
to - the end index (exclusive).

addElements

public void addElements(int index,
                        Object[] a,
                        int offset,
                        int length)
Adds elements to this type-specific list one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
addElements in interface ReferenceList
Parameters:
index - the index at which to add elements.
a - the array containing the elements.
offset - the offset of the first element to add.
length - the number of elements to add.

addElements

public void addElements(int index,
                        Object[] a)
Description copied from interface: ReferenceList
Add (hopefully quickly) elements to this type-specific list.

Specified by:
addElements in interface ReferenceList
Parameters:
index - the index at which to add elements.
a - the array containing the elements.

getElements

public void getElements(int from,
                        Object[] a,
                        int offset,
                        int length)
Copies element of this type-specific list into the given array one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
getElements in interface ReferenceList
Parameters:
from - the start index (inclusive).
a - the destination array.
offset - the offset into the destination array where to store the first element copied.
length - the number of elements to be copied.

equals

public boolean equals(Object o)
Specified by:
equals in interface List

hashCode

public int hashCode()
Returns the hash code for this list, which is identical to List.hashCode().

Specified by:
hashCode in interface List
Returns:
the hash code for this list.

push

public void push(Object o)
Description copied from interface: Stack
Pushes the given object on the stack.

Specified by:
push in interface Stack
Parameters:
o - the object that will become the new top of the stack.

pop

public Object pop()
Description copied from interface: Stack
Pops the top off the stack.

Specified by:
pop in interface Stack
Returns:
the top of the stack.

top

public Object top()
Description copied from interface: Stack
Peeks at the top of the stack (optional operation).

Specified by:
top in interface Stack
Returns:
the top of the stack.

peek

public Object peek(int i)
Description copied from interface: Stack
Peeks at an element on the stack (optional operation).

Specified by:
peek in interface Stack
Returns:
the i-th element on the stack; 0 represents the top.

toString

public String toString()
Overrides:
toString in class AbstractReferenceCollection