E - The type of the listpublic class FastLinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, Serializable
Returns concrete interface classes from iterator() methods: iterator() listIterator()
descendingIterator().
Does not check list modifications during iterations.
modCount| Constructor and Description |
|---|
FastLinkedList()
Constructs an empty list.
|
FastLinkedList(AbstractListListener<E> listener)
Constructs an empty list with an optional addition removal listener.
|
FastLinkedList(AbstractListListener<E> listener,
Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
|
FastLinkedList(Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
addFirst(E e) |
void |
addLast(E e) |
void |
clear() |
Object |
clone() |
boolean |
contains(Object o) |
FastLinkedListIterator<E> |
descendingIterator() |
E |
element() |
E |
get(int index) |
E |
getFirst() |
E |
getLast() |
int |
indexOf(Object o) |
FastLinkedListIterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
FastLinkedListIterator<E> |
listIterator() |
FastLinkedListIterator<E> |
listIterator(int index) |
boolean |
offer(E e)
Adds the specified element as the tail (last element) of this list.
|
boolean |
offerFirst(E e)
Inserts the specified element at the front of this list.
|
boolean |
offerLast(E e)
Inserts the specified element at the end of this list.
|
E |
peek()
Retrieves, but does not remove, the head (first element) of this list.
|
E |
peekFirst()
Retrieves, but does not remove, the first element of this list, or returns
null if this list is empty. |
E |
peekLast()
Retrieves, but does not remove, the last element of this list, or returns
null if this list is empty. |
E |
poll()
Retrieves and removes the head (first element) of this list.
|
E |
pollFirst()
Retrieves and removes the first element of this list, or returns
null if this list is empty. |
E |
pollLast()
Retrieves and removes the last element of this list, or returns
null if this list is empty. |
E |
pop()
Pops an element from the stack represented by this list.
|
void |
push(E e)
Pushes an element onto the stack represented by this list.
|
E |
remove()
Retrieves and removes the head (first element) of this list.
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
remove(Object o)
Removes the first occurrence of the specified element from this list, if it is present.
|
E |
removeFirst()
Removes and returns the first element from this list.
|
boolean |
removeFirstOccurrence(Object o)
Removes the first occurrence of the specified element in this list (when traversing the list from head to tail).
|
E |
removeLast()
Removes and returns the last element from this list.
|
boolean |
removeLastOccurrence(Object o)
Removes the last occurrence of the specified element in this list (when traversing the list from head to tail).
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element.
|
int |
size()
Returns the number of elements in this list.
|
Object[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence (from first to last element).
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the
returned array is that of the specified array.
|
equals, hashCode, removeRange, subListcontainsAll, isEmpty, removeAll, retainAll, toStringpublic FastLinkedList()
public FastLinkedList(AbstractListListener<E> listener)
listener - the listener to call on additions and removalspublic FastLinkedList(AbstractListListener<E> listener, Collection<? extends E> c)
listener - the listener to call on additions and removalsc - the collection whose elements are to be placed into this listNullPointerException - if the specified collection is nullpublic FastLinkedList(Collection<? extends E> c)
c - the collection whose elements are to be placed into this listNullPointerException - if the specified collection is nullpublic boolean add(E e)
public void add(int index,
E element)
public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in interface List<E>addAll in class AbstractCollection<E>public boolean addAll(int index,
Collection<? extends E> c)
public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>public boolean contains(Object o)
public FastLinkedListIterator<E> descendingIterator()
descendingIterator in interface Deque<E>public E element()
public E get(int index)
public int indexOf(Object o)
public FastLinkedListIterator<E> iterator()
public int lastIndexOf(Object o)
lastIndexOf in interface List<E>lastIndexOf in class AbstractList<E>public FastLinkedListIterator<E> listIterator()
listIterator in interface List<E>listIterator in class AbstractList<E>public FastLinkedListIterator<E> listIterator(int index)
listIterator in interface List<E>listIterator in class AbstractSequentialList<E>public boolean offer(E e)
public boolean offerFirst(E e)
offerFirst in interface Deque<E>e - the element to inserttrue (as specified by Deque.offerFirst(E))public boolean offerLast(E e)
offerLast in interface Deque<E>e - the element to inserttrue (as specified by Deque.offerLast(E))public E peek()
public E peekFirst()
null if this list is empty.public E peekLast()
null if this list is empty.public E poll()
public E pollFirst()
null if this list is empty.public E pollLast()
null if this list is empty.public E pop()
This method is equivalent to removeFirst().
pop in interface Deque<E>NoSuchElementException - if this list is emptypublic void push(E e)
This method is equivalent to addFirst(E).
public E remove()
public E remove(int index)
remove in interface List<E>remove in class AbstractSequentialList<E>index - the index of the element to be removedIndexOutOfBoundsExceptionpublic boolean remove(Object o)
i such that
(o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this
list contained the specified element (or equivalently, if this list changed as a result of the call).remove in interface Collection<E>remove in interface Deque<E>remove in interface List<E>remove in class AbstractCollection<E>o - element to be removed from this list, if presenttrue if this list contained the specified elementpublic E removeFirst()
removeFirst in interface Deque<E>NoSuchElementException - if this list is emptypublic boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface Deque<E>o - element to be removed from this list, if presenttrue if the list contained the specified elementpublic E removeLast()
removeLast in interface Deque<E>NoSuchElementException - if this list is emptypublic boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface Deque<E>o - element to be removed from this list, if presenttrue if the list contained the specified elementpublic E set(int index, E element)
set in interface List<E>set in class AbstractSequentialList<E>index - index of the element to replaceelement - element to be stored at the specified positionIndexOutOfBoundsExceptionpublic int size()
public Object[] toArray()
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the
array immediately following the end of the list is set to null. (This is useful in determining the length of the list
only if the caller knows that the list does not contain any null elements.)
Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method
allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation
costs.
Suppose x is a list known to contain only strings. The following code can be used to dump the list into a newly allocated
array of String:
String[] y = x.toArray(new String[0]);Note that
toArray(new Object[0]) is identical in function to toArray().toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>a - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose.ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this listNullPointerException - if the specified array is nullCopyright © 2012-2013 Batoo. All Rights Reserved.