Save This Page
Home » commons-collections-3.2.1-src » org.apache.commons » collections » primitives » [javadoc | source]
org.apache.commons.collections.primitives
public interface: ShortList [javadoc | source]

All Implemented Interfaces:
    ShortCollection

All Known Implementing Classes:
    InvocationCounter, RandomAccessShortList, AbstractListShortList, ArrayUnsignedByteList, NonSerializableListShortList, NonSerializableUnmodifiableShortList, BaseUnmodifiableShortList, ListShortList, RandomAccessShortSubList, BaseProxyShortList, ArrayShortList, AbstractRandomAccessShortListImpl, UnmodifiableShortList

An ordered collection of short values.
Method from org.apache.commons.collections.primitives.ShortList Summary:
add,   add,   addAll,   equals,   get,   hashCode,   indexOf,   iterator,   lastIndexOf,   listIterator,   listIterator,   removeElementAt,   set,   subList
Method from org.apache.commons.collections.primitives.ShortList Detail:
 public boolean add(short element)
    Appends the specified element to the end of me (optional operation). Returns true iff I changed as a result of this call.

    If a collection refuses to add the specified element for any reason other than that it already contains the element, it must throw an exception (rather than simply returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

 public  void add(int index,
    short element)
    Inserts the specified element at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right, increasing their indices.
 public boolean addAll(int index,
    ShortCollection collection)
    Inserts all of the elements in the specified collection into me, at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right, increasing their indices. The new elements will appear in the order that they are returned by the given collection's iterator .
 public boolean equals(Object that)
    Returns true iff that is an ShortList that contains the same elements in the same order as me. In other words, returns true iff that is an ShortList that has the same size as me, and for which the elements returned by its iterator are equal (==) to the corresponding elements within me. (This contract ensures that this method works properly across different implementations of the ShortList interface.)
 public short get(int index)
    Returns the value of the element at the specified position within me.
 public int hashCode()
    Returns my hash code.

    The hash code of an ShortList is defined to be the result of the following calculation:

     int hash = 1;
    for(ShortIterator iter = iterator(); iter.hasNext(); ) {
    short value = iter.next();
    hash = 31*hash + (int)(value ^ (value >>> 32));
    }

    This contract ensures that this method is consistent with equals and with the hashCode method of a List of Short s.

 public int indexOf(short element)
    Returns the index of the first occurrence of the specified element within me, or -1 if I do not contain the element.
 public ShortIterator iterator()
    Returns an iterator over all my elements, in the appropriate sequence.
 public int lastIndexOf(short element)
    Returns the index of the last occurrence of the specified element within me, or -1 if I do not contain the element.
 public ShortListIterator listIterator()
 public ShortListIterator listIterator(int index)
    Returns a bidirectional iterator over all my elements, in the appropriate sequence, starting at the specified position. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one.
 public short removeElementAt(int index)
    Removes the element at the specified position in (optional operation). Any subsequent elements are shifted to the left, subtracting one from their indices. Returns the element that was removed.
 public short set(int index,
    short element)
    Replaces the element at the specified position in me with the specified element (optional operation).
 public ShortList subList(int fromIndex,
    int toIndex)
    Returns a view of the elements within me between the specified fromIndex, inclusive, and toIndex, exclusive. The returned ShortList is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support.

    Note that when fromIndex == toIndex, the returned list is initially empty, and when fromIndex == 0 && toIndex == size() the returned list is my "improper" sublist, containing all my elements.

    The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.