Package gnu.trove.impl.unmodifiable
Class TUnmodifiableDoubleList
- java.lang.Object
-
- gnu.trove.impl.unmodifiable.TUnmodifiableDoubleCollection
-
- gnu.trove.impl.unmodifiable.TUnmodifiableDoubleList
-
- All Implemented Interfaces:
TDoubleList,TDoubleCollection,java.io.Serializable
- Direct Known Subclasses:
TUnmodifiableRandomAccessDoubleList
public class TUnmodifiableDoubleList extends TUnmodifiableDoubleCollection implements TDoubleList
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TUnmodifiableDoubleList(TDoubleList list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double[] vals)Adds the values in the array vals to the end of the list, in order.voidadd(double[] vals, int offset, int length)Adds a subset of the values in the array vals to the end of the list, in order.intbinarySearch(double value)Performs a binary search for value in the entire list.intbinarySearch(double value, int fromIndex, int toIndex)Performs a binary search for value in the specified range.booleanequals(java.lang.Object o)Compares the specified object with this collection for equality.voidfill(double val)Fills every slot in the list with the specified value.voidfill(int fromIndex, int toIndex, double val)Fills a range in the list with the specified value.booleanforEachDescending(TDoubleProcedure procedure)Applies the procedure to each value in the list in descending (back to front) order.doubleget(int index)Returns the value at the specified offset.TDoubleListgrep(TDoubleProcedure condition)Searches the list for values satisfying condition in the manner of the *nix grep utility.inthashCode()Returns the hash code value for this collection.intindexOf(double o)Searches the list front to back for the index of value.intindexOf(int offset, double value)Searches the list front to back for the index of value, starting at offset.voidinsert(int offset, double value)Inserts value into the list at offset.voidinsert(int offset, double[] values)Inserts the array of values into the list at offset.voidinsert(int offset, double[] values, int valOffset, int len)Inserts a slice of the array of values into the list at offset.TDoubleListinverseGrep(TDoubleProcedure condition)Searches the list for values which do not satisfy condition.intlastIndexOf(double o)Searches the list back to front for the last index of value.intlastIndexOf(int offset, double value)Searches the list back to front for the last index of value, starting at offset.doublemax()Finds the maximum value in the list.doublemin()Finds the minimum value in the list.voidremove(int offset, int length)Removes length values from the list, starting at offsetdoubleremoveAt(int offset)Removes value at a given offset from the list.doublereplace(int offset, double val)Sets the value at the specified offset and returns the previously stored value.voidreverse()Reverse the order of the elements in the list.voidreverse(int from, int to)Reverse the order of the elements in the range of the list.doubleset(int offset, double val)Sets the value at the specified offset.voidset(int offset, double[] values)Replace the values in the list starting at offset with the contents of the values array.voidset(int offset, double[] values, int valOffset, int length)Replace the values in the list starting at offset with length values from the values array, starting at valOffset.voidshuffle(java.util.Random rand)Shuffle the elements of the list using the specified random number generator.voidsort()Sort the values in the list (ascending) using the Sun quicksort implementation.voidsort(int fromIndex, int toIndex)Sort a slice of the list (ascending) using the Sun quicksort implementation.TDoubleListsubList(int fromIndex, int toIndex)Returns a sublist of this list.doublesum()Calculates the sum of all the values in the list.double[]toArray(double[] dest, int offset, int len)Copies a slice of the list into a native array.double[]toArray(double[] dest, int source_pos, int dest_pos, int len)Copies a slice of the list into a native array.double[]toArray(int offset, int len)Copies a slice of the list into a native array.voidtransformValues(TDoubleFunction function)Transform each value in the list using the specified function.-
Methods inherited from class gnu.trove.impl.unmodifiable.TUnmodifiableDoubleCollection
add, addAll, addAll, addAll, clear, contains, containsAll, containsAll, containsAll, forEach, getNoEntryValue, isEmpty, iterator, remove, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll, size, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gnu.trove.TDoubleCollection
addAll, addAll, addAll, containsAll, containsAll, containsAll, iterator, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll
-
-
-
-
Constructor Detail
-
TUnmodifiableDoubleList
public TUnmodifiableDoubleList(TDoubleList list)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:TDoubleCollectionCompares the specified object with this collection for equality. Returns true if the specified object is also a collection, the two collection have the same size, and every member of the specified collection is contained in this collection (or equivalently, every member of this collection is contained in the specified collection). This definition ensures that the equals method works properly across different implementations of the collection interface.- Specified by:
equalsin interfaceTDoubleCollection- Overrides:
equalsin classjava.lang.Object- Parameters:
o- object to be compared for equality with this collection- Returns:
- true if the specified object is equal to this collection
-
hashCode
public int hashCode()
Description copied from interface:TDoubleCollectionReturns the hash code value for this collection. The hash code of a collection is defined to be the sum of the hash codes of the elements in the collection. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two collection s1 and s2, as required by the general contract ofObject.hashCode().- Specified by:
hashCodein interfaceTDoubleCollection- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code value for this collection
- See Also:
Object.equals(Object),Collection.equals(Object)
-
get
public double get(int index)
Description copied from interface:TDoubleListReturns the value at the specified offset.- Specified by:
getin interfaceTDoubleList- Parameters:
index- anintvalue- Returns:
- an
doublevalue
-
indexOf
public int indexOf(double o)
Description copied from interface:TDoubleListSearches the list front to back for the index of value.- Specified by:
indexOfin interfaceTDoubleList- Parameters:
o- andoublevalue- Returns:
- the first offset of the value, or -1 if it is not in the list.
- See Also:
for faster searches on sorted lists
-
lastIndexOf
public int lastIndexOf(double o)
Description copied from interface:TDoubleListSearches the list back to front for the last index of value.- Specified by:
lastIndexOfin interfaceTDoubleList- Parameters:
o- andoublevalue- Returns:
- the last offset of the value, or -1 if it is not in the list.
- See Also:
for faster searches on sorted lists
-
toArray
public double[] toArray(int offset, int len)Description copied from interface:TDoubleListCopies a slice of the list into a native array.- Specified by:
toArrayin interfaceTDoubleList- Parameters:
offset- the offset at which to start copyinglen- the number of values to copy.- Returns:
- an
double[]value
-
toArray
public double[] toArray(double[] dest, int offset, int len)Description copied from interface:TDoubleListCopies a slice of the list into a native array.- Specified by:
toArrayin interfaceTDoubleList- Parameters:
dest- the array to copy into.offset- the offset where the first value should be copiedlen- the number of values to copy.- Returns:
- the array passed in.
-
toArray
public double[] toArray(double[] dest, int source_pos, int dest_pos, int len)Description copied from interface:TDoubleListCopies a slice of the list into a native array.- Specified by:
toArrayin interfaceTDoubleList- Parameters:
dest- the array to copy into.source_pos- the offset of the first value to copydest_pos- the offset where the first value should be copiedlen- the number of values to copy.- Returns:
- the array passed in.
-
forEachDescending
public boolean forEachDescending(TDoubleProcedure procedure)
Description copied from interface:TDoubleListApplies the procedure to each value in the list in descending (back to front) order.- Specified by:
forEachDescendingin interfaceTDoubleList- Parameters:
procedure- aTDoubleProcedurevalue- Returns:
- true if the procedure did not terminate prematurely.
-
binarySearch
public int binarySearch(double value)
Description copied from interface:TDoubleListPerforms a binary search for value in the entire list. Note that you must @{link #sort sort} the list before doing a search.- Specified by:
binarySearchin interfaceTDoubleList- Parameters:
value- the value to search for- Returns:
- the absolute offset in the list of the value, or its negative insertion point into the sorted list.
-
binarySearch
public int binarySearch(double value, int fromIndex, int toIndex)Description copied from interface:TDoubleListPerforms a binary search for value in the specified range. Note that you must @{link #sort sort} the list or the range before doing a search.- Specified by:
binarySearchin interfaceTDoubleList- Parameters:
value- the value to search forfromIndex- the lower boundary of the range (inclusive)toIndex- the upper boundary of the range (exclusive)- Returns:
- the absolute offset in the list of the value, or its negative insertion point into the sorted list.
-
indexOf
public int indexOf(int offset, double value)Description copied from interface:TDoubleListSearches the list front to back for the index of value, starting at offset.- Specified by:
indexOfin interfaceTDoubleList- Parameters:
offset- the offset at which to start the linear search (inclusive)value- andoublevalue- Returns:
- the first offset of the value, or -1 if it is not in the list.
- See Also:
for faster searches on sorted lists
-
lastIndexOf
public int lastIndexOf(int offset, double value)Description copied from interface:TDoubleListSearches the list back to front for the last index of value, starting at offset.- Specified by:
lastIndexOfin interfaceTDoubleList- Parameters:
offset- the offset at which to start the linear search (exclusive)value- andoublevalue- Returns:
- the last offset of the value, or -1 if it is not in the list.
- See Also:
for faster searches on sorted lists
-
grep
public TDoubleList grep(TDoubleProcedure condition)
Description copied from interface:TDoubleListSearches the list for values satisfying condition in the manner of the *nix grep utility.- Specified by:
grepin interfaceTDoubleList- Parameters:
condition- a condition to apply to each element in the list- Returns:
- a list of values which match the condition.
-
inverseGrep
public TDoubleList inverseGrep(TDoubleProcedure condition)
Description copied from interface:TDoubleListSearches the list for values which do not satisfy condition. This is akin to *nixgrep -v.- Specified by:
inverseGrepin interfaceTDoubleList- Parameters:
condition- a condition to apply to each element in the list- Returns:
- a list of values which do not match the condition.
-
max
public double max()
Description copied from interface:TDoubleListFinds the maximum value in the list.- Specified by:
maxin interfaceTDoubleList- Returns:
- the largest value in the list.
-
min
public double min()
Description copied from interface:TDoubleListFinds the minimum value in the list.- Specified by:
minin interfaceTDoubleList- Returns:
- the smallest value in the list.
-
sum
public double sum()
Description copied from interface:TDoubleListCalculates the sum of all the values in the list.- Specified by:
sumin interfaceTDoubleList- Returns:
- the sum of the values in the list (zero if the list is empty).
-
subList
public TDoubleList subList(int fromIndex, int toIndex)
Description copied from interface:TDoubleListReturns a sublist of this list.- Specified by:
subListin interfaceTDoubleList- Parameters:
fromIndex- low endpoint (inclusive) of the subList.toIndex- high endpoint (exclusive) of the subList.- Returns:
- sublist of this list from begin, inclusive to end, exclusive.
-
add
public void add(double[] vals)
Description copied from interface:TDoubleListAdds the values in the array vals to the end of the list, in order.- Specified by:
addin interfaceTDoubleList- Parameters:
vals- andouble[]value
-
add
public void add(double[] vals, int offset, int length)Description copied from interface:TDoubleListAdds a subset of the values in the array vals to the end of the list, in order.- Specified by:
addin interfaceTDoubleList- Parameters:
vals- andouble[]valueoffset- the offset at which to start copyinglength- the number of values to copy.
-
removeAt
public double removeAt(int offset)
Description copied from interface:TDoubleListRemoves value at a given offset from the list.- Specified by:
removeAtin interfaceTDoubleList- Parameters:
offset- anintvalue that represents the offset to the element to be removed- Returns:
- an double that is the value removed.
-
remove
public void remove(int offset, int length)Description copied from interface:TDoubleListRemoves length values from the list, starting at offset- Specified by:
removein interfaceTDoubleList- Parameters:
offset- anintvaluelength- anintvalue
-
insert
public void insert(int offset, double value)Description copied from interface:TDoubleListInserts value into the list at offset. All values including and to the right of offset are shifted to the right.- Specified by:
insertin interfaceTDoubleList- Parameters:
offset- anintvaluevalue- andoublevalue
-
insert
public void insert(int offset, double[] values)Description copied from interface:TDoubleListInserts the array of values into the list at offset. All values including and to the right of offset are shifted to the right.- Specified by:
insertin interfaceTDoubleList- Parameters:
offset- anintvaluevalues- andouble[]value
-
insert
public void insert(int offset, double[] values, int valOffset, int len)Description copied from interface:TDoubleListInserts a slice of the array of values into the list at offset. All values including and to the right of offset are shifted to the right.- Specified by:
insertin interfaceTDoubleList- Parameters:
offset- anintvaluevalues- andouble[]valuevalOffset- the offset in the values array at which to start copying.len- the number of values to copy from the values array
-
set
public double set(int offset, double val)Description copied from interface:TDoubleListSets the value at the specified offset.- Specified by:
setin interfaceTDoubleList- Parameters:
offset- anintvalueval- andoublevalue- Returns:
- The value previously at the given index.
-
set
public void set(int offset, double[] values)Description copied from interface:TDoubleListReplace the values in the list starting at offset with the contents of the values array.- Specified by:
setin interfaceTDoubleList- Parameters:
offset- the first offset to replacevalues- the source of the new values
-
set
public void set(int offset, double[] values, int valOffset, int length)Description copied from interface:TDoubleListReplace the values in the list starting at offset with length values from the values array, starting at valOffset.- Specified by:
setin interfaceTDoubleList- Parameters:
offset- the first offset to replacevalues- the source of the new valuesvalOffset- the first value to copy from the values arraylength- the number of values to copy
-
replace
public double replace(int offset, double val)Description copied from interface:TDoubleListSets the value at the specified offset and returns the previously stored value.- Specified by:
replacein interfaceTDoubleList- Parameters:
offset- anintvalueval- andoublevalue- Returns:
- the value previously stored at offset.
-
transformValues
public void transformValues(TDoubleFunction function)
Description copied from interface:TDoubleListTransform each value in the list using the specified function.- Specified by:
transformValuesin interfaceTDoubleList- Parameters:
function- aTDoubleFunctionvalue
-
reverse
public void reverse()
Description copied from interface:TDoubleListReverse the order of the elements in the list.- Specified by:
reversein interfaceTDoubleList
-
reverse
public void reverse(int from, int to)Description copied from interface:TDoubleListReverse the order of the elements in the range of the list.- Specified by:
reversein interfaceTDoubleList- Parameters:
from- the inclusive index at which to start reversingto- the exclusive index at which to stop reversing
-
shuffle
public void shuffle(java.util.Random rand)
Description copied from interface:TDoubleListShuffle the elements of the list using the specified random number generator.- Specified by:
shufflein interfaceTDoubleList- Parameters:
rand- aRandomvalue
-
sort
public void sort()
Description copied from interface:TDoubleListSort the values in the list (ascending) using the Sun quicksort implementation.- Specified by:
sortin interfaceTDoubleList- See Also:
Arrays.sort(int[])
-
sort
public void sort(int fromIndex, int toIndex)Description copied from interface:TDoubleListSort a slice of the list (ascending) using the Sun quicksort implementation.- Specified by:
sortin interfaceTDoubleList- Parameters:
fromIndex- the index at which to start sorting (inclusive)toIndex- the index at which to stop sorting (exclusive)- See Also:
Arrays.sort(int[])
-
fill
public void fill(double val)
Description copied from interface:TDoubleListFills every slot in the list with the specified value.- Specified by:
fillin interfaceTDoubleList- Parameters:
val- the value to use when filling
-
fill
public void fill(int fromIndex, int toIndex, double val)Description copied from interface:TDoubleListFills a range in the list with the specified value.- Specified by:
fillin interfaceTDoubleList- Parameters:
fromIndex- the offset at which to start filling (inclusive)toIndex- the offset at which to stop filling (exclusive)val- the value to use when filling
-
-