public abstract class AbstractFloatCollection extends AbstractPrimitiveCollectable<Float> implements FloatCollection
float
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(float)
and
iterator remove()
methods must also be implemented.
Subclasses may override other methods to increase efficiency.
Modifier | Constructor and Description |
---|---|
protected |
AbstractFloatCollection()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(float value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(Float value)
Adds the
Float value to this collection (optional operation). |
boolean |
addAll(Collection<? extends Float> coll)
Adds a collection of
Float values to this collection (optional operation). |
boolean |
addAll(float[] values)
Adds an array of primitive values to this collection (optional operation).
|
boolean |
addAll(FloatCollection values)
Adds a collection of primitive values to this collection (optional operation).
|
protected void |
arrayCopy(int fromIndex,
float[] 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(float value)
Checks whether this collection contains a specified primitive value.
|
boolean |
contains(Object value)
Checks whether this collection contains a specified
Float value. |
boolean |
containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values.
|
boolean |
containsAll(float[] values)
Checks if this collection contains all of the values in the specified array.
|
boolean |
containsAll(FloatCollection values)
Checks if this collection contains all of the values in the specified collection.
|
boolean |
containsAny(Collection<?> coll)
Checks if the collection contains any of the primitive values in the array.
|
boolean |
containsAny(float[] values)
Checks if this collection contains any of the values in the specified array.
|
boolean |
containsAny(FloatCollection values)
Checks if this collection contains any of the values in the specified collection.
|
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
Float value from
this collection (optional operation). |
boolean |
removeAll(Collection<?> coll)
Removes each of a collection of
Float values from this collection (optional operation). |
boolean |
removeAll(float value)
Removes all occurrences of the specified primitive value from this collection.
|
boolean |
removeAll(float[] values)
Removes all occurrences from this collection of each primitive in the specified array.
|
boolean |
removeAll(FloatCollection values)
Removes all occurrences from this collection of each primitive in the specified collection.
|
boolean |
removeFirst(float value)
Removes the first occurrence of the specified primitive value from this collection
|
boolean |
retainAll(Collection<?> coll)
Retains each of a collection of
Float values, removing other
values (optional operation). |
boolean |
retainAll(float[] values)
Retains each element of this collection that is present in the specified array
removing all other values.
|
boolean |
retainAll(FloatCollection values)
Retains each element of this collection that is present in the specified collection
removing all other values.
|
Object[] |
toArray()
Gets the collection as an array of
Float . |
<T> T[] |
toArray(T[] array)
Gets the collection as an array, using the array provided.
|
float[] |
toFloatArray()
Gets the elements of this collection as an array.
|
float[] |
toFloatArray(float[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position.
|
protected Float |
toObject(float value)
Wraps an
float with an Object wrapper. |
protected float |
toPrimitive(Object value)
Unwraps the
Float to retrieve the primitive float . |
protected float[] |
toPrimitiveArray(Collection<?> coll)
Unwraps a
Collection to retrieve the primitive float . |
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 AbstractFloatCollection()
public boolean contains(float value)
This implementation uses floatIterator()
.
contains
in interface FloatCollection
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(float[] values)
true
is returned.
This implementation uses contains(float)
.
containsAll
in interface FloatCollection
values
- the values to search for, null treated as empty arraytrue
if all of the values are foundpublic boolean containsAll(FloatCollection values)
true
is returned.
This implementation uses contains(float)
.
containsAll
in interface FloatCollection
values
- the values to search for, null treated as empty collectiontrue
if all of the values are foundpublic boolean containsAny(float[] values)
false
is returned.
This implementation uses contains(float)
.
containsAny
in interface FloatCollection
values
- the values to search for, null treated as empty arraytrue
if at least one of the values is foundpublic boolean containsAny(FloatCollection values)
false
is returned.
This implementation uses contains(float)
.
containsAny
in interface FloatCollection
values
- the values to search for, null treated as empty collectiontrue
if at least one of the values is foundpublic float[] toFloatArray()
This implementation uses arrayCopy
.
toFloatArray
in interface FloatCollection
public float[] toFloatArray(float[] 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
.
toFloatArray
in interface FloatCollection
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<Float>
clear
in interface PrimitiveCollectable<Float>
UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(float value)
This implementation throws UnsupportedOperationException.
add
in interface FloatCollection
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(float[] values)
This implementation uses add(float)
.
addAll
in interface FloatCollection
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(FloatCollection values)
This implementation uses add(float)
.
addAll
in interface FloatCollection
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 removeFirst(float value)
This implementation uses iterator().remove()
.
removeFirst
in interface FloatCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(float value)
This implementation uses iterator().remove()
.
removeAll
in interface FloatCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(float[] values)
This implementation uses iterator().remove()
.
removeAll
in interface FloatCollection
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(FloatCollection values)
This implementation uses iterator().remove()
.
removeAll
in interface FloatCollection
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 retainAll(float[] values)
This implementation uses iterator().remove()
.
retainAll
in interface FloatCollection
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(FloatCollection values)
This implementation uses iterator().remove()
.
retainAll
in interface FloatCollection
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 contains(Object value)
Float
value.
This implementation uses contains(float)
.
contains
in interface Collection<Float>
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(Collection<?> coll)
This implementation uses containsAll(float[])
.
containsAll
in interface Collection<Float>
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(float[])
.
containsAny
in interface PrimitiveCollection<Float>
coll
- the collection of values to search fortrue
if at least one of the values is foundpublic Object[] toArray()
Float
.toArray
in interface Collection<Float>
Float
public <T> T[] toArray(T[] array)
toArray
in interface Collection<Float>
array
- the array to populateFloat
public boolean add(Float value)
Float
value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses add(float)
.
add
in interface Collection<Float>
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 Float> coll)
Float
values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(float[])
.
addAll
in interface Collection<Float>
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 Float
IllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean remove(Object value)
Float
value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(float)
.
remove
in interface Collection<Float>
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(Collection<?> coll)
Float
values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(float[])
.
removeAll
in interface Collection<Float>
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)
Float
values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(float[])
.
retainAll
in interface Collection<Float>
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, float[] 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<Float>
isModifiable
in class AbstractPrimitiveCollectable<Float>
protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected Float toObject(float value)
float
with an Object wrapper.value
- the primitive valueprotected boolean isToPrimitivePossible(Object value)
This implementation only allows non-null Float objects.
value
- the Object wrapperprotected float toPrimitive(Object value)
Float
to retrieve the primitive float
.
This implementation only allows non-null Float 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 float[] toPrimitiveArray(Collection<?> coll)
Collection
to retrieve the primitive float
.
This implementation only allows non-null Float 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.