|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.intcoll.AbstractIntCollection
ch.javasoft.util.intcoll.AbstractIntList
ch.javasoft.util.intcoll.DefaultIntList
public class DefaultIntList
The DefaultIntList is a list of integers backed by an
IntArray. Integers can be added after construction. This class
implements the collection interfaces and is therefore a list of integers.
addInt(int),
trimToLength(),
List,
IntList,
Serialized Form| Field Summary |
|---|
| Fields inherited from class ch.javasoft.util.intcoll.AbstractIntCollection |
|---|
mod |
| Constructor Summary | |
|---|---|
DefaultIntList()
|
|
DefaultIntList(DefaultIntList copy)
|
|
DefaultIntList(int initialCapacity)
|
|
DefaultIntList(int[] initialValues)
|
|
DefaultIntList(IntArray array)
|
|
DefaultIntList(IntCollection coll)
|
|
DefaultIntList(Iterable<Integer> values)
|
|
| Method Summary | |
|---|---|
boolean |
addAll(int... values)
|
boolean |
addAll(IntCollection coll)
|
boolean |
addInt(int value)
|
boolean |
addInt(int index,
int value)
|
int |
addIntToSorted(int value)
Adds the given value at the position where the value fits according to binarySearchInt(int). |
int |
binarySearchInt(int key)
Searches this int array for the specified value using the binary search algorithm. |
int |
binarySearchInt(int key,
int fromIndex,
int toIndex)
Searches this int array for the specified value using the binary search algorithm. |
void |
clear()
|
DefaultIntList |
clone()
|
int |
firstInt()
|
int |
getInt(int index)
|
boolean |
isEmpty()
|
int |
lastInt()
|
IntListIterator |
listIterator(int index)
|
void |
mergeSorted(IntList sorted)
Merges two sorted int lists. |
boolean |
removeFromTail(int n)
Removes n elements from the tail of this array. |
int |
removeIntAt(int index)
Removes and returns the integer at the given position. |
int |
removeLastInt()
|
int |
setInt(int index,
int value)
|
void |
setOrAddInt(int index,
int value)
Sets the value at the given position, if the index is in the range or this int array. |
int |
size()
|
void |
sort(boolean ascending)
Sort the array ascending or descending. |
void |
sort(boolean ascending,
int start,
int end)
Sort the specified array range ascending or descending. |
DefaultIntList |
subList(int fromIndex,
int toIndex)
|
void |
swap(int indexA,
int indexB)
|
int[] |
toIntArray()
|
String |
toString()
Returns a string representation of the contents of this int array. |
void |
trimToLength()
|
int[] |
yieldIntArray()
Returns the internal array after trimming it to the current length and returns it. |
| Methods inherited from class ch.javasoft.util.intcoll.AbstractIntList |
|---|
add, addAll, containsInt, get, indexOf, indexOfInt, intIterator, lastIndexOf, lastIndexOfInt, listIterator, remove, removeInt, set |
| Methods inherited from class ch.javasoft.util.intcoll.AbstractIntCollection |
|---|
add, addAll, contains, containsAll, equals, first, hashCode, iterator, last, remove, removeAll, retainAll, toArray, toArray, toArrayInternal, toIntArray, toIntArrayInternal |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ch.javasoft.util.intcoll.IntList |
|---|
containsInt, intIterator |
| Methods inherited from interface ch.javasoft.util.intcoll.IntCollection |
|---|
removeInt, toIntArray |
| Methods inherited from interface java.util.List |
|---|
add, add, addAll, addAll, contains, containsAll, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, toArray, toArray |
| Constructor Detail |
|---|
public DefaultIntList()
public DefaultIntList(int initialCapacity)
public DefaultIntList(int[] initialValues)
public DefaultIntList(IntArray array)
public DefaultIntList(Iterable<Integer> values)
public DefaultIntList(DefaultIntList copy)
public DefaultIntList(IntCollection coll)
| Method Detail |
|---|
public DefaultIntList clone()
clone in class AbstractIntCollectionpublic int size()
size in interface Collection<Integer>size in interface List<Integer>size in class AbstractIntListpublic boolean isEmpty()
isEmpty in interface Collection<Integer>isEmpty in interface List<Integer>isEmpty in class AbstractIntCollection
public int getInt(int index)
throws IndexOutOfBoundsException
getInt in interface IntListgetInt in class AbstractIntListIndexOutOfBoundsException
public int setInt(int index,
int value)
throws IndexOutOfBoundsException
setInt in interface IntListsetInt in class AbstractIntListIndexOutOfBoundsException
public void setOrAddInt(int index,
int value)
index == length()), the value is added to this array. If the
index is after the end (i.e. index > length()), the value is
added at the specified position, the gap between the added value and the
current length of the array is filled with
initial values.
index - the index where the new value should be placed, either added
or replacing an old onevalue - the value to set or addpublic int addIntToSorted(int value)
binarySearchInt(int). If this int array is not sorted
ascending, the result is undefined.
value - the value to insert
public void mergeSorted(IntList sorted)
sorted - the other sorted int list to merge into this int arraypublic boolean addInt(int value)
addInt in interface IntCollectionaddInt in class AbstractIntList
public boolean addInt(int index,
int value)
addInt in interface IntListaddInt in class AbstractIntListpublic boolean addAll(IntCollection coll)
addAll in interface IntCollectionaddAll in class AbstractIntCollectionpublic boolean addAll(int... values)
addAll in interface IntCollectionaddAll in class AbstractIntCollectionpublic int removeLastInt()
public boolean removeFromTail(int n)
n elements from the tail of this array. If fewer
elements are left in this array, an IndexOutOfBoundsException is
thrown.
n - the number of elements to remove from the tail of this array
public int removeIntAt(int index)
removeIntAt in interface IntListremoveIntAt in class AbstractIntListindex - the index of the value to remove
public void clear()
clear in interface Collection<Integer>clear in interface List<Integer>clear in class AbstractIntListpublic int firstInt()
firstInt in class AbstractIntCollectionpublic int lastInt()
lastInt in class AbstractIntCollection
public DefaultIntList subList(int fromIndex,
int toIndex)
subList in interface IntListsubList in interface List<Integer>subList in class AbstractIntListpublic IntListIterator listIterator(int index)
listIterator in interface IntListlistIterator in interface List<Integer>listIterator in class AbstractIntList
public void swap(int indexA,
int indexB)
public int[] toIntArray()
toIntArray in interface IntCollectiontoIntArray in class AbstractIntCollectionpublic int[] yieldIntArray()
DefaultIntList will be empty after this
operation.
public void trimToLength()
public void sort(boolean ascending)
binarySearchInt(int) and
addIntToSorted(int) methods can be used
ascending - true for ascending sort order
public void sort(boolean ascending,
int start,
int end)
binarySearchInt(int) and
addIntToSorted(int) methods can be used.
This method should only be used if one knows that only the defined
interval needs sorting. Otherwise, sort(boolean) should be used
instead.
ascending - true for ascending sort orderstart - the index where the sorting starts (inclusive)end - the index where the sorting ends (exclusive)
public int binarySearchInt(int key)
throws IllegalStateException
sort(boolean) method) prior to making this
call. If it is not sorted, the results are undefined. If the array
contains multiple elements with the specified value, there is no
guarantee which one will be found.
key - the value to be searched for.
IllegalStateExceptionArrays.binarySearch(int[], int, int, int)
public int binarySearchInt(int key,
int fromIndex,
int toIndex)
throws IllegalStateException
sort(boolean) method) prior to making this
call. If it is not sorted, the results are undefined. If the array
contains multiple elements with the specified value, there is no
guarantee which one will be found.
key - the value to be searched for.fromIndex - the index of the first element (inclusive) to be
searchedtoIndex - the index of the last element (exclusive) to be searched
IllegalStateExceptionArrays.binarySearch(int[], int, int, int)public String toString()
toString in class AbstractIntCollection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||