org.joda.primitives.list.impl
Class AbstractFloatList

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

public abstract class AbstractFloatList
extends AbstractFloatCollection
implements FloatList

Abstract base class for lists of primitive float elements.

This class implements Collection allowing seamless integration with other APIs.

The get(int) and size() methods must be implemented by subclases. To make the subclass modifiable, the add(int, float), removeIndex(int) and set(int, float) must also be implemented. Subclasses may override other methods to increase efficiency.

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

Nested Class Summary
protected static class AbstractFloatList.PListIterator
          List iterator.
 
Constructor Summary
protected AbstractFloatList()
          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 add(int index, float value)
          Adds a primitive value to this list at an index (optional operation).
 void add(int index, Float value)
          Adds the Float value to this list at an index (optional operation).
 boolean addAll(float[] values)
          Adds an array of primitive values to this list at an index (optional operation).
 boolean addAll(int index, Collection<? extends Float> coll)
          Adds an array of Float values to this list at an index (optional operation).
 boolean addAll(int index, float[] values)
          Adds an array of primitive values to this list at an index (optional operation).
protected  void arrayCopy(int fromIndex, float[] dest, int destIndex, int size)
          Copies data from this collection into the specified array.
protected  void checkIndex(int index)
          Checks whether an index is valid or not.
protected  void checkIndexExists(int index)
          Checks whether an index is valid or not.
protected  void checkRange(int fromIndexInclusive, int toIndexExclusive)
          Checks whether a range is valid or not.
protected  void checkSetModifiable()
          Check whether add is suported and throw an exception.
 void clear()
          Clears the listof all elements (optional operation).
 boolean contains(float value)
          Checks whether this collection contains a specified primitive value.
 boolean equals(Object obj)
          Compares this list to another as per the contract of List.
 Float first()
          Gets the first Float value.
 float firstFloat()
          Gets the first primitive value.
 Float get(int index)
          Gets the Float value at the specified index.
 int hashCode()
          Gets the hashCode of this list as per the contract of List.
 int indexOf(float value)
          Gets the first index of the specified primitive value.
 int indexOf(float value, int fromIndexInclusive)
          Gets the first index of the specified primitive value from an index.
 int indexOf(Object value)
          Gets the first index of the specified Float value.
 int indexOf(Object value, int fromIndexInclusive)
          Gets the first index of the specified Float value from an index.
 boolean isModifiable()
          Is the collection modifiable in any way.
protected  boolean isSetModifiable()
          Are the set methods supported.
 FloatListIterator iterator()
          Gets an iterator over this list.
 Float last()
          Gets the last Float value.
 float lastFloat()
          Gets the last primitive value.
 int lastIndexOf(float value)
          Gets the last index of the specified primitive value.
 int lastIndexOf(float value, int fromIndexInclusive)
          Gets the first index of the specified primitive value from an index.
 int lastIndexOf(Object value)
          Gets the last index of the specified Float value.
 int lastIndexOf(Object value, int fromIndexInclusive)
          Gets the first index of the specified Float value from an index.
 FloatListIterator listIterator()
          Gets a list iterator over this list.
 FloatListIterator listIterator(int index)
          Gets a list iterator over this list from a start index.
 Float remove(int index)
          Deprecated. This method should only be used when working with List and not when working with FloatList - use removeFloatAt(int)
 boolean removeFloat(float value)
          Removes the first occurrence of a primitive value from the list (optional operation).
 float removeFloatAt(int index)
          Removes a primitive value by index from the list (optional operation).
 boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
          Removes a range of values from the list (optional operation).
 float set(int index, float value)
          Sets the primitive value at a specified index.
 Float set(int index, Float value)
          Sets the Float value at a specified index.
 FloatList subList(int fromIndexInclusive, int toIndexExclusive)
          Gets a range view of part of this list.
 float[] toFloatArray(int fromIndexInclusive, int toIndexExclusive)
          Gets a range of elements as an array.
 
Methods inherited from class org.joda.primitives.collection.impl.AbstractFloatCollection
addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, isAddModifiable, isRemoveModifiable, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toArray, toArray, toFloatArray, toFloatArray, toObject, toPrimitive, toPrimitiveArray, toString
 
Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable
clone, isEmpty, optimize
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.primitives.list.FloatList
getFloat
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
clone, isEmpty, optimize, size
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface org.joda.primitives.collection.FloatCollection
addAll, containsAll, containsAll, containsAny, containsAny, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, toFloatArray, toFloatArray
 
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection
containsAny
 
Methods inherited from interface org.joda.primitives.PrimitiveCollectable
clone, isEmpty, optimize, size
 

Constructor Detail

AbstractFloatList

protected AbstractFloatList()
Constructor.

Method Detail

iterator

public FloatListIterator iterator()
Gets an iterator over this list.

Specified by:
iterator in interface Iterable<Float>
Specified by:
iterator in interface Collection<Float>
Specified by:
iterator in interface List<Float>
Specified by:
iterator in interface FloatCollection
Specified by:
iterator in interface FloatIterable
Specified by:
iterator in interface FloatList
Returns:
an iterator over this list, not null

listIterator

public FloatListIterator listIterator()
Gets a list iterator over this list.

This implementation uses floatListIterator(int).

Specified by:
listIterator in interface List<Float>
Specified by:
listIterator in interface FloatList
Returns:
an iterator over this list, not null

listIterator

public FloatListIterator listIterator(int index)
Gets a list iterator over this list from a start index.

Specified by:
listIterator in interface List<Float>
Specified by:
listIterator in interface FloatList
Parameters:
index - the index to start from
Returns:
an iterator over this list, not null
Throws:
IndexOutOfBoundsException - if the index is invalid

firstFloat

public float firstFloat()
Gets the first primitive value.

Specified by:
firstFloat in interface FloatList
Returns:
value at index zero
Throws:
IndexOutOfBoundsException - if the size is zero

lastFloat

public float lastFloat()
Gets the last primitive value.

Specified by:
lastFloat in interface FloatList
Returns:
value at index size() - 1
Throws:
IndexOutOfBoundsException - if the size is zero

contains

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

This implementation uses getFloat(int).

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

indexOf

public int indexOf(float value)
Gets the first index of the specified primitive value.

This implementation uses indexof(float, int).

Specified by:
indexOf in interface FloatList
Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found

indexOf

public int indexOf(float value,
                   int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.

This method follows the conventions of String in that a negative index is treated as zero, and an index greater than the list size will simply return -1.

This implementation uses get(int).

Specified by:
indexOf in interface FloatList
Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found

lastIndexOf

public int lastIndexOf(float value)
Gets the last index of the specified primitive value.

This implementation uses lastIndexof(float, int).

Specified by:
lastIndexOf in interface FloatList
Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found

lastIndexOf

public int lastIndexOf(float value,
                       int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.

This method follows the conventions of String in that an index greater than the list size will start searching at the list size, and a negative index simply returns -1.

This implementation uses get(int).

Specified by:
lastIndexOf in interface FloatList
Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found

toFloatArray

public float[] toFloatArray(int fromIndexInclusive,
                            int toIndexExclusive)
Gets a range of elements as an array.

Specified by:
toFloatArray in interface FloatList
Parameters:
fromIndexInclusive - the index to start from, inclusive
toIndexExclusive - the index to end at, exclusive
Returns:
a new array containing a copy of the range of elements, not null
Throws:
IndexOutOfBoundsException - if either index is invalid

subList

public FloatList subList(int fromIndexInclusive,
                         int toIndexExclusive)
Gets a range view of part of this list.

This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.

Specified by:
subList in interface List<Float>
Specified by:
subList in interface FloatList
Parameters:
fromIndexInclusive - the index to start from, inclusive
toIndexExclusive - the index to end at, exclusive
Returns:
a new FloatList for the subList, not null
Throws:
IndexOutOfBoundsException - if either index is invalid

clear

public void clear()
Clears the listof all elements (optional operation).

This implementation uses removeRange(int, int).

Specified by:
clear in interface Collection<Float>
Specified by:
clear in interface List<Float>
Specified by:
clear in interface PrimitiveCollectable<Float>
Overrides:
clear in class AbstractFloatCollection
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 uses add(int, float).

Specified by:
add in interface FloatCollection
Overrides:
add in class AbstractFloatCollection
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

add

public boolean add(int index,
                   float value)
Adds a primitive value to this list at an index (optional operation).

This implementation throws UnsupportedOperationException.

Specified by:
add in interface FloatList
Parameters:
index - the index to add at
value - the value to add to this collection
Returns:
true if this list was modified by this method call
Throws:
IndexOutOfBoundsException - if the index is invalid
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 list at an index (optional operation).

This implementation uses addAll(int, float).

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

addAll

public boolean addAll(int index,
                      float[] values)
Adds an array of primitive values to this list at an index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

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

removeFloatAt

public float removeFloatAt(int index)
Removes a primitive value by index from the list (optional operation).

This implementation throws UnsupportedOperationException.

Specified by:
removeFloatAt in interface FloatList
Parameters:
index - the index to remove from
Returns:
the primitive value previously at this index
Throws:
IndexOutOfBoundsException - if the index is invalid
UnsupportedOperationException - if not supported by this collection

removeFloat

public boolean removeFloat(float value)
Removes the first occurrence of a primitive value from the list (optional operation).

This implementation uses get(int) and removeFloatAt(int).

Parameters:
value - the value to remove
Returns:
the primitive value previously at this index
Throws:
UnsupportedOperationException - if not supported by this collection

removeRange

public boolean removeRange(int fromIndexInclusive,
                           int toIndexExclusive)
Removes a range of values from the list (optional operation).

This implementation uses removeFloatAt(int).

Specified by:
removeRange in interface PrimitiveList<Float>
Parameters:
fromIndexInclusive - the start of the range to remove, inclusive
toIndexExclusive - the end of the range to remove, exclusive
Returns:
true if the collection was modified
Throws:
IndexOutOfBoundsException - if the index is invalid
UnsupportedOperationException - if remove is not supported

set

public float set(int index,
                 float value)
Sets the primitive value at a specified index.

This implementation throws UnsupportedOperationException.

Specified by:
set in interface FloatList
Parameters:
index - the index to set
value - the value to store
Returns:
the previous value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

get

public Float get(int index)
Gets the Float value at the specified index.

Specified by:
get in interface List<Float>
Parameters:
index - the index to get from
Returns:
value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid

first

public Float first()
Gets the first Float value.

Specified by:
first in interface PrimitiveList<Float>
Returns:
value at index zero or null if the size is zero

last

public Float last()
Gets the last Float value.

Specified by:
last in interface PrimitiveList<Float>
Returns:
value at index size() - 1 or null if the size is zero

indexOf

public int indexOf(Object value)
Gets the first index of the specified Float value.

Specified by:
indexOf in interface List<Float>
Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found
Throws:
NullPointerException - if the value if null
ClassCastException - if the object is not Float

indexOf

public int indexOf(Object value,
                   int fromIndexInclusive)
Gets the first index of the specified Float value from an index.

This method follows the conventions of String in that a negative index is treated as zero, and an index greater than the list size will simply return -1.

Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found
Throws:
NullPointerException - if the value if null
ClassCastException - if the object is not Float

lastIndexOf

public int lastIndexOf(Object value)
Gets the last index of the specified Float value.

Specified by:
lastIndexOf in interface List<Float>
Parameters:
value - the value to search for
Returns:
the zero-based index, or -1 if not found
Throws:
NullPointerException - if the value if null
ClassCastException - if the object is not Float

lastIndexOf

public int lastIndexOf(Object value,
                       int fromIndexInclusive)
Gets the first index of the specified Float value from an index.

This method follows the conventions of String in that an index greater than the list size will start searching at the list size, and a negative index simply returns -1.

Parameters:
value - the value to search for
fromIndexInclusive - the index to start searching from, inclusive
Returns:
the zero-based index, or -1 if not found
Throws:
NullPointerException - if the value if null
ClassCastException - if the object is not 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.

Specified by:
add in interface Collection<Float>
Specified by:
add in interface List<Float>
Overrides:
add in class AbstractFloatCollection
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

add

public void add(int index,
                Float value)
Adds the Float value to this list at an index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

Specified by:
add in interface List<Float>
Parameters:
index - the index to add at
value - the value to add to this collection
Throws:
IndexOutOfBoundsException - if the index is invalid
ClassCastException - if the object is not Float
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

addAll

public boolean addAll(int index,
                      Collection<? extends Float> coll)
Adds an array of Float values to this list at an index (optional operation).

This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.

Specified by:
addAll in interface List<Float>
Parameters:
index - the index to add at
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 Float remove(int index)
Deprecated. This method should only be used when working with List and not when working with FloatList - use removeFloatAt(int)

Removes a primitive value by index from the list (optional operation).

This implementation uses removeFloatAt(int).

Specified by:
remove in interface List<Float>
Specified by:
remove in interface FloatList
Parameters:
index - the index to remove from
Returns:
the primitive value previously at this index
Throws:
IndexOutOfBoundsException - if the index is invalid
UnsupportedOperationException - if not supported by this collection

set

public Float set(int index,
                 Float value)
Sets the Float value at a specified index.

This implementation uses set(int, float).

Specified by:
set in interface List<Float>
Parameters:
index - the index to set
value - the value to store
Returns:
the previous value at the index
Throws:
IndexOutOfBoundsException - if the index is invalid
IllegalArgumentException - if value is rejected by this collection
UnsupportedOperationException - if not supported by this collection

equals

public boolean equals(Object obj)
Compares this list to another as per the contract of List.

Specified by:
equals in interface Collection<Float>
Specified by:
equals in interface List<Float>
Overrides:
equals in class Object
Parameters:
obj - the object to compare to
Returns:
true if the lists are equal

hashCode

public int hashCode()
Gets the hashCode of this list as per the contract of List.

Specified by:
hashCode in interface Collection<Float>
Specified by:
hashCode in interface List<Float>
Overrides:
hashCode in class Object
Returns:
the hash code for this list

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.

Overrides:
arrayCopy in class AbstractFloatCollection
Parameters:
fromIndex - the index to start from
dest - the destination array
destIndex - the destination start index
size - the number of items to copy

isSetModifiable

protected boolean isSetModifiable()
Are the set 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 AbstractFloatCollection
Returns:
true if supported

checkSetModifiable

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


checkIndexExists

protected void checkIndexExists(int index)
Checks whether an index is valid or not.

Parameters:
index - the index to check
Throws:
IndexOutOfBoundsException - if either index is invalid

checkIndex

protected void checkIndex(int index)
Checks whether an index is valid or not.

Parameters:
index - the index to check
Throws:
IndexOutOfBoundsException - if either index is invalid

checkRange

protected void checkRange(int fromIndexInclusive,
                          int toIndexExclusive)
Checks whether a range is valid or not.

Parameters:
fromIndexInclusive - the index to start from, inclusive
toIndexExclusive - the index to end at, exclusive
Throws:
IndexOutOfBoundsException - if either index is invalid


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