it.unimi.dsi.fastutil.doubles
Class AbstractDoubleList

java.lang.Object
  extended by java.util.AbstractCollection<Double>
      extended by it.unimi.dsi.fastutil.doubles.AbstractDoubleCollection
          extended by it.unimi.dsi.fastutil.doubles.AbstractDoubleList
All Implemented Interfaces:
DoubleCollection, DoubleIterable, DoubleList, DoubleStack, Stack<Double>, Comparable<List<? extends Double>>, Iterable<Double>, Collection<Double>, List<Double>
Direct Known Subclasses:
AbstractDoubleList.DoubleSubList, DoubleArrayList, DoubleLists.Singleton

public abstract class AbstractDoubleList
extends AbstractDoubleCollection
implements DoubleList, DoubleStack

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 AbstractDoubleList.DoubleSubList
           
 
Method Summary
 boolean add(double k)
           
 void add(int index, double k)
           
 void add(int index, Double ok)
          Delegates to the corresponding type-specific method.
 boolean addAll(Collection<? extends Double> c)
          Delegates to a more generic method.
 boolean addAll(DoubleCollection c)
          Adds all elements of the given type-specific collection to this collection.
 boolean addAll(DoubleList l)
           
 boolean addAll(int index, Collection<? extends Double> c)
           
 boolean addAll(int index, DoubleCollection c)
          Delegates to a more generic method.
 boolean addAll(int index, DoubleList l)
          Delegates to a more generic method.
 void addElements(int index, double[] a)
          Add (hopefully quickly) elements to this type-specific list.
 void addElements(int index, double[] a, int offset, int length)
          Adds elements to this type-specific list one-by-one.
 int compareTo(List<? extends Double> l)
          Compares this list to another object.
 boolean contains(double k)
           
 DoubleListIterator doubleListIterator()
          Deprecated. 
 DoubleListIterator doubleListIterator(int index)
          Deprecated. 
 DoubleList doubleSubList(int from, int to)
          Deprecated. 
 boolean equals(Object o)
           
 Double get(int index)
          Delegates to the corresponding type-specific method.
 void getElements(int from, double[] 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(double k)
           
 int indexOf(Object ok)
          Delegates to the corresponding type-specific method.
 DoubleListIterator iterator()
          Returns a type-specific iterator on the elements of this collection.
 int lastIndexOf(double k)
           
 int lastIndexOf(Object ok)
          Delegates to the corresponding type-specific method.
 DoubleListIterator listIterator()
          Returns a type-specific list iterator on the list.
 DoubleListIterator listIterator(int index)
          Returns a type-specific list iterator on the list starting at a given index.
 Double peek(int i)
          Delegates to the corresponding type-specific method.
 double peekDouble(int i)
           
 Double pop()
          Delegates to the corresponding type-specific method.
 double popDouble()
           
 void push(double o)
           
 void push(Double o)
          Delegates to the corresponding type-specific method.
 boolean rem(double 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.
 Double remove(int index)
          Delegates to the corresponding type-specific method.
 boolean remove(Object o)
          Delegates to rem().
 double removeDouble(int i)
           
 void removeElements(int from, int to)
          Removes elements of this type-specific list one-by-one.
 double set(int index, double k)
           
 Double set(int index, Double ok)
          Delegates to the corresponding type-specific method.
 void size(int size)
          Sets the size of this list.
 DoubleList 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.
 Double top()
          Delegates to the corresponding type-specific method.
 double topDouble()
           
 String toString()
           
 
Methods inherited from class it.unimi.dsi.fastutil.doubles.AbstractDoubleCollection
add, contains, containsAll, containsAll, doubleIterator, isEmpty, rem, removeAll, removeAll, retainAll, retainAll, toArray, toArray, toArray, toDoubleArray, toDoubleArray
 
Methods inherited from class java.util.AbstractCollection
clear, size
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.doubles.DoubleList
getDouble
 
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.doubles.DoubleCollection
containsAll, doubleIterator, removeAll, retainAll, toArray, toArray, toDoubleArray, toDoubleArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Method Detail

add

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

add

public boolean add(double k)
Specified by:
add in interface DoubleCollection
Specified by:
add in interface DoubleList
Overrides:
add in class AbstractDoubleCollection
See Also:
Collection.add(Object)

removeDouble

public double removeDouble(int i)
Specified by:
removeDouble in interface DoubleList
See Also:
List.remove(int)

set

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

addAll

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

addAll

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

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

doubleListIterator

@Deprecated
public DoubleListIterator doubleListIterator()
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
doubleListIterator in interface DoubleList
See Also:
DoubleList.listIterator()

doubleListIterator

@Deprecated
public DoubleListIterator doubleListIterator(int index)
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
doubleListIterator in interface DoubleList
See Also:
DoubleList.listIterator(int)

iterator

public DoubleListIterator iterator()
Description copied from interface: DoubleCollection
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 DoubleCollection
Specified by:
iterator in interface DoubleIterable
Specified by:
iterator in interface DoubleList
Specified by:
iterator in interface Iterable<Double>
Specified by:
iterator in interface Collection<Double>
Specified by:
iterator in interface List<Double>
Specified by:
iterator in class AbstractDoubleCollection
Returns:
a type-specific iterator on the elements of this collection.

listIterator

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

Specified by:
listIterator in interface DoubleList
Specified by:
listIterator in interface List<Double>
See Also:
List.listIterator()

listIterator

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

Specified by:
listIterator in interface DoubleList
Specified by:
listIterator in interface List<Double>
See Also:
List.listIterator(int)

contains

public boolean contains(double k)
Specified by:
contains in interface DoubleCollection
Overrides:
contains in class AbstractDoubleCollection
See Also:
Collection.contains(Object)

indexOf

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

lastIndexOf

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

size

public void size(int size)
Description copied from interface: DoubleList
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 DoubleList
Parameters:
size - the new size.

subList

public DoubleList subList(int from,
                          int to)
Description copied from interface: DoubleList
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 DoubleList
Specified by:
subList in interface List<Double>
See Also:
List.subList(int,int)

doubleSubList

@Deprecated
public DoubleList doubleSubList(int from,
                                           int to)
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
doubleSubList in interface DoubleList
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 DoubleList
Parameters:
from - the start index (inclusive).
to - the end index (exclusive).

addElements

public void addElements(int index,
                        double[] 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 DoubleList
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,
                        double[] a)
Description copied from interface: DoubleList
Add (hopefully quickly) elements to this type-specific list.

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

getElements

public void getElements(int from,
                        double[] 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 DoubleList
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<Double>
Specified by:
equals in interface List<Double>
Overrides:
equals in class Object

compareTo

public int compareTo(List<? extends Double> 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 Double>>
Parameters:
l - a 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<Double>
Specified by:
hashCode in interface List<Double>
Overrides:
hashCode in class Object
Returns:
the hash code for this list.

push

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

popDouble

public double popDouble()
Specified by:
popDouble in interface DoubleStack
See Also:
Stack.pop()

topDouble

public double topDouble()
Specified by:
topDouble in interface DoubleStack
See Also:
Stack.top()

peekDouble

public double peekDouble(int i)
Specified by:
peekDouble in interface DoubleStack
See Also:
Stack.peek(int)

rem

public boolean rem(double k)
Description copied from interface: DoubleCollection
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 DoubleCollection
Overrides:
rem in class AbstractDoubleCollection
See Also:
Collection.remove(Object)

remove

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

Specified by:
remove in interface Collection<Double>
Specified by:
remove in interface List<Double>
Overrides:
remove in class AbstractDoubleCollection

addAll

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

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

addAll

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

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

addAll

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

Specified by:
addAll in interface DoubleCollection
Overrides:
addAll in class AbstractDoubleCollection
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(DoubleList l)
Specified by:
addAll in interface DoubleList
See Also:
List.add(int,Object)

add

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

Specified by:
add in interface List<Double>

set

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

Specified by:
set in interface List<Double>

get

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

Specified by:
get in interface List<Double>

indexOf

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

Specified by:
indexOf in interface List<Double>

lastIndexOf

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

Specified by:
lastIndexOf in interface List<Double>

remove

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

Specified by:
remove in interface List<Double>

push

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

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

pop

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

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

top

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

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

peek

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

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

toString

public String toString()
Overrides:
toString in class AbstractDoubleCollection