Package org.eclipse.mat.collect
Class ArrayInt
java.lang.Object
org.eclipse.mat.collect.ArrayInt
Utility class to hold a list of ints
Similar to a list, but efficient for ints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int element) append one more entryvoidaddAll(int[] elements) Append a group of entriesvoidAppend all of another ArrayInt to the end of this one.voidclear()clear all the entriesintget the first entry to be written.intget(int index) Retrieve one entrybooleanisEmpty()is the list emptyiterator()get an iterator to go through the listintget the last entry to be written.intset(int index, int element) modify one particular entryintsize()get the number of used entriesvoidsort()arrange the entries in ascending orderint[]toArray()convert to an array
-
Constructor Details
-
ArrayInt
public ArrayInt()Create a list of default size -
ArrayInt
public ArrayInt(int initialCapacity) Create an empty list of given capacity for more entries.- Parameters:
initialCapacity- in number of entries
-
ArrayInt
public ArrayInt(int[] initialValues) Create a list based on a supplied array- Parameters:
initialValues- a copy is taken of this array
-
ArrayInt
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(int element) append one more entry- Parameters:
element- the int to add to the end
-
addAll
public void addAll(int[] elements) Append a group of entries- Parameters:
elements- an array of int, to be added to end of this ArrayInt.
-
addAll
Append all of another ArrayInt to the end of this one.- Parameters:
template- the other ArrayInt
-
set
public int set(int index, int element) modify one particular entry- Parameters:
index- into this ArrayIntelement- the new value to be put here- Returns:
- the previous value
-
get
public int get(int index) Retrieve one entry- Parameters:
index- into the ArrayInt- Returns:
- the entry
-
size
public int size()get the number of used entries- Returns:
- the number of entries
-
toArray
public int[] 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 int lastElement()get the last entry to be written. Must be at least one entry.- Returns:
- the last element
- Since:
- 1.0
-
firstElement
public int firstElement()get the first entry to be written. Must be at least one entry.- Returns:
- the first element
- Since:
- 1.0
-
sort
public void sort()arrange the entries in ascending order
-