|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Integer>
org.joda.primitives.collection.impl.AbstractIntCollection
public abstract class AbstractIntCollection
Abstract base class for collections of primitive int 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(int) and
iterator remove() methods must also be implemented.
Subclasses may override other methods to increase efficiency.
| Constructor Summary | |
|---|---|
protected |
AbstractIntCollection()
Constructor. |
| Method Summary | ||
|---|---|---|
boolean |
add(int value)
Adds a primitive value to this collection (optional operation). |
|
boolean |
add(Integer value)
Adds the Integer value to this collection (optional operation). |
|
boolean |
addAll(Collection<? extends Integer> coll)
Adds a collection of Integer values to this collection (optional operation). |
|
boolean |
addAll(int[] values)
Adds an array of primitive values to this collection (optional operation). |
|
boolean |
addAll(IntCollection values)
Adds a collection of primitive values to this collection (optional operation). |
|
boolean |
addAll(int startInclusive,
int endInclusive)
Adds a range of primitive values to this collection (optional operation). |
|
protected void |
arrayCopy(int fromIndex,
int[] 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(int value)
Checks whether this collection contains a specified primitive value. |
|
boolean |
contains(Object value)
Checks whether this collection contains a specified Integer value. |
|
boolean |
containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values. |
|
boolean |
containsAll(int[] values)
Checks if this collection contains all of the values in the specified array. |
|
boolean |
containsAll(IntCollection values)
Checks if this collection contains all of the values in the specified collection. |
|
boolean |
containsAll(int startInclusive,
int 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(int[] values)
Checks if this collection contains any of the values in the specified array. |
|
boolean |
containsAny(IntCollection values)
Checks if this collection contains any of the values in the specified collection. |
|
boolean |
containsAny(int startInclusive,
int 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 Integer value from
this collection (optional operation). |
|
boolean |
removeAll(Collection<?> coll)
Removes each of a collection of Integer values from this collection (optional operation). |
|
boolean |
removeAll(int value)
Removes all occurrences of the specified primitive value from this collection. |
|
boolean |
removeAll(int[] values)
Removes all occurrences from this collection of each primitive in the specified array. |
|
boolean |
removeAll(IntCollection values)
Removes all occurrences from this collection of each primitive in the specified collection. |
|
boolean |
removeAll(int startInclusive,
int endInclusive)
Removes all occurrences of a range of primitive values from this collection. |
|
boolean |
removeFirst(int value)
Removes the first occurrence of the specified primitive value from this collection |
|
boolean |
retainAll(Collection<?> coll)
Retains each of a collection of Integer values, removing other
values (optional operation). |
|
boolean |
retainAll(int[] values)
Retains each element of this collection that is present in the specified array removing all other values. |
|
boolean |
retainAll(IntCollection values)
Retains each element of this collection that is present in the specified collection removing all other values. |
|
boolean |
retainAll(int startInclusive,
int 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 Integer. |
|
|
toArray(T[] array)
Gets the collection as an array, using the array provided. |
|
int[] |
toIntArray()
Gets the elements of this collection as an array. |
|
int[] |
toIntArray(int[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position. |
|
protected Integer |
toObject(int value)
Wraps an int with an Object wrapper. |
|
protected int |
toPrimitive(Object value)
Unwraps the Integer to retrieve the primitive int. |
|
protected int[] |
toPrimitiveArray(Collection<?> coll)
Unwraps a Collection to retrieve the primitive int. |
|
String |
toString()
Gets a string representing this collection. |
|
| Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable |
|---|
clone, isEmpty, optimize |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.joda.primitives.collection.IntCollection |
|---|
iterator |
| Methods inherited from interface org.joda.primitives.PrimitiveCollectable |
|---|
clone, isEmpty, optimize, size |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode, isEmpty, size |
| Constructor Detail |
|---|
protected AbstractIntCollection()
| Method Detail |
|---|
public boolean contains(int value)
This implementation uses intIterator().
contains in interface IntCollectionvalue - the value to search for
true if the value is foundpublic boolean containsAll(int[] values)
true is returned.
This implementation uses contains(int).
containsAll in interface IntCollectionvalues - the values to search for, null treated as empty array
true if all of the values are foundpublic boolean containsAll(IntCollection values)
true is returned.
This implementation uses contains(int).
containsAll in interface IntCollectionvalues - the values to search for, null treated as empty collection
true if all of the values are found
public boolean containsAll(int startInclusive,
int 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(int).
containsAll in interface IntCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end value
true if the collection contains the entire rangepublic boolean containsAny(int[] values)
false is returned.
This implementation uses contains(int).
containsAny in interface IntCollectionvalues - the values to search for, null treated as empty array
true if at least one of the values is foundpublic boolean containsAny(IntCollection values)
false is returned.
This implementation uses contains(int).
containsAny in interface IntCollectionvalues - the values to search for, null treated as empty collection
true if at least one of the values is found
public boolean containsAny(int startInclusive,
int 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(int).
containsAny in interface IntCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end value
true if the collection contains at least one of the rangepublic int[] toIntArray()
This implementation uses arrayCopy.
toIntArray in interface IntCollection
public int[] toIntArray(int[] 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.
toIntArray in interface IntCollectionarray - the array to add the elements to, null treated as empty arraystartIndex - the position in the array to start setting elements
IndexOutOfBoundsException - 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<Integer>clear in interface PrimitiveCollectable<Integer>UnsupportedOperationException - if method not supported by this collectionpublic boolean add(int value)
This implementation throws UnsupportedOperationException.
add in interface IntCollectionvalue - the value to add to this collection
true if this collection was modified by this method call
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(int[] values)
This implementation uses add(int).
addAll in interface IntCollectionvalues - the values to add to this collection, null treated as empty array
true if this collection was modified by this method call
IllegalArgumentException - if a value is rejected by this collection
UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(IntCollection values)
This implementation uses add(int).
addAll in interface IntCollectionvalues - the values to add to this collection, null treated as empty collection
true if this collection was modified by this method call
IllegalArgumentException - if a value is rejected by this collection
UnsupportedOperationException - if not supported by this collection
public boolean addAll(int startInclusive,
int 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(int).
addAll in interface IntCollectionstartInclusive - 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 boolean removeFirst(int value)
This implementation uses iterator().remove().
removeFirst in interface IntCollectionvalue - the value to remove
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(int value)
This implementation uses iterator().remove().
removeAll in interface IntCollectionvalue - the value to remove
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(int[] values)
This implementation uses iterator().remove().
removeAll in interface IntCollectionvalues - the values to remove from this collection, null treated as empty array
true if this list was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(IntCollection values)
This implementation uses iterator().remove().
removeAll in interface IntCollectionvalues - the values to remove from this collection, null treated as empty collection
true if this list was modified by this method call
UnsupportedOperationException - if not supported by this collection
public boolean removeAll(int startInclusive,
int 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 IntCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end value
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(int[] values)
This implementation uses iterator().remove().
retainAll in interface IntCollectionvalues - the values to remove from this collection, null treated as empty array
true if this list was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(IntCollection values)
This implementation uses iterator().remove().
retainAll in interface IntCollectionvalues - the values to retain in this collection, null treated as empty collection
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collection
public boolean retainAll(int startInclusive,
int 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 IntCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end value
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean contains(Object value)
Integer value.
This implementation uses contains(int).
contains in interface Collection<Integer>value - the value to search for
true if the value is foundpublic boolean containsAll(Collection<?> coll)
This implementation uses containsAll(int[]).
containsAll in interface Collection<Integer>coll - the collection of values to search for
true if all the values are foundpublic boolean containsAny(Collection<?> coll)
false is returned.
This implementation uses containsAny(int[]).
containsAny in interface PrimitiveCollection<Integer>coll - the collection of values to search for
true if at least one of the values is foundpublic Object[] toArray()
Integer.
toArray in interface Collection<Integer>Integerpublic <T> T[] toArray(T[] array)
toArray in interface Collection<Integer>array - the array to populate
Integerpublic boolean add(Integer value)
Integer value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses add(int).
add in interface Collection<Integer>value - the value to add to this collection
true if this collection was modified by this method call
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(Collection<? extends Integer> coll)
Integer values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(int[]).
addAll in interface Collection<Integer>coll - the values to add to this collection
true if this list was modified by this method call
IndexOutOfBoundsException - if the index is invalid
ClassCastException - if any object is not Integer
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collectionpublic boolean remove(Object value)
Integer value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(int).
remove in interface Collection<Integer>value - the value to remove
true if this collection was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(Collection<?> coll)
Integer values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(int[]).
removeAll in interface Collection<Integer>coll - the values to remove from this collection
true if this list was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(Collection<?> coll)
Integer values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(int[]).
retainAll in interface Collection<Integer>coll - the values to retain in this collection
true if this list was modified by this method call
UnsupportedOperationException - if not supported by this collectionpublic String toString()
The format used is as per Collection.
toString in class Object
protected void arrayCopy(int fromIndex,
int[] 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<Integer>isModifiable in class AbstractPrimitiveCollectable<Integer>protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected Integer toObject(int value)
int with an Object wrapper.
value - the primitive value
protected boolean isToPrimitivePossible(Object value)
This implementation only allows non-null Int objects.
value - the Object wrapper
protected int toPrimitive(Object value)
Integer to retrieve the primitive int.
This implementation only allows non-null Int objects.
value - the Object to convert to a primitive
NullPointerException - if the value is null and this is unacceptable
ClassCastException - if the object is of an unsuitable typeprotected int[] toPrimitiveArray(Collection<?> coll)
Collection to retrieve the primitive int.
This implementation only allows non-null Int objects.
coll - the Collection to convert to primitives
NullPointerException - if the value is null and this is unacceptable
ClassCastException - if any object is of an unsuitable type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||