Package org.yamcs.utils
Class IntArray
- java.lang.Object
-
- org.yamcs.utils.IntArray
-
public class IntArray extends Object
int array
-
-
Field Summary
Fields Modifier and Type Field Description intcountstatic intDEFAULT_CAPACITY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int x)add value to the arrayvoidadd(int pos, int x)int[]array()get the backing arrayintbinarySearch(int x)Assuming that the array is sorted, performs a binary search and returns the position of the found element.booleanequals(Object obj)intget(int pos)get element at positioninthashCode()intindexOf(int x)Returns the index of the first occurrence of the specified element in the array, or -1 if the array does not contain the element.booleanisEmpty()intremove(int pos)Remove element at position shifting all subsequent elements to the leftvoidset(int pos, int x)intsize()voidsort(List<?> list)Sort the array concurrently swapping the elements in the list such that the correspondence is kept.IntStreamstream()int[]toArray()StringtoString()static IntArraywrap(int... array)Creates the IntArray with the backing array
-
-
-
Field Detail
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
-
count
public int count
-
-
Method Detail
-
wrap
public static IntArray wrap(int... array)
Creates the IntArray with the backing array- Parameters:
array-- Returns:
- a new object containing all the values from the passed array
-
add
public void add(int x)
add value to the array- Parameters:
x- - value to be added
-
add
public void add(int pos, int x)
-
get
public int get(int pos)
get element at position- Parameters:
pos-- Returns:
- the element at the specified position
-
remove
public int remove(int pos)
Remove element at position shifting all subsequent elements to the left- Parameters:
pos-- Returns:
- the element removed
-
stream
public IntStream stream()
-
isEmpty
public boolean isEmpty()
-
toArray
public int[] toArray()
-
size
public int size()
-
set
public void set(int pos, int x)
-
indexOf
public int indexOf(int x)
Returns the index of the first occurrence of the specified element in the array, or -1 if the array does not contain the element.- Parameters:
x- element which is searched for- Returns:
- the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
-
array
public int[] array()
get the backing array- Returns:
- the backing array
-
binarySearch
public int binarySearch(int x)
Assuming that the array is sorted, performs a binary search and returns the position of the found element. SeeArrays.binarySearch(int[], int)for details. If the array is not sorted, the behaviour is undefined.- Parameters:
x- - the value to be searched for- Returns:
-
sort
public void sort(List<?> list)
Sort the array concurrently swapping the elements in the list such that the correspondence is kept. The list has to contain the same number of elements as the array- Parameters:
list-
-
-