public class IntArray extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CAPACITY |
| Constructor and Description |
|---|
IntArray()
Creates a sorted int array with a default initial capacity
|
IntArray(int capacity)
Creates an IntArray with a given initial capacity
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int x)
add value to the array
|
void |
add(int pos,
int x) |
int[] |
array()
get the backing array
|
boolean |
equals(Object obj) |
int |
get(int pos)
get element at position
|
int |
hashCode() |
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.
|
boolean |
isEmpty() |
void |
set(int pos,
int x) |
int |
size() |
int[] |
toArray() |
String |
toString() |
static IntArray |
wrap(int... array)
Creates the IntArray with the backing array
|
public IntArray()
public IntArray(int capacity)
capacity - public static IntArray wrap(int... array)
array - public void add(int x)
x - - value to be addedpublic void add(int pos,
int x)
public int get(int pos)
pos - public boolean isEmpty()
public int[] toArray()
public int size()
public void set(int pos,
int x)
public int indexOf(int x)
x - element which is searched forpublic int[] array()
Copyright © 2018 Space Applications Services. All rights reserved.