public class IntegerList
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private int[] |
_data |
private int |
_size |
private static int[] |
EMPTY_DATA |
private static int |
INITIAL_SIZE |
private static int |
MAX_ARRAY_SIZE |
| Constructor and Description |
|---|
IntegerList() |
IntegerList(java.util.Collection<java.lang.Integer> list) |
IntegerList(int capacity) |
IntegerList(IntegerList list) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int value) |
void |
addAll(java.util.Collection<java.lang.Integer> list) |
void |
addAll(int[] array) |
void |
addAll(IntegerList list) |
int |
binarySearch(int key) |
int |
binarySearch(int fromIndex,
int toIndex,
int key) |
private int |
charArraySize() |
void |
clear() |
boolean |
contains(int value) |
private void |
ensureCapacity(int capacity) |
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality.
|
int |
get(int index) |
int |
hashCode()
Returns the hash code value for this list.
|
boolean |
isEmpty() |
int |
removeAt(int index) |
void |
removeRange(int fromIndex,
int toIndex) |
int |
set(int index,
int value) |
int |
size() |
void |
sort() |
int[] |
toArray() |
char[] |
toCharArray()
Convert the list to a UTF-16 encoded char array.
|
java.lang.String |
toString()
Returns a string representation of this list.
|
void |
trimToSize() |
private static int[] EMPTY_DATA
private static final int INITIAL_SIZE
private static final int MAX_ARRAY_SIZE
private int[] _data
private int _size
public IntegerList()
public IntegerList(int capacity)
public IntegerList(IntegerList list)
public IntegerList(java.util.Collection<java.lang.Integer> list)
public final void add(int value)
public final void addAll(int[] array)
public final void addAll(IntegerList list)
public final void addAll(java.util.Collection<java.lang.Integer> list)
public final int get(int index)
public final boolean contains(int value)
public final int set(int index,
int value)
public final int removeAt(int index)
public final void removeRange(int fromIndex,
int toIndex)
public final boolean isEmpty()
public final int size()
public final void trimToSize()
public final void clear()
public final int[] toArray()
public final void sort()
public boolean equals(java.lang.Object o)
true if and only if the specified object is also an IntegerList,
both lists have the same size, and all corresponding pairs of elements in
the two lists are equal. In other words, two lists are defined to be
equal if they contain the same elements in the same order.
This implementation first checks if the specified object is this
list. If so, it returns true; if not, it checks if the
specified object is an IntegerList. If not, it returns false;
if so, it checks the size of both lists. If the lists are not the same size,
it returns false; otherwise it iterates over both lists, comparing
corresponding pairs of elements. If any comparison returns false,
this method returns false.
equals in class java.lang.Objecto - the object to be compared for equality with this listtrue if the specified object is equal to this listpublic int hashCode()
This implementation uses exactly the code that is used to define the
list hash function in the documentation for the List.hashCode()
method.
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic final int binarySearch(int key)
public final int binarySearch(int fromIndex,
int toIndex,
int key)
private void ensureCapacity(int capacity)
public final char[] toCharArray()
private int charArraySize()