|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
net.sf.molae.pipe.hash.HashList<E>
public class HashList<E>
A list where the index of each element equals its hash code.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
HashList(List<E> base)
Constructs a HashList object. |
Method Summary | |
---|---|
boolean |
add(E o)
Appends the specified element to the end of this List (optional operation). |
void |
clear()
Removes all of the elements from this collection (optional operation). |
boolean |
contains(Object o)
Returns true if this collection contains the specified element. |
E |
get(int index)
Returns the element at the specified position in this list. |
int |
indexOf(Object o)
Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. |
boolean |
isEmpty()
Returns true if this collection contains no elements. |
int |
lastIndexOf(Object o)
Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. |
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element (optional operation). |
int |
size()
Returns the number of elements in this collection. |
Methods inherited from class java.util.AbstractList |
---|
add, addAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, containsAll, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, containsAll, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public HashList(List<E> base)
base
- the underling lists where the elements are stored.Method Detail |
---|
public int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
isEmpty
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface List<E>
contains
in class AbstractCollection<E>
o
- object to be checked for containment in this collection.
public boolean add(E o)
This implementation calls the corresponding method of the base list if the hash code of the specified element equals the size of the list.
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractList<E>
o
- element to be appended to this list.
UnsupportedOperationException
- if the add method is not
supported by the base list.
ClassCastException
- if the class of the specified element
prevents it from being added to the base list.
IllegalArgumentException
- some aspect of this element prevents
it from being added to the base list or
if the hash code of the specified element is not equal to the size of
this list.public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class AbstractList<E>
UnsupportedOperationException
- if the clear
method
is not supported by the base listpublic E get(int index)
get
in interface List<E>
get
in class AbstractList<E>
index
- index of element to return.
IndexOutOfBoundsException
- if the given index is out of range
(index < 0 || index >= size()).public E set(int index, E element)
This implementation checks the hash code of the new element first.
set
in interface List<E>
set
in class AbstractList<E>
index
- index of element to replace.element
- element to be stored at the specified position.
UnsupportedOperationException
- if the set method is not
supported by the base list.
ClassCastException
- if the class of the specified element
prevents it from being added to the base list.
IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this list.
IndexOutOfBoundsException
- if the specified index is out of
range (index < 0 || index >= size()).public int indexOf(Object o)
indexOf
in interface List<E>
indexOf
in class AbstractList<E>
o
- element to search for.
public int lastIndexOf(Object o)
indexOf
.
lastIndexOf
in interface List<E>
lastIndexOf
in class AbstractList<E>
o
- element to search for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |