|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttl.lin.data.array.ArrayListOfDoubles
public class ArrayListOfDoubles
Object representing a list of doubles, backed by an resizable-array.
| Field Summary | |
|---|---|
protected double[] |
array
|
protected int |
size
|
| Constructor Summary | |
|---|---|
ArrayListOfDoubles()
Constructs an empty list with an initial capacity of ten. |
|
ArrayListOfDoubles(double[] a)
Constructs a list from an array. |
|
ArrayListOfDoubles(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
|
ArrayListOfDoubles(int first,
int last)
Constructs a list populated with longs in range [first, last). |
|
| Method Summary | |
|---|---|
ArrayListOfDoubles |
add(double e)
Appends the specified element to the end of this list. |
ArrayListOfDoubles |
add(int index,
double element)
Inserts the specified element at the specified position in this list. |
void |
addUnique(int[] arr)
Add all ints in the specified array into this list, ignoring duplicates. |
void |
clear()
Removes all of the elements from this list. |
ArrayListOfDoubles |
clone()
Returns a clone of this object. |
boolean |
contains(double n)
Returns true if this list contains the specified element. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this object, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
boolean |
equals(Object obj)
Elementwise comparison. |
double |
get(int index)
Returns the element at the specified position in this list. |
double[] |
getArray()
Returns the array backing this object. |
int |
indexOf(double n)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. |
ArrayListOfDoubles |
intersection(ArrayListOfDoubles other)
Computes the intersection of two sorted lists of unique elements. |
boolean |
isEmpty()
Returns true if this list contains no elements. |
Iterator<Double> |
iterator()
Returns an iterator for this list. |
int |
lastIndexOf(double n)
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. |
ArrayListOfDoubles |
merge(ArrayListOfDoubles sortedLst)
Merges two sorted (ascending order) lists into one sorted union. |
double |
remove(int index)
Removes the element at the specified position in this list. |
double |
set(int index,
double element)
Replaces the element at the specified position in this list with the specified element. |
void |
setSize(int sz)
Specifies the length of this list. |
void |
shiftLastNToTop(int n)
|
int |
size()
Returns the number of elements in this list. |
void |
sort()
Sorts this list. |
ArrayListOfDoubles |
subList(int start,
int end)
Extracts a sub-list. |
String |
toString()
|
String |
toString(int n)
Returns a string representation of the object, explicitly printing out the first n elements of this list. |
void |
trimToSize()
Trims the capacity of this object to be the list's current size. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected transient double[] array
protected int size
| Constructor Detail |
|---|
public ArrayListOfDoubles(int initialCapacity)
initialCapacity - the initial capacity of the list
IllegalArgumentException - if the specified initial capacity is negativepublic ArrayListOfDoubles()
public ArrayListOfDoubles(double[] a)
a - source array
public ArrayListOfDoubles(int first,
int last)
first - the smallest element in the range (inclusive)last - the largest element in the range (exclusive)| Method Detail |
|---|
public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacitypublic int size()
public void setSize(int sz)
public boolean isEmpty()
public boolean contains(double n)
n - element whose presence in this list is to be tested
public int indexOf(double n)
public int lastIndexOf(double n)
public ArrayListOfDoubles clone()
clone in class Objectpublic double get(int index)
index - index of the element to return
public double set(int index,
double element)
index - index of the element to replaceelement - element to be stored at the specified position
public ArrayListOfDoubles add(double e)
public ArrayListOfDoubles add(int index,
double element)
index - index at which the specified element is to be insertedelement - element to be insertedpublic double remove(int index)
index - the index of the element to be removed
public void clear()
public double[] getArray()
public Iterator<Double> iterator()
Iterable interface; this method is not efficient because of
autoboxing.
iterator in interface Iterable<Double>public String toString(int n)
public String toString()
toString in class Objectpublic void sort()
public ArrayListOfDoubles intersection(ArrayListOfDoubles other)
other - other list to be intersected with this list
public ArrayListOfDoubles merge(ArrayListOfDoubles sortedLst)
sortedLst - list to be merged into this
public ArrayListOfDoubles subList(int start,
int end)
start - first index to be included in sub-listend - last index to be included in sub-list
start to endpublic void addUnique(int[] arr)
arr - array of ints to add to this objectpublic void shiftLastNToTop(int n)
public boolean equals(Object obj)
equals in class Objectobj - other object this is compared against
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||