Package org.basex.util.list
Class LongList
java.lang.Object
org.basex.util.list.ElementList
org.basex.util.list.LongList
Resizable-array implementation for native long values.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsFields inherited from class org.basex.util.list.ElementList
factor, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal LongListadd(long element) Adds an element to the array.final LongListadd(long... elements) Adds elements to the array.distinct()Removes duplicate entries.booleanlong[]finish()Returns an array with all elements and invalidates the internal array.final longget(int index) Returns the element at the specified position.final longpeek()Returns the uppermost element from the stack.final longpop()Pops the uppermost element from the stack.final voidpush(long element) Pushes an element onto the stack.sort()Sorts the data.final long[]toArray()Returns an array with all elements.toString()Methods inherited from class org.basex.util.list.ElementList
isEmpty, newCapacity, newCapacity, reset, size, size
-
Field Details
-
list
protected long[] listElement container.
-
-
Constructor Details
-
LongList
public LongList()Default constructor. -
LongList
public LongList(long capacity) Constructor with initial capacity.- Parameters:
capacity- array capacity
-
-
Method Details
-
add
Adds an element to the array.- Parameters:
element- element to be added- Returns:
- self reference
-
add
Adds elements to the array.- Parameters:
elements- elements to be added- Returns:
- self reference
-
get
public final long get(int index) Returns the element at the specified position.- Parameters:
index- index of the element to return- Returns:
- element
-
peek
public final long peek()Returns the uppermost element from the stack.- Returns:
- the uppermost element
-
pop
public final long pop()Pops the uppermost element from the stack.- Returns:
- the popped element
-
push
public final void push(long element) Pushes an element onto the stack.- Parameters:
element- element
-
toArray
public final long[] toArray()Returns an array with all elements.- Returns:
- array
-
finish
public long[] finish()Returns an array with all elements and invalidates the internal array. Warning: the function must only be called if the list is discarded afterwards.- Returns:
- array (internal representation!)
-
sort
Sorts the data.- Returns:
- self reference
-
distinct
Removes duplicate entries.- Returns:
- self reference
-
equals
-
toString
-