Package org.eclipse.mat.collect
Class ArrayLong
java.lang.Object
org.eclipse.mat.collect.ArrayLong
Utility class to hold a list of longs
Similar to a list, but efficient for longs
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long element) append one more entryvoid
addAll
(long[] elements) Append a group of entriesvoid
Append all of another ArrayLong to the end of this one.void
clear()
clear all the entrieslong
get the first entry to be written.long
get
(int index) Retrieve one entryboolean
isEmpty()
is the list emptyiterator()
get an iterator to go through the listlong
get the last entry to be written.long
set
(int index, long element) modify one particular entryint
size()
get the number of used entriesvoid
sort()
arrange the entries in ascending orderlong[]
toArray()
convert to an array
-
Constructor Details
-
ArrayLong
public ArrayLong()Create a list of default size -
ArrayLong
public ArrayLong(int initialCapacity) Create an empty list of given capacity for more entries.- Parameters:
initialCapacity
- in number of entries
-
ArrayLong
public ArrayLong(long[] initialValues) Create a list based on a supplied array- Parameters:
initialValues
- a copy is taken of this array
-
ArrayLong
Create a list based on an existing ArrayInt, of size of the template- Parameters:
template
- a copy is taken of these values
-
-
Method Details
-
add
public void add(long element) append one more entry- Parameters:
element
- the int to add to the end
-
addAll
public void addAll(long[] elements) Append a group of entries- Parameters:
elements
- an array of long, to be added to end of this ArrayLong.
-
addAll
Append all of another ArrayLong to the end of this one.- Parameters:
template
- the other ArrayLong
-
set
public long set(int index, long element) modify one particular entry- Parameters:
index
- into this ArrayLongelement
- the new value to be put here- Returns:
- the previous value
-
get
public long get(int index) Retrieve one entry- Parameters:
index
- into the ArrayLong- Returns:
- the entry
-
size
public int size()get the number of used entries- Returns:
- the number of entries
-
toArray
public long[] toArray()convert to an array- Returns:
- a copy of the entries
-
isEmpty
public boolean isEmpty()is the list empty- Returns:
- true if empty
-
iterator
get an iterator to go through the list- Returns:
- the iterator
-
clear
public void clear()clear all the entries -
lastElement
public long lastElement()get the last entry to be written. Must be at least one entry.- Returns:
- the last element
-
firstElement
public long firstElement()get the first entry to be written. Must be at least one entry.- Returns:
- the first element
-
sort
public void sort()arrange the entries in ascending order
-