public class SortedIntArray extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CAPACITY |
| Constructor and Description |
|---|
SortedIntArray()
Creates a sorted int array with a default initial capacity
|
SortedIntArray(int... array)
Creates the SortedIntArray by copying all values from the input array and sorting them
|
SortedIntArray(int capacity)
Creates a sorted int array with a given initial capacity
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int x)
Performs a binary search and returns true if this array contains the value.
|
static SortedIntArray |
decodeFromVarIntArray(byte[] buf) |
byte[] |
encodeToVarIntArray() |
boolean |
equals(Object obj) |
int |
get(int pos)
get element at position
|
int[] |
getArray() |
PrimitiveIterator.OfInt |
getAscendingIterator(int startFrom)
Constructs an ascending iterator starting from a specified value (inclusive)
|
PrimitiveIterator.OfInt |
getDescendingIterator(int startFrom)
Constructs an descending iterator starting from a specified value (exclusive)
|
int |
hashCode() |
int |
insert(int x)
Inserts value to the array and return the position on which has been inserted
|
boolean |
isEmpty() |
int |
search(int x)
performs a binary search in the array.
|
int |
size() |
String |
toString() |
public SortedIntArray()
public SortedIntArray(int capacity)
capacity - public SortedIntArray(int... array)
array - public int insert(int x)
x - - value to be insertedpublic int search(int x)
x - Arrays.binarySearch(int[], int)public int get(int pos)
pos - public boolean isEmpty()
public int[] getArray()
public int size()
public PrimitiveIterator.OfInt getAscendingIterator(int startFrom)
startFrom - public PrimitiveIterator.OfInt getDescendingIterator(int startFrom)
startFrom - public boolean contains(int x)
x - - value to checkpublic byte[] encodeToVarIntArray()
public static SortedIntArray decodeFromVarIntArray(byte[] buf)
Copyright © 2017 Space Applications Services. All rights reserved.