it.unimi.dsi.fastutil.floats
Class AbstractFloatList

java.lang.Object
  extended by it.unimi.dsi.fastutil.floats.AbstractFloatCollection
      extended by it.unimi.dsi.fastutil.floats.AbstractFloatList
All Implemented Interfaces:
FloatCollection, FloatIterable, FloatList, FloatStack, Stack<Float>, Comparable<List<? extends Float>>, Iterable<Float>, Collection<Float>, List<Float>
Direct Known Subclasses:
AbstractFloatList.FloatSubList, FloatArrayList, FloatLists.Singleton

public abstract class AbstractFloatList
extends AbstractFloatCollection
implements FloatList, FloatStack

An abstract class providing basic methods for lists implementing a type-specific list interface.

As an additional bonus, this class implements on top of the list operations a type-specific stack.


Nested Class Summary
static class AbstractFloatList.FloatSubList
           
 
Method Summary
 boolean add(float k)
           
 void add(int index, float k)
           
 void add(int index, Float ok)
          Delegates to the corresponding type-specific method.
 boolean addAll(Collection<? extends Float> c)
          Delegates to a more generic method.
 boolean addAll(FloatCollection c)
          Adds all elements of the given type-specific collection to this collection.
 boolean addAll(FloatList l)
           
 boolean addAll(int index, Collection<? extends Float> c)
           
 boolean addAll(int index, FloatCollection c)
          Delegates to a more generic method.
 boolean addAll(int index, FloatList l)
          Delegates to a more generic method.
 void addElements(int index, float[] a)
          Add (hopefully quickly) elements to this type-specific list.
 void addElements(int index, float[] a, int offset, int length)
          Adds elements to this type-specific list one-by-one.
 int compareTo(List<? extends Float> l)
          Compares this list to another object.
 boolean contains(float k)
           
 boolean equals(Object o)
           
 FloatListIterator floatListIterator()
          Deprecated. 
 FloatListIterator floatListIterator(int index)
          Deprecated. 
 FloatList floatSubList(int from, int to)
          Deprecated. 
 Float get(int index)
          Delegates to the corresponding type-specific method.
 void getElements(int from, float[] a, int offset, int length)
          Copies element of this type-specific list into the given array one-by-one.
 int hashCode()
          Returns the hash code for this list, which is identical to List.hashCode().
 int indexOf(float k)
           
 int indexOf(Object ok)
          Delegates to the corresponding type-specific method.
 FloatIterator iterator()
          Returns a type-specific iterator on the elements of this collection.
 int lastIndexOf(float k)
           
 int lastIndexOf(Object ok)
          Delegates to the corresponding type-specific method.
 FloatListIterator listIterator()
          Returns a type-specific list iterator on the list.
 FloatListIterator listIterator(int index)
          Returns a type-specific list iterator on the list starting at a given index.
 Float peek(int i)
          Delegates to the corresponding type-specific method.
 float peekFloat(int i)
           
 Float pop()
          Delegates to the corresponding type-specific method.
 float popFloat()
           
 void push(float o)
           
 void push(Float o)
          Delegates to the corresponding type-specific method.
 boolean rem(float k)
          Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name.
 Float remove(int index)
          Delegates to the corresponding type-specific method.
 boolean remove(Object o)
          Delegates to rem().
 void removeElements(int from, int to)
          Removes elements of this type-specific list one-by-one.
 float removeFloat(int i)
           
 float set(int index, float k)
           
 Float set(int index, Float ok)
          Delegates to the corresponding type-specific method.
 void size(int size)
          Sets the size of this list.
 FloatList subList(int from, int to)
          Returns a type-specific view of the portion of this list from the index from, inclusive, to the index to, exclusive.
 Float top()
          Delegates to the corresponding type-specific method.
 float topFloat()
           
 String toString()
           
 
Methods inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatCollection
add, clear, contains, containsAll, containsAll, floatIterator, isEmpty, rem, removeAll, removeAll, retainAll, retainAll, toArray, toArray, toArray, toFloatArray, toFloatArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.floats.FloatList
getFloat
 
Methods inherited from interface java.util.List
add, clear, contains, containsAll, isEmpty, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.floats.FloatCollection
containsAll, floatIterator, removeAll, retainAll, toArray, toArray, toFloatArray, toFloatArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Method Detail

add

public void add(int index,
                float k)
Specified by:
add in interface FloatList
See Also:
List.add(int,Object)

add

public boolean add(float k)
Specified by:
add in interface FloatCollection
Overrides:
add in class AbstractFloatCollection
See Also:
Collection.add(Object)

removeFloat

public float removeFloat(int i)
Specified by:
removeFloat in interface FloatList
See Also:
List.remove(int)

set

public float set(int index,
                 float k)
Specified by:
set in interface FloatList
See Also:
List.set(int,Object)

addAll

public boolean addAll(int index,
                      Collection<? extends Float> c)
Specified by:
addAll in interface List<Float>

addAll

public boolean addAll(Collection<? extends Float> c)
Delegates to a more generic method.

Specified by:
addAll in interface Collection<Float>
Specified by:
addAll in interface List<Float>
Overrides:
addAll in class AbstractFloatCollection
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

floatListIterator

@Deprecated
public FloatListIterator floatListIterator()
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
floatListIterator in interface FloatList
See Also:
FloatList.listIterator()

floatListIterator

@Deprecated
public FloatListIterator floatListIterator(int index)
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
floatListIterator in interface FloatList
See Also:
FloatList.listIterator(int)

iterator

public FloatIterator iterator()
Description copied from interface: FloatCollection
Returns a type-specific iterator on the elements of this collection.

Note that this specification strengthens the one given in Iterable.iterator(), which was already strengthened in the corresponding type-specific class, but was weakened by the fact that this interface extends Collection.

Specified by:
iterator in interface FloatCollection
Specified by:
iterator in interface FloatIterable
Specified by:
iterator in interface FloatList
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 class AbstractFloatCollection
Returns:
a type-specific iterator on the elements of this collection.

listIterator

public FloatListIterator listIterator()
Description copied from interface: FloatList
Returns a type-specific list iterator on the list.

Specified by:
listIterator in interface FloatList
Specified by:
listIterator in interface List<Float>
See Also:
FloatList.listIterator()

listIterator

public FloatListIterator listIterator(int index)
Description copied from interface: FloatList
Returns a type-specific list iterator on the list starting at a given index.

Specified by:
listIterator in interface FloatList
Specified by:
listIterator in interface List<Float>
See Also:
FloatList.listIterator(int)

contains

public boolean contains(float k)
Specified by:
contains in interface FloatCollection
See Also:
Collection.contains(Object)

indexOf

public int indexOf(float k)
Specified by:
indexOf in interface FloatList
See Also:
List.indexOf(Object)

lastIndexOf

public int lastIndexOf(float k)
Specified by:
lastIndexOf in interface FloatList
See Also:
List.lastIndexOf(Object)

size

public void size(int size)
Description copied from interface: FloatList
Sets the size of this list.

If the specified size is smaller than the current size, the last elements are discarded. Otherwise, they are filled with 0/null/false.

Specified by:
size in interface FloatList
Parameters:
size - the new size.

subList

public FloatList subList(int from,
                         int to)
Description copied from interface: FloatList
Returns a type-specific view of the portion of this list from the index from, inclusive, to the index to, exclusive.

Note that this specification strengthens the one given in List.subList(int,int).

Specified by:
subList in interface FloatList
Specified by:
subList in interface List<Float>
See Also:
List.subList(int,int)

floatSubList

@Deprecated
public FloatList floatSubList(int from,
                                         int to)
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
floatSubList in interface FloatList
See Also:
List.subList(int,int)

removeElements

public void removeElements(int from,
                           int to)
Removes elements of this type-specific list one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
removeElements in interface FloatList
Parameters:
from - the start index (inclusive).
to - the end index (exclusive).

addElements

public void addElements(int index,
                        float[] a,
                        int offset,
                        int length)
Adds elements to this type-specific list one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
addElements in interface FloatList
Parameters:
index - the index at which to add elements.
a - the array containing the elements.
offset - the offset of the first element to add.
length - the number of elements to add.

addElements

public void addElements(int index,
                        float[] a)
Description copied from interface: FloatList
Add (hopefully quickly) elements to this type-specific list.

Specified by:
addElements in interface FloatList
Parameters:
index - the index at which to add elements.
a - the array containing the elements.

getElements

public void getElements(int from,
                        float[] a,
                        int offset,
                        int length)
Copies element of this type-specific list into the given array one-by-one.

This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

Specified by:
getElements in interface FloatList
Parameters:
from - the start index (inclusive).
a - the destination array.
offset - the offset into the destination array where to store the first element copied.
length - the number of elements to be copied.

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<Float>
Specified by:
equals in interface List<Float>
Overrides:
equals in class Object

compareTo

public int compareTo(List<? extends Float> l)
Compares this list to another object. If the argument is a List, this method performs a lexicographical comparison; otherwise, it throws a ClassCastException.

Specified by:
compareTo in interface Comparable<List<? extends Float>>
Parameters:
l - an list.
Returns:
if the argument is a List, a negative integer, zero, or a positive integer as this list is lexicographically less than, equal to, or greater than the argument.
Throws:
ClassCastException - if the argument is not a list.

hashCode

public int hashCode()
Returns the hash code for this list, which is identical to List.hashCode().

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.

push

public void push(float o)
Specified by:
push in interface FloatStack
See Also:
Stack.push(Object)

popFloat

public float popFloat()
Specified by:
popFloat in interface FloatStack
See Also:
Stack.pop()

topFloat

public float topFloat()
Specified by:
topFloat in interface FloatStack
See Also:
Stack.top()

peekFloat

public float peekFloat(int i)
Specified by:
peekFloat in interface FloatStack
See Also:
Stack.peek(int)

rem

public boolean rem(float k)
Description copied from interface: FloatCollection
Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name. For simplicity, the set interfaces reinstates remove().

Specified by:
rem in interface FloatCollection
Overrides:
rem in class AbstractFloatCollection
See Also:
Collection.remove(Object)

remove

public boolean remove(Object o)
Delegates to rem().

Specified by:
remove in interface Collection<Float>
Specified by:
remove in interface List<Float>
Overrides:
remove in class AbstractFloatCollection

addAll

public boolean addAll(int index,
                      FloatCollection c)
Delegates to a more generic method.

Specified by:
addAll in interface FloatList
See Also:
List.add(int,Object)

addAll

public boolean addAll(int index,
                      FloatList l)
Delegates to a more generic method.

Specified by:
addAll in interface FloatList
See Also:
List.add(int,Object)

addAll

public boolean addAll(FloatCollection c)
Description copied from class: AbstractFloatCollection
Adds all elements of the given type-specific collection to this collection.

Specified by:
addAll in interface FloatCollection
Overrides:
addAll in class AbstractFloatCollection
Parameters:
c - a type-specific collection.
Returns:
true if this collection changed as a result of the call.
See Also:
Collection.addAll(Collection)

addAll

public boolean addAll(FloatList l)
Specified by:
addAll in interface FloatList
See Also:
List.add(int,Object)

add

public void add(int index,
                Float ok)
Delegates to the corresponding type-specific method.

Specified by:
add in interface List<Float>

set

public Float set(int index,
                 Float ok)
Delegates to the corresponding type-specific method.

Specified by:
set in interface List<Float>

get

public Float get(int index)
Delegates to the corresponding type-specific method.

Specified by:
get in interface List<Float>

indexOf

public int indexOf(Object ok)
Delegates to the corresponding type-specific method.

Specified by:
indexOf in interface List<Float>

lastIndexOf

public int lastIndexOf(Object ok)
Delegates to the corresponding type-specific method.

Specified by:
lastIndexOf in interface List<Float>

remove

public Float remove(int index)
Delegates to the corresponding type-specific method.

Specified by:
remove in interface List<Float>

push

public void push(Float o)
Delegates to the corresponding type-specific method.

Specified by:
push in interface Stack<Float>
Parameters:
o - the object that will become the new top of the stack.

pop

public Float pop()
Delegates to the corresponding type-specific method.

Specified by:
pop in interface Stack<Float>
Returns:
the top of the stack.

top

public Float top()
Delegates to the corresponding type-specific method.

Specified by:
top in interface Stack<Float>
Returns:
the top of the stack.

peek

public Float peek(int i)
Delegates to the corresponding type-specific method.

Specified by:
peek in interface Stack<Float>
Returns:
the i-th element on the stack; 0 represents the top.

toString

public String toString()
Overrides:
toString in class AbstractFloatCollection