public abstract class AbstractShortCollection extends AbstractPrimitiveCollectable<Short> implements ShortCollection
short
elements.
This class implements Collection
allowing
seamless integration with other APIs.
The iterator
and size
must be implemented by subclases.
To make the subclass modifiable, the add(short)
and
iterator remove()
methods must also be implemented.
Subclasses may override other methods to increase efficiency.
Modifier | Constructor and Description |
---|---|
protected |
AbstractShortCollection()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(short value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(Short value)
Adds the
Short value to this collection (optional operation). |
boolean |
addAll(Collection<? extends Short> coll)
Adds a collection of
Short values to this collection (optional operation). |
boolean |
addAll(short[] values)
Adds an array of primitive values to this collection (optional operation).
|
boolean |
addAll(ShortCollection values)
Adds a collection of primitive values to this collection (optional operation).
|
boolean |
addAll(short startInclusive,
short endInclusive)
Adds a range of primitive values to this collection (optional operation).
|
protected void |
arrayCopy(int fromIndex,
short[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
protected void |
checkAddModifiable()
Check whether add is suported and throw an exception.
|
protected void |
checkRemoveModifiable()
Check whether remove is suported and throw an exception.
|
void |
clear()
Clears the collection/map of all elements (optional operation).
|
boolean |
contains(Object value)
Checks whether this collection contains a specified
Short value. |
boolean |
contains(short value)
Checks whether this collection contains a specified primitive value.
|
boolean |
containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values.
|
boolean |
containsAll(short[] values)
Checks if this collection contains all of the values in the specified array.
|
boolean |
containsAll(ShortCollection values)
Checks if this collection contains all of the values in the specified collection.
|
boolean |
containsAll(short startInclusive,
short endInclusive)
Checks if this collection contain all the values in the specified range.
|
boolean |
containsAny(Collection<?> coll)
Checks if the collection contains any of the primitive values in the array.
|
boolean |
containsAny(short[] values)
Checks if this collection contains any of the values in the specified array.
|
boolean |
containsAny(ShortCollection values)
Checks if this collection contains any of the values in the specified collection.
|
boolean |
containsAny(short startInclusive,
short endInclusive)
Checks if this collection contain some of the values in the specified range.
|
protected boolean |
isAddModifiable()
Are the add methods supported.
|
boolean |
isModifiable()
Is the collection modifiable in any way.
|
protected boolean |
isRemoveModifiable()
Are the remove methods supported.
|
protected boolean |
isToPrimitivePossible(Object value)
Checks if the object can be converted to a primitive successfully.
|
boolean |
remove(Object value)
Removes the first occurrance of the specified
Short value from
this collection (optional operation). |
boolean |
removeAll(Collection<?> coll)
Removes each of a collection of
Short values from this collection (optional operation). |
boolean |
removeAll(short value)
Removes all occurrences of the specified primitive value from this collection.
|
boolean |
removeAll(short[] values)
Removes all occurrences from this collection of each primitive in the specified array.
|
boolean |
removeAll(ShortCollection values)
Removes all occurrences from this collection of each primitive in the specified collection.
|
boolean |
removeAll(short startInclusive,
short endInclusive)
Removes all occurrences of a range of primitive values from this collection.
|
boolean |
removeFirst(short value)
Removes the first occurrence of the specified primitive value from this collection
|
boolean |
retainAll(Collection<?> coll)
Retains each of a collection of
Short values, removing other
values (optional operation). |
boolean |
retainAll(short[] values)
Retains each element of this collection that is present in the specified array
removing all other values.
|
boolean |
retainAll(ShortCollection values)
Retains each element of this collection that is present in the specified collection
removing all other values.
|
boolean |
retainAll(short startInclusive,
short endInclusive)
Retains all occurences of a range of primitive values within this collection
removing all values outside the range (optional operation).
|
Object[] |
toArray()
Gets the collection as an array of
Short . |
<T> T[] |
toArray(T[] array)
Gets the collection as an array, using the array provided.
|
protected Short |
toObject(short value)
Wraps an
short with an Object wrapper. |
protected short |
toPrimitive(Object value)
Unwraps the
Short to retrieve the primitive short . |
protected short[] |
toPrimitiveArray(Collection<?> coll)
Unwraps a
Collection to retrieve the primitive short . |
short[] |
toShortArray()
Gets the elements of this collection as an array.
|
short[] |
toShortArray(short[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position.
|
String |
toString()
Gets a string representing this collection.
|
clone, isEmpty, optimize
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
iterator
clone, isEmpty, optimize, size
equals, hashCode, isEmpty, size
protected AbstractShortCollection()
public boolean contains(short value)
This implementation uses shortIterator()
.
contains
in interface ShortCollection
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(short[] values)
true
is returned.
This implementation uses contains(short)
.
containsAll
in interface ShortCollection
values
- the values to search for, null treated as empty arraytrue
if all of the values are foundpublic boolean containsAll(ShortCollection values)
true
is returned.
This implementation uses contains(short)
.
containsAll
in interface ShortCollection
values
- the values to search for, null treated as empty collectiontrue
if all of the values are foundpublic boolean containsAll(short startInclusive, short endInclusive)
The range is defined to be inclusive of the start and end.
If the start is greater than the end then the result is true
as the range is equivalent to an empty collection.
This implementation uses contains(short)
.
containsAll
in interface ShortCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end valuetrue
if the collection contains the entire rangepublic boolean containsAny(short[] values)
false
is returned.
This implementation uses contains(short)
.
containsAny
in interface ShortCollection
values
- the values to search for, null treated as empty arraytrue
if at least one of the values is foundpublic boolean containsAny(ShortCollection values)
false
is returned.
This implementation uses contains(short)
.
containsAny
in interface ShortCollection
values
- the values to search for, null treated as empty collectiontrue
if at least one of the values is foundpublic boolean containsAny(short startInclusive, short endInclusive)
The range is defined to be inclusive of the start and end.
If the start is greater than the end then the result is false
as the range is equivalent to an empty collection.
This implementation uses contains(short)
.
containsAny
in interface ShortCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end valuetrue
if the collection contains at least one of the rangepublic short[] toShortArray()
This implementation uses arrayCopy
.
toShortArray
in interface ShortCollection
public short[] toShortArray(short[] array, int startIndex)
If the array specified is null a new array is created. If the array specified is large enough, it will be modified. If the array is not large enough, a new array will be created containing the values from the specified array before the startIndex plus those from this collection.
This implementation uses arrayCopy
.
toShortArray
in interface ShortCollection
array
- the array to add the elements to, null treated as empty arraystartIndex
- the position in the array to start setting elementsIndexOutOfBoundsException
- if the index is negativepublic void clear()
The collection/map will have a zero size after this method completes. This method is optional, throwing an UnsupportedOperationException if the collection/map cannot be cleared.
This implementation uses iterator()
.
clear
in interface Collection<Short>
clear
in interface PrimitiveCollectable<Short>
UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(short value)
This implementation throws UnsupportedOperationException.
add
in interface ShortCollection
value
- the value to add to this collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(short[] values)
This implementation uses add(short)
.
addAll
in interface ShortCollection
values
- the values to add to this collection, null treated as empty arraytrue
if this collection was modified by this method callIllegalArgumentException
- if a value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(ShortCollection values)
This implementation uses add(short)
.
addAll
in interface ShortCollection
values
- the values to add to this collection, null treated as empty collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if a value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(short startInclusive, short endInclusive)
The range is defined to be inclusive of the start and end. If the start is greater than the end then the range is equivalent to an empty collection.
This implementation uses add(short)
.
addAll
in interface ShortCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end valuetrue
if this collection was modified by this method callIllegalArgumentException
- if a value is rejected by this setUnsupportedOperationException
- if not supported by this setpublic boolean removeFirst(short value)
This implementation uses iterator().remove()
.
removeFirst
in interface ShortCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(short value)
This implementation uses iterator().remove()
.
removeAll
in interface ShortCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(short[] values)
This implementation uses iterator().remove()
.
removeAll
in interface ShortCollection
values
- the values to remove from this collection, null treated as empty arraytrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(ShortCollection values)
This implementation uses iterator().remove()
.
removeAll
in interface ShortCollection
values
- the values to remove from this collection, null treated as empty collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(short startInclusive, short endInclusive)
The range is defined to be inclusive of the start and end. The elements removed are greater than or equal to the start and less than or equal to the end. Thus if the start is greater than the end then no elements are removed.
This method is optional, throwing an UnsupportedOperationException if the set cannot be changed.
This implementation uses iterator().remove()
.
removeAll
in interface ShortCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end valuetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(short[] values)
This implementation uses iterator().remove()
.
retainAll
in interface ShortCollection
values
- the values to remove from this collection, null treated as empty arraytrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(ShortCollection values)
This implementation uses iterator().remove()
.
retainAll
in interface ShortCollection
values
- the values to retain in this collection, null treated as empty collectiontrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(short startInclusive, short endInclusive)
The range is defined to be inclusive of the start and end. If the start is greater than the end then the range is equivalent to an empty collection.
This method is optional, throwing an UnsupportedOperationException if the set cannot be changed.
retainAll
in interface ShortCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end valuetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean contains(Object value)
Short
value.
This implementation uses contains(short)
.
contains
in interface Collection<Short>
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(Collection<?> coll)
This implementation uses containsAll(short[])
.
containsAll
in interface Collection<Short>
coll
- the collection of values to search fortrue
if all the values are foundpublic boolean containsAny(Collection<?> coll)
false
is returned.
This implementation uses containsAny(short[])
.
containsAny
in interface PrimitiveCollection<Short>
coll
- the collection of values to search fortrue
if at least one of the values is foundpublic Object[] toArray()
Short
.toArray
in interface Collection<Short>
Short
public <T> T[] toArray(T[] array)
toArray
in interface Collection<Short>
array
- the array to populateShort
public boolean add(Short value)
Short
value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses add(short)
.
add
in interface Collection<Short>
value
- the value to add to this collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(Collection<? extends Short> coll)
Short
values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(short[])
.
addAll
in interface Collection<Short>
coll
- the values to add to this collectiontrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidClassCastException
- if any object is not Short
IllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean remove(Object value)
Short
value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(short)
.
remove
in interface Collection<Short>
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(Collection<?> coll)
Short
values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(short[])
.
removeAll
in interface Collection<Short>
coll
- the values to remove from this collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(Collection<?> coll)
Short
values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(short[])
.
retainAll
in interface Collection<Short>
coll
- the values to retain in this collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic String toString()
The format used is as per Collection
.
protected void arrayCopy(int fromIndex, short[] dest, int destIndex, int size)
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected boolean isAddModifiable()
This implementation returns false.
protected boolean isRemoveModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Short>
isModifiable
in class AbstractPrimitiveCollectable<Short>
protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected Short toObject(short value)
short
with an Object wrapper.value
- the primitive valueprotected boolean isToPrimitivePossible(Object value)
This implementation only allows non-null Short objects.
value
- the Object wrapperprotected short toPrimitive(Object value)
Short
to retrieve the primitive short
.
This implementation only allows non-null Short objects.
value
- the Object to convert to a primitiveNullPointerException
- if the value is null and this is unacceptableClassCastException
- if the object is of an unsuitable typeprotected short[] toPrimitiveArray(Collection<?> coll)
Collection
to retrieve the primitive short
.
This implementation only allows non-null Short objects.
coll
- the Collection to convert to primitivesNullPointerException
- if the value is null and this is unacceptableClassCastException
- if any object is of an unsuitable typeCopyright © 2005-2012 Joda.org. All Rights Reserved.