|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectLongList
public class LongList
A fast, array-based, expandable list of longs.
Field Summary | |
---|---|
private long[] |
data
|
private int |
size
|
Constructor Summary | |
---|---|
LongList()
Basic constructor - initializes with capacity of 10 |
|
LongList(int initialCapacity)
Constructor to specify initial capacity explicitly |
Method Summary | |
---|---|
void |
add(long value)
Add a value to the end of the list, expanding the array if necessary |
int |
binarySearch(long searchFor)
Perform a binary search for the given value. |
int[] |
calcSortMap()
Calculate a reordering of the elements of the list that would put them in sorted order. |
void |
clear()
Remove all elements from the list (but doesn't resize the array) |
void |
compact()
Resize the array so it exactly fits the current elements |
void |
ensureCapacity(int cap)
Ensure that at least the given number of elements can be stored |
void |
fill(long value)
Fill the list with a given data value |
long |
get(int index)
Get an element from the list |
long |
getLast()
Get the last element from the list |
boolean |
isEmpty()
Check if the list is empty (i.e. size() == 0) |
void |
remap(int[] map)
Apply a sort order to the elements -- see calcSortMap() |
void |
resize(int newSize)
Resize the array to the specified size. |
void |
set(int index,
long value)
Set an element in the list |
int |
size()
Retrieve the current number of elements in the list |
void |
sort()
Sort all the elements in the list in ascending order |
long[] |
toArray()
Get an array of the elements. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private long[] data
private int size
Constructor Detail |
---|
public LongList()
public LongList(int initialCapacity)
Method Detail |
---|
public final void add(long value)
public final void ensureCapacity(int cap)
public final void compact()
public final void resize(int newSize)
public final long[] toArray()
public final boolean isEmpty()
public final void clear()
public final int size()
public final long get(int index)
public final long getLast()
public final void set(int index, long value)
public final void fill(long value)
public final void sort()
public final int binarySearch(long searchFor)
sort()
if necessary.
Arrays.binarySearch(int[], int)
public final int[] calcSortMap()
remap(int[])
on each array including the original.
public final void remap(int[] map)
calcSortMap()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |