it.unimi.dsi.fastutil.shorts
Interface ShortList

All Superinterfaces:
Collection, Comparable, List, ShortCollection
All Known Implementing Classes:
AbstractShortList, Lists.EmptyList, ShortLists.SynchronizedList, ShortLists.UnmodifiableList

public interface ShortList
extends List, Comparable, ShortCollection

A type-specific List; provides some additional methods that use polymorphism to reduce type juggling.

Note that this type-specific interface extends Comparable: it is expected that implementing classes perform a lexicographical comparison using the standard operator "less then" for primitive types, and the usual compareTo() method for objects.

Besides polymorphic methods, this interfaces specifies methods to copy into an array or remove contiguous sublists. Although the abstract implementation of this interface provides simple, one-by-one implementations of these methods, it is expected that concrete implementation override them with optimized versions.

See Also:
List

Method Summary
 void add(int index, short key)
           
 boolean addAll(int index, ShortCollection c)
           
 boolean addAll(int index, ShortList c)
           
 boolean addAll(ShortList c)
           
 void addElements(int index, short[] a)
          Add (hopefully quickly) elements to this type-specific list.
 void addElements(int index, short[] a, int offset, int length)
          Add (hopefully quickly) elements to this type-specific list.
 void getElements(int from, short[] a, int offset, int length)
          Copies (hopefully quickly) elements of this type-specific list into the given array.
 short getShort(int index)
           
 int indexOf(short k)
           
 int lastIndexOf(short k)
           
 void removeElements(int from, int to)
          Removes (hopefully quickly) elements of this type-specific list.
 short removeShort(int index)
           
 short set(int index, short k)
           
 ShortListIterator shortListIterator()
          Returns a type-specific list iterator on the list.
 ShortListIterator shortListIterator(int index)
          Returns a type-specific list iterator on the list starting at a given index.
 ShortList shortSubList(int from, int to)
           
 void size(int size)
          Sets the size of this list.
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface it.unimi.dsi.fastutil.shorts.ShortCollection
add, addAll, contains, containsAll, rem, removeAll, retainAll, shortIterator, toArray, toShortArray, toShortArray
 

Method Detail

shortListIterator

public ShortListIterator shortListIterator()
Returns a type-specific list iterator on the list.

The iterator returned by the List.listIterator() method and by this method are identical; however, using this method you can save a type casting.

See Also:
List.listIterator()

shortListIterator

public ShortListIterator shortListIterator(int index)
Returns a type-specific list iterator on the list starting at a given index.

The iterator returned by the List.listIterator() method and by this method are identical; however, using this method you can save a type casting.

See Also:
List.listIterator(int)

shortSubList

public ShortList shortSubList(int from,
                              int to)
See Also:
List.subList(int,int)

size

public void size(int size)
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.

Parameters:
size - the new size.

getElements

public void getElements(int from,
                        short[] a,
                        int offset,
                        int length)
Copies (hopefully quickly) elements of this type-specific list into the given array.

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.

removeElements

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

Parameters:
from - the start index (inclusive).
to - the end index (exclusive).

addElements

public void addElements(int index,
                        short[] a)
Add (hopefully quickly) elements to this type-specific list.

Parameters:
index - the index at which to add elements.
a - the array containing the elements.

addElements

public void addElements(int index,
                        short[] a,
                        int offset,
                        int length)
Add (hopefully quickly) elements to this type-specific list.

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.

add

public void add(int index,
                short key)
See Also:
List.add(int,Object)

addAll

public boolean addAll(int index,
                      ShortCollection c)
See Also:
List.add(int,Object)

addAll

public boolean addAll(int index,
                      ShortList c)
See Also:
List.add(int,Object)

addAll

public boolean addAll(ShortList c)
See Also:
List.add(int,Object)

getShort

public short getShort(int index)
See Also:
List.get(int)

indexOf

public int indexOf(short k)
See Also:
List.indexOf(Object)

lastIndexOf

public int lastIndexOf(short k)
See Also:
List.lastIndexOf(Object)

removeShort

public short removeShort(int index)
See Also:
List.remove(int)

set

public short set(int index,
                 short k)
See Also:
List.set(int,Object)