org.joda.primitives.list
Interface ShortList

All Superinterfaces:
Collection<Short>, Iterable<Short>, List<Short>, PrimitiveCollectable<Short>, PrimitiveCollection<Short>, PrimitiveList<Short>, ShortCollection, ShortIterable
All Known Implementing Classes:
AbstractShortList, ArrayShortList, ImmutableArrayShortList

public interface ShortList
extends PrimitiveList<Short>, ShortCollection

Defines a list of primitive short values.

This interface extends List allowing seamless integration with other APIs. All List methods can be used, using the primitive wrapper class Short. However, it will be much more efficient to use the methods defined here.

Since:
1.0
Version:
CODE GENERATED
Author:
Stephen Colebourne, Jason Tiscione

Method Summary
 boolean add(int index, short value)
          Adds a primitive value to this list at an index (optional operation).
 boolean addAll(int index, short[] values)
          Adds an array of primitive values to this list at an index (optional operation).
 short firstShort()
          Gets the first primitive value.
 short getShort(int index)
          Gets the primitive value at the specified index.
 int indexOf(short value)
          Gets the first index of the specified primitive value.
 int indexOf(short value, int fromIndexInclusive)
          Gets the first index of the specified primitive value from an index.
 ShortIterator iterator()
          Gets an iterator over this list capable of accessing the primitive values.
 int lastIndexOf(short value)
          Gets the last index of the specified primitive value.
 int lastIndexOf(short value, int fromIndexInclusive)
          Gets the first index of the specified primitive value from an index.
 short lastShort()
          Gets the last primitive value.
 ShortListIterator listIterator()
          Gets a list iterator over this list capable of accessing the primitive values.
 ShortListIterator listIterator(int index)
          Gets a list iterator over this list from a start index capable of accessing the primitive values.
 Short remove(int index)
          Deprecated. use short removeShortAt(int)
 short removeShortAt(int index)
          Removes a primitive value by index from the list (optional operation).
 short set(int index, short value)
          Sets the primitive value at a specified index (optional operation).
 ShortList subList(int fromIndexInclusive, int toIndexExclusive)
          Gets a range view of part of this list.
 short[] toShortArray(int fromIndexInclusive, int toIndexExclusive)
          Gets a range of elements as an array.
 
Methods inherited from interface org.joda.primitives.list.PrimitiveList
first, last, removeRange
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
clear, clone, isEmpty, isModifiable, optimize, size
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, remove, removeAll, retainAll, set, size, toArray, toArray
 
Methods inherited from interface org.joda.primitives.collection.ShortCollection
add, addAll, addAll, addAll, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toShortArray, toShortArray
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
clear, clone, isEmpty, isModifiable, optimize, size
 

Method Detail

iterator

ShortIterator iterator()
Gets an iterator over this list capable of accessing the primitive values.

Specified by:
iterator in interface Collection<Short>
Specified by:
iterator in interface Iterable<Short>
Specified by:
iterator in interface List<Short>
Specified by:
iterator in interface ShortCollection
Specified by:
iterator in interface ShortIterable
Returns:
an iterator over this list, not null

getShort

short getShort(int index)
Gets the primitive value at the specified index.

Parameters:
index - the index to get from
Returns:
value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid

firstShort

short firstShort()
Gets the first primitive value.

Returns:
value at index zero
Throws:
IndexOutOfBoundsException - if the size is zero

lastShort

short lastShort()
Gets the last primitive value.

Returns:
value at index size() - 1
Throws:
IndexOutOfBoundsException - if the size is zero

listIterator

ShortListIterator listIterator()
Gets a list iterator over this list capable of accessing the primitive values.

Specified by:
listIterator in interface List<Short>
Returns:
an iterator over this list, not null

listIterator

ShortListIterator listIterator(int index)
Gets a list iterator over this list from a start index capable of accessing the primitive values.

Specified by:
listIterator in interface List<Short>
Parameters:
index - the index to start from
Returns:
an iterator over this list, not null
Throws:
IndexOutOfBoundsException - if the index is invalid

indexOf

int indexOf(short value)
Gets the first index of the specified primitive value.

Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found

indexOf

int indexOf(short value,
            int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.

This method follows the conventions of String in that a negative index is treated as zero, and an index greater than the list size will simply return -1.

Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found

lastIndexOf

int lastIndexOf(short value)
Gets the last index of the specified primitive value.

Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found

lastIndexOf

int lastIndexOf(short value,
                int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.

This method follows the conventions of String in that an index greater than the list size will start searching at the list size, and a negative index simply returns -1.

Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found

toShortArray

short[] toShortArray(int fromIndexInclusive,
                     int toIndexExclusive)
Gets a range of elements as an array.

Parameters:
fromIndexInclusive - the index to start from, inclusive
toIndexExclusive - the index to end at, exclusive
Returns:
a new array containing a copy of the range of elements, not null
Throws:
IndexOutOfBoundsException - if either index is invalid

subList

ShortList subList(int fromIndexInclusive,
                  int toIndexExclusive)
Gets a range view of part of this list.

This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.

Specified by:
subList in interface List<Short>
Parameters:
fromIndexInclusive - the index to start from, inclusive
toIndexExclusive - the index to end at, exclusive
Returns:
a new ShortList for the subList, not null
Throws:
IndexOutOfBoundsException - if either index is invalid

add

boolean add(int index,
            short value)
Adds a primitive value to this list at an index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

Parameters:
index - the index to add at
value - the value to add to this collection
Returns:
true if this list was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

addAll

boolean addAll(int index,
               short[] values)
Adds an array of primitive values to this list at an index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

Parameters:
index - the index to add at
values - the values to add to this collection, null treated as empty array
Returns:
true if this list was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

remove

@Deprecated
Short remove(int index)
Deprecated. use short removeShortAt(int)

Removes a primitive value by index from the list (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

This method is deprecated to serve as a warning to developers. Using it can be confusing as it removes by index rather than by primitive. The method will still function correctly as the method is defined in the List interface. Use removeShortAt(int) instead.

Specified by:
remove in interface List<Short>
Parameters:
index - the index to remove from
Returns:
the primitive value previously at this index
Throws:
IndexOutOfBoundsException - if the index is invalid
UnsupportedOperationException - if not supported by this collection

removeShortAt

short removeShortAt(int index)
Removes a primitive value by index from the list (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

Parameters:
index - the index to remove from
Returns:
the primitive value previously at this index
Throws:
IndexOutOfBoundsException - if the index is invalid
UnsupportedOperationException - if not supported by this collection

set

short set(int index,
          short value)
Sets the primitive value at a specified index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be changed.

Parameters:
index - the index to set
value - the value to store
Returns:
the previous value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection


Copyright © 2005-2010 Joda.org. All Rights Reserved.