|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Short>
org.joda.primitives.collection.impl.AbstractShortCollection
org.joda.primitives.collection.impl.ArrayShortCollection
public class ArrayShortCollection
Array based implementation of ShortCollection for
primitive short elements.
This collection implementation allows multiple copies of the same value to be added. Internally, it uses an array, and behaves much like a list.
This class implements Collection allowing
seamless integration with other APIs.
Add, Remove and Clear are supported.
| Nested Class Summary | |
|---|---|
protected static class |
ArrayShortCollection.PIterator
Iterator. |
| Constructor Summary | |
|---|---|
ArrayShortCollection()
Constructor. |
|
ArrayShortCollection(Collection<?> coll)
Constructs a new collection by copying values from another collection. |
|
ArrayShortCollection(int initialSize)
Constructor that defines an initial size for the internal storage array. |
|
ArrayShortCollection(Iterator<Short> it)
Constructs a new collection by copying values from an iterator. |
|
ArrayShortCollection(short[] values)
Constructor that copies the specified values. |
|
| Method Summary | |
|---|---|
boolean |
add(short value)
Adds a primitive value to this collection. |
boolean |
addAll(short[] values)
Adds an array of primitive values to this collection. |
boolean |
addAll(ShortCollection values)
Adds a collection of primitive values to this collection. |
boolean |
addAll(short startInclusive,
short endInclusive)
Adds a range of primitive values to this collection. |
protected void |
arrayCopy(int fromIndex,
short[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array. |
void |
clear()
Clears the collection of all elements. |
Object |
clone()
Clone implementation that calls Object clone(). |
boolean |
contains(short value)
Checks whether this collection contains a specified primitive value. |
protected boolean |
doAdd(int index,
short[] values)
Internal implementation to add to this collection at the specified index. |
protected void |
doRemoveIndex(int index)
Internal implementation to remove the element at the specified index. |
protected void |
ensureCapacity(int reqCapacity)
Internal implementation to ensure that the internal storage array has at least the specified size. |
protected boolean |
isAddModifiable()
Are the add methods supported. |
boolean |
isModifiable()
Checks whether the object can currently be modified. |
protected boolean |
isRemoveModifiable()
Are the remove methods supported. |
ShortIterator |
iterator()
Gets an iterator over this collection capable of accessing the primitive values. |
void |
optimize()
Optimizes the implementation. |
int |
size()
Gets the current size of the collection. |
| Methods inherited from class org.joda.primitives.collection.impl.AbstractShortCollection |
|---|
add, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toObject, toPrimitive, toPrimitiveArray, toShortArray, toShortArray, toString |
| Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable |
|---|
isEmpty |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.joda.primitives.PrimitiveCollectable |
|---|
isEmpty |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode, isEmpty |
| Constructor Detail |
|---|
public ArrayShortCollection()
public ArrayShortCollection(int initialSize)
initialSize - the initial size of the internal array, negative treated as zeropublic ArrayShortCollection(short[] values)
values - an array of values to copy, null treated as zero size arraypublic ArrayShortCollection(Collection<?> coll)
coll - a collection of values to copy, null treated as zero size collectionpublic ArrayShortCollection(Iterator<Short> it)
it - an iterator of values to extract, null treated as zero size collection| Method Detail |
|---|
public int size()
size in interface Collection<Short>size in interface PrimitiveCollectable<Short>public ShortIterator iterator()
iterator in interface Iterable<Short>iterator in interface Collection<Short>iterator in interface ShortCollectioniterator in interface ShortIterablepublic boolean add(short value)
add in interface ShortCollectionadd in class AbstractShortCollectionvalue - the value to add to this collection
true if this collection was modified by this method call
IllegalArgumentException - if value is rejected by this collectionpublic void optimize()
This implementation changes the internal array to be the same size as the size of the collection.
optimize in interface PrimitiveCollectable<Short>optimize in class AbstractPrimitiveCollectable<Short>protected boolean isAddModifiable()
isAddModifiable in class AbstractShortCollectiontrueprotected boolean isRemoveModifiable()
isRemoveModifiable in class AbstractShortCollectiontruepublic boolean isModifiable()
isModifiable in interface PrimitiveCollectable<Short>isModifiable in class AbstractShortCollectiontruepublic boolean contains(short value)
This implementation uses the internal array directly.
contains in interface ShortCollectioncontains in class AbstractShortCollectionvalue - the value to search for
true if the value is foundpublic void clear()
This implementation resets the size, but does not reduce the internal storage array.
clear in interface Collection<Short>clear in interface PrimitiveCollectable<Short>clear in class AbstractShortCollectionpublic boolean addAll(short[] values)
addAll in interface ShortCollectionaddAll in class AbstractShortCollectionvalues - the values to add to this collection
true if this collection was modified by this method callpublic boolean addAll(ShortCollection values)
addAll in interface ShortCollectionaddAll in class AbstractShortCollectionvalues - the values to add to this collection, null treated as empty collection
true if this collection was modified by this method call
public 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.
addAll in interface ShortCollectionaddAll in class AbstractShortCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end value
true if this collection was modified by this method call
IllegalArgumentException - if a value is rejected by this set
UnsupportedOperationException - if not supported by this setpublic Object clone()
clone in interface PrimitiveCollectable<Short>clone in class AbstractPrimitiveCollectable<Short>
protected void arrayCopy(int fromIndex,
short[] dest,
int destIndex,
int size)
arrayCopy in class AbstractShortCollectionfromIndex - the index to start fromdest - the destination arraydestIndex - the destination start indexsize - the number of items to copy
protected boolean doAdd(int index,
short[] values)
index - the index to add at, validvalues - the array to add, not null
protected void doRemoveIndex(int index)
index - the index, validprotected void ensureCapacity(int reqCapacity)
reqCapacity - the amount to expand to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||