|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.collection.list.IndexArrayList<E>
E - public class IndexArrayList<E extends Comparable<? super E>>
This class implements the list interface.
The implementation is based on an internal ArrayList with a second list acting as an index.
What means that the list will need some more than twice the memory than an ArrayList and more time to add elements to the list.
For the increased memory space used and the increased time used for adding elements, it offers look up methods, like
contains(Object), indexOf(Object), lastIndexOf(Object),
that are based on an index search algorithm.
The algorithm uses binary search, and has by that a limited cost of log(n) for searching and adding, whereby n is the size of
the list.
The order of the list is the same, as the order of the elements added.
A limitation of the list is, that it can only be used for objects, that implement the Comparable interface. This is
caused by the use of a sorted internal table for the index.
| Constructor Summary | |
|---|---|
IndexArrayList()
Creates a new empty indexed list. |
|
IndexArrayList(Collection<? extends E> c)
Creates a new indexed list, which is filled with all objects of the collection. |
|
IndexArrayList(int initialSize)
|
|
| Method Summary | ||
|---|---|---|
boolean |
add(E e)
|
|
void |
add(int index,
E element)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
boolean |
addAll(int index,
Collection<? extends E> c)
|
|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
E |
get(int index)
|
|
int[] |
indexesOf(E e)
Returns all index positions, where the data values at are equal to the given element. |
|
int[] |
indexesOfElementsEqualOrBetween(E smallestElement,
E largestElement)
Returns the indexes of the elements that are equal or between the smallestElement and the largestElement. |
|
int[] |
indexesOfElementsGreaterThan(E element)
Returns the indexes of the elements greater than the as parameter given element. |
|
int[] |
indexesOfElementsLessThan(E element)
Returns the indexes of the elements less than the parameter element. |
|
int |
indexOf(Object o)
|
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
|
|
int |
lastIndexOf(Object o)
|
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int index)
|
|
void |
printDataList()
|
|
void |
printIndexList()
|
|
E |
remove(int dataListIndexPosition)
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
E |
set(int index,
E element)
|
|
int |
size()
|
|
List<E> |
subList(int fromIndex,
int toIndex)
|
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public IndexArrayList()
public IndexArrayList(int initialSize)
public IndexArrayList(Collection<? extends E> c)
c - | Method Detail |
|---|
public boolean add(E e)
add in interface Collection<E extends Comparable<? super E>>add in interface List<E extends Comparable<? super E>>
public void add(int index,
E element)
add in interface List<E extends Comparable<? super E>>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E extends Comparable<? super E>>addAll in interface List<E extends Comparable<? super E>>
public boolean addAll(int index,
Collection<? extends E> c)
addAll in interface List<E extends Comparable<? super E>>public void clear()
clear in interface Collection<E extends Comparable<? super E>>clear in interface List<E extends Comparable<? super E>>public boolean contains(Object o)
contains in interface Collection<E extends Comparable<? super E>>contains in interface List<E extends Comparable<? super E>>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E extends Comparable<? super E>>containsAll in interface List<E extends Comparable<? super E>>public E get(int index)
get in interface List<E extends Comparable<? super E>>public int indexOf(Object o)
indexOf in interface List<E extends Comparable<? super E>>public int[] indexesOfElementsGreaterThan(E element)
indexesOfElementsGreaterThan in interface IndexList<E extends Comparable<? super E>>element -
public int[] indexesOfElementsLessThan(E element)
indexesOfElementsLessThan in interface IndexList<E extends Comparable<? super E>>element -
public int[] indexesOfElementsEqualOrBetween(E smallestElement,
E largestElement)
indexesOfElementsEqualOrBetween in interface IndexList<E extends Comparable<? super E>>elementFrom -
public int[] indexesOf(E e)
indexesOf in interface IndexList<E extends Comparable<? super E>>e -
indexOf(Object),
lastIndexOf(Object)public boolean isEmpty()
isEmpty in interface Collection<E extends Comparable<? super E>>isEmpty in interface List<E extends Comparable<? super E>>public Iterator<E> iterator()
iterator in interface Iterable<E extends Comparable<? super E>>iterator in interface Collection<E extends Comparable<? super E>>iterator in interface List<E extends Comparable<? super E>>public int lastIndexOf(Object o)
lastIndexOf in interface List<E extends Comparable<? super E>>public ListIterator<E> listIterator()
listIterator in interface List<E extends Comparable<? super E>>public ListIterator<E> listIterator(int index)
listIterator in interface List<E extends Comparable<? super E>>public boolean remove(Object o)
remove in interface Collection<E extends Comparable<? super E>>remove in interface List<E extends Comparable<? super E>>public E remove(int dataListIndexPosition)
remove in interface List<E extends Comparable<? super E>>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E extends Comparable<? super E>>removeAll in interface List<E extends Comparable<? super E>>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E extends Comparable<? super E>>retainAll in interface List<E extends Comparable<? super E>>
public E set(int index,
E element)
set in interface List<E extends Comparable<? super E>>public int size()
size in interface Collection<E extends Comparable<? super E>>size in interface List<E extends Comparable<? super E>>
public List<E> subList(int fromIndex,
int toIndex)
subList in interface List<E extends Comparable<? super E>>public Object[] toArray()
toArray in interface Collection<E extends Comparable<? super E>>toArray in interface List<E extends Comparable<? super E>>public <T> T[] toArray(T[] a)
toArray in interface Collection<E extends Comparable<? super E>>toArray in interface List<E extends Comparable<? super E>>public void printDataList()
public void printIndexList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||