org.joda.primitives.collection.impl
Class AbstractFloatCollection

java.lang.Object
  extended by org.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Float>
      extended by org.joda.primitives.collection.impl.AbstractFloatCollection
All Implemented Interfaces:
Iterable<Float>, Collection<Float>, FloatCollection, PrimitiveCollection<Float>, FloatIterable, PrimitiveCollectable<Float>
Direct Known Subclasses:
AbstractFloatList, ArrayFloatCollection

public abstract class AbstractFloatCollection
extends AbstractPrimitiveCollectable<Float>
implements FloatCollection

Abstract base class for collections of primitive 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.

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

Constructor Summary
protected AbstractFloatCollection()
          Constructor.
 
Method Summary
 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.
 
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.FloatCollection
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

AbstractFloatCollection

protected AbstractFloatCollection()
Constructor.

Method Detail

contains

public boolean contains(float value)
Checks whether this collection contains a specified primitive value.

This implementation uses floatIterator().

Specified by:
contains in interface FloatCollection
Parameters:
value - the value to search for
Returns:
true if the value is found

containsAll

public boolean containsAll(float[] values)
Checks if this collection contains all of the values in the specified array. If the specified array is empty, true is returned.

This implementation uses contains(float).

Specified by:
containsAll in interface FloatCollection
Parameters:
values - the values to search for, null treated as empty array
Returns:
true if all of the values are found

containsAll

public boolean containsAll(FloatCollection values)
Checks if this collection contains all of the values in the specified collection. If the specified collection is empty, true is returned.

This implementation uses contains(float).

Specified by:
containsAll in interface FloatCollection
Parameters:
values - the values to search for, null treated as empty collection
Returns:
true if all of the values are found

containsAny

public boolean containsAny(float[] values)
Checks if this collection contains any of the values in the specified array. If the specified array is empty, false is returned.

This implementation uses contains(float).

Specified by:
containsAny in interface FloatCollection
Parameters:
values - the values to search for, null treated as empty array
Returns:
true if at least one of the values is found

containsAny

public boolean containsAny(FloatCollection values)
Checks if this collection contains any of the values in the specified collection. If the specified collection is empty, false is returned.

This implementation uses contains(float).

Specified by:
containsAny in interface FloatCollection
Parameters:
values - the values to search for, null treated as empty collection
Returns:
true if at least one of the values is found

toFloatArray

public float[] toFloatArray()
Gets the elements of this collection as an array.

This implementation uses arrayCopy.

Specified by:
toFloatArray in interface FloatCollection
Returns:
a new array containing a copy of the elements of this collection

toFloatArray

public float[] toFloatArray(float[] array,
                            int startIndex)
Copies the elements of this collection into an array at a specified position. Previous values in the array are overwritten.

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.

Specified by:
toFloatArray in interface FloatCollection
Parameters:
array - the array to add the elements to, null treated as empty array
startIndex - the position in the array to start setting elements
Returns:
the array with the populated collection
Throws:
IndexOutOfBoundsException - if the index is negative

clear

public void clear()
Clears the collection/map of all elements (optional operation).

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().

Specified by:
clear in interface Collection<Float>
Specified by:
clear in interface PrimitiveCollectable<Float>
Throws:
UnsupportedOperationException - if method not supported by this collection

add

public boolean add(float value)
Adds a primitive value to this collection (optional operation).

This implementation throws UnsupportedOperationException.

Specified by:
add in interface FloatCollection
Parameters:
value - the value to add to this collection
Returns:
true if this collection was modified by this method call
Throws:
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

addAll

public boolean addAll(float[] values)
Adds an array of primitive values to this collection (optional operation).

This implementation uses add(float).

Specified by:
addAll in interface FloatCollection
Parameters:
values - the values to add to this collection, null treated as empty array
Returns:
true if this collection was modified by this method call
Throws:
IllegalArgumentException - if a value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

addAll

public boolean addAll(FloatCollection values)
Adds a collection of primitive values to this collection (optional operation).

This implementation uses add(float).

Specified by:
addAll in interface FloatCollection
Parameters:
values - the values to add to this collection, null treated as empty collection
Returns:
true if this collection was modified by this method call
Throws:
IllegalArgumentException - if a value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

removeFirst

public boolean removeFirst(float value)
Removes the first occurrence of the specified primitive value from this collection

This implementation uses iterator().remove().

Specified by:
removeFirst in interface FloatCollection
Parameters:
value - the value to remove
Returns:
true if this collection was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

removeAll

public boolean removeAll(float value)
Removes all occurrences of the specified primitive value from this collection.

This implementation uses iterator().remove().

Specified by:
removeAll in interface FloatCollection
Parameters:
value - the value to remove
Returns:
true if this collection was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

removeAll

public boolean removeAll(float[] values)
Removes all occurrences from this collection of each primitive in the specified array.

This implementation uses iterator().remove().

Specified by:
removeAll in interface FloatCollection
Parameters:
values - the values to remove from this collection, null treated as empty array
Returns:
true if this list was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

removeAll

public boolean removeAll(FloatCollection values)
Removes all occurrences from this collection of each primitive in the specified collection.

This implementation uses iterator().remove().

Specified by:
removeAll in interface FloatCollection
Parameters:
values - the values to remove from this collection, null treated as empty collection
Returns:
true if this list was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

retainAll

public boolean retainAll(float[] values)
Retains each element of this collection that is present in the specified array removing all other values.

This implementation uses iterator().remove().

Specified by:
retainAll in interface FloatCollection
Parameters:
values - the values to remove from this collection, null treated as empty array
Returns:
true if this list was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

retainAll

public boolean retainAll(FloatCollection values)
Retains each element of this collection that is present in the specified collection removing all other values.

This implementation uses iterator().remove().

Specified by:
retainAll in interface FloatCollection
Parameters:
values - the values to retain in this collection, null treated as empty collection
Returns:
true if this collection was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

contains

public boolean contains(Object value)
Checks whether this collection contains a specified Float value.

This implementation uses contains(float).

Specified by:
contains in interface Collection<Float>
Parameters:
value - the value to search for
Returns:
true if the value is found

containsAll

public boolean containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values.

This implementation uses containsAll(float[]).

Specified by:
containsAll in interface Collection<Float>
Parameters:
coll - the collection of values to search for
Returns:
true if all the values are found

containsAny

public boolean containsAny(Collection<?> coll)
Checks if the collection contains any of the primitive values in the array. If the specified collection is empty, false is returned.

This implementation uses containsAny(float[]).

Specified by:
containsAny in interface PrimitiveCollection<Float>
Parameters:
coll - the collection of values to search for
Returns:
true if at least one of the values is found

toArray

public Object[] toArray()
Gets the collection as an array of Float.

Specified by:
toArray in interface Collection<Float>
Returns:
an array of Float

toArray

public <T> T[] toArray(T[] array)
Gets the collection as an array, using the array provided.

Specified by:
toArray in interface Collection<Float>
Parameters:
array - the array to populate
Returns:
an array of Float

add

public boolean add(Float value)
Adds the 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).

Specified by:
add in interface Collection<Float>
Parameters:
value - the value to add to this collection
Returns:
true if this collection was modified by this method call
Throws:
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

addAll

public boolean addAll(Collection<? extends Float> coll)
Adds a collection of 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[]).

Specified by:
addAll in interface Collection<Float>
Parameters:
coll - the values to add to this collection
Returns:
true if this list was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid
ClassCastException - if any object is not Float
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

remove

public boolean remove(Object value)
Removes the first occurrance of the specified 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).

Specified by:
remove in interface Collection<Float>
Parameters:
value - the value to remove
Returns:
true if this collection was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

removeAll

public boolean removeAll(Collection<?> coll)
Removes each of a collection of 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[]).

Specified by:
removeAll in interface Collection<Float>
Parameters:
coll - the values to remove from this collection
Returns:
true if this list was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

retainAll

public boolean retainAll(Collection<?> coll)
Retains each of a collection of 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[]).

Specified by:
retainAll in interface Collection<Float>
Parameters:
coll - the values to retain in this collection
Returns:
true if this list was modified by this method call
Throws:
UnsupportedOperationException - if not supported by this collection

toString

public String toString()
Gets a string representing this collection.

The format used is as per Collection.

Overrides:
toString in class Object
Returns:
collection as a String

arrayCopy

protected void arrayCopy(int fromIndex,
                         float[] dest,
                         int destIndex,
                         int size)
Copies data from this collection into the specified array. This method is pre-validated.

Parameters:
fromIndex - the index to start from
dest - the destination array
destIndex - the destination start index
size - the number of items to copy

isAddModifiable

protected boolean isAddModifiable()
Are the add methods supported.

This implementation returns false.

Returns:
true if supported

isRemoveModifiable

protected boolean isRemoveModifiable()
Are the remove methods supported.

This implementation returns false.

Returns:
true if supported

isModifiable

public boolean isModifiable()
Is the collection modifiable in any way.

Specified by:
isModifiable in interface PrimitiveCollectable<Float>
Overrides:
isModifiable in class AbstractPrimitiveCollectable<Float>
Returns:
true if supported

checkAddModifiable

protected void checkAddModifiable()
Check whether add is suported and throw an exception.


checkRemoveModifiable

protected void checkRemoveModifiable()
Check whether remove is suported and throw an exception.


toObject

protected Float toObject(float value)
Wraps an float with an Object wrapper.

Parameters:
value - the primitive value
Returns:
the Object wrapper

isToPrimitivePossible

protected boolean isToPrimitivePossible(Object value)
Checks if the object can be converted to a primitive successfully.

This implementation only allows non-null Float objects.

Parameters:
value - the Object wrapper
Returns:
true if a primitive value can be successfully extracted

toPrimitive

protected float toPrimitive(Object value)
Unwraps the Float to retrieve the primitive float.

This implementation only allows non-null Float objects.

Parameters:
value - the Object to convert to a primitive
Returns:
the primitive value
Throws:
NullPointerException - if the value is null and this is unacceptable
ClassCastException - if the object is of an unsuitable type

toPrimitiveArray

protected float[] toPrimitiveArray(Collection<?> coll)
Unwraps a Collection to retrieve the primitive float.

This implementation only allows non-null Float objects.

Parameters:
coll - the Collection to convert to primitives
Returns:
the primitive value
Throws:
NullPointerException - if the value is null and this is unacceptable
ClassCastException - if any object is of an unsuitable type


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