ints.
| Modifier and Type | Field and Description |
|---|---|
| public static final IntList | EMPTY
|
| private int | size
|
| private boolean | sorted
whether the values are currently sorted |
| private int[] | values
|
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public int | Returns: index of value or(-(insertion point) - 1) if the
value is not presentvalue to find value)Performs a binary search on a sorted list, returning the index of
the given value if it is present or
|
| public boolean | Returns: whether the list contains the given valuevalue to look for value)Returns whether or not the given value appears in the list. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public int | Returns: the indicated element's value>= 0, < size(); which elementGets the indicated value. |
| private void | |
| public int | |
| public int | Returns: index of value or -1value to find value)Returns the index of the given value, or -1 if the value does not appear in the list. |
| public void | insert(int
>= 0, <=size(); index of where to insertvalue to insert value)Inserts element into specified index, moving elements at and above that index up one. |
| public static IntList | makeImmutable(int
the sole value in the list value)Constructs a new immutable instance with the given element. |
| public static IntList | makeImmutable(int
the first value in the list value0, int the second value in the list value1)Constructs a new immutable instance with the given elements. |
| public IntList | Returns: non-null; an appropriately-constructed instanceMakes and returns a mutable copy of the list. |
| public int | Returns: value from what was the last elementPops an element off the end of the list and decreasing the size by one. |
| public void | pop(int
>= 0; number of elements to remove from endPops N elements off the end of the list and decreasing the size by N. |
| public void | removeIndex(int
>=0, < size(); index of element to removeRemoves an element at a given index, shifting elements at greater indicies down one. |
| public void | |
| public void | |
| public int | |
| public void | |
| public int | Returns: last value in the arrayReturns the last element in the array without modifying the array |
| public String |
| EMPTY | back to summary |
|---|---|
| public static final IntList EMPTY
| |
| size | back to summary |
|---|---|
| private int size
| |
| sorted | back to summary |
|---|---|
| private boolean sorted whether the values are currently sorted | |
| values | back to summary |
|---|---|
| private int[] values
| |
| IntList | back to summary |
|---|---|
| public IntList() Constructs an empty instance with a default initial capacity. | |
| IntList | back to summary |
|---|---|
| public IntList(int initialCapacity) Constructs an empty instance.
| |
| add | back to summary |
|---|---|
| public void add(int value) Adds an element to the end of the list. This will increase the list's capacity if necessary.
| |
| binarysearch | back to summary |
|---|---|
| public int binarysearch(int value) Performs a binary search on a sorted list, returning the index of
the given value if it is present or
| |
| contains | back to summary |
|---|---|
| public boolean contains(int value) Returns whether or not the given value appears in the list. This will do a binary search if the list is sorted or a linear search if not.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| get | back to summary |
|---|---|
| public int get(int n) Gets the indicated value.
| |
| growIfNeeded | back to summary |
|---|---|
| private void growIfNeeded() Increases size of array if needed | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(int value) Returns the index of the given value, or -1 if the value does not appear in the list. This will do a binary search if the list is sorted or a linear search if not.
| |
| insert | back to summary |
|---|---|
| public void insert(int n, int value) Inserts element into specified index, moving elements at and above that index up one. May not be used to insert at an index beyond the current size (that is, insertion as a last element is legal but no further).
| |
| makeImmutable | back to summary |
|---|---|
| public static IntList makeImmutable(int value) Constructs a new immutable instance with the given element.
| |
| makeImmutable | back to summary |
|---|---|
| public static IntList makeImmutable(int value0, int value1) Constructs a new immutable instance with the given elements.
| |
| mutableCopy | back to summary |
|---|---|
| public IntList mutableCopy() Makes and returns a mutable copy of the list.
| |
| pop | back to summary |
|---|---|
| public int pop() Pops an element off the end of the list and decreasing the size by one.
| |
| pop | back to summary |
|---|---|
| public void pop(int n) Pops N elements off the end of the list and decreasing the size by N.
| |
| removeIndex | back to summary |
|---|---|
| public void removeIndex(int n) Removes an element at a given index, shifting elements at greater indicies down one.
| |
| set | back to summary |
|---|---|
| public void set(int n, int value) Sets the value at the given index.
| |
| shrink | back to summary |
|---|---|
| public void shrink(int newSize) Shrinks the size of the list.
| |
| size | back to summary |
|---|---|
| public int size() Gets the number of elements in this list. | |
| sort | back to summary |
|---|---|
| public void sort() Sorts the elements in the list in-place. | |
| top | back to summary |
|---|---|
| public int top() Returns the last element in the array without modifying the array
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |