org.omnaest.utils.structure.collection.list
Class ListAbstract<E>

java.lang.Object
  extended by org.omnaest.utils.structure.collection.CollectionAbstract<E>
      extended by org.omnaest.utils.structure.collection.list.ListAbstract<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>
Direct Known Subclasses:
ArrayToListAdapter, IdentityArrayList, ListAbstract.ListAbstractSublist, ListToListAdapter, NestedDirectoryToByteArrayContainerListAdapter, SortedListAbstract

public abstract class ListAbstract<E>
extends CollectionAbstract<E>
implements List<E>, Deque<E>, Serializable

This abstract list implementation offers the basic methods like addAll, removeAll, retainAll, etc. which rely only on other list methods and not on any underlying structure. This list offers automatic ListIterator, Iterator and sublist which are backed to the given list.

Additionally the Deque interface is completely implemented as well.

Author:
Omnaest
See Also:
List, Deque, CollectionAbstract, MapAbstract, Serialized Form

Nested Class Summary
protected static class ListAbstract.ListAbstractSublist<E>
          Sublist implementation for the ListAbstract including the ListAbstract.ListAbstractSublist.fromIndex and excluding the ListAbstract.ListAbstractSublist.toIndex
 
Constructor Summary
ListAbstract()
           
 
Method Summary
 boolean addAll(int index, Collection<? extends E> elementCollection)
           
 void addFirst(E element)
           
 void addLast(E e)
           
 void clear()
           
 boolean contains(Object o)
           
 Iterator<E> descendingIterator()
           
 E element()
           
 E getFirst()
           
 E getLast()
           
protected  boolean isValidIndex(int index)
           
 Iterator<E> iterator()
           
 ListIterator<E> listIterator()
           
 ListIterator<E> listIterator(int index)
           
 boolean offer(E e)
           
 boolean offerFirst(E element)
           
 boolean offerLast(E e)
           
 E peek()
           
 E peekFirst()
           
 E peekLast()
           
 E poll()
           
 E pollFirst()
           
 E pollLast()
           
 E pop()
           
 void push(E element)
           
 E remove()
           
 boolean remove(Object o)
           
 E removeFirst()
           
 boolean removeFirstOccurrence(Object o)
           
 E removeLast()
           
 boolean removeLastOccurrence(Object o)
           
 List<E> subList(int fromIndex, int toIndex)
           
 
Methods inherited from class org.omnaest.utils.structure.collection.CollectionAbstract
addAll, containsAll, equals, hashCode, isEmpty, 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
add, add, addAll, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, remove, removeAll, retainAll, set, size, toArray, toArray
 
Methods inherited from interface java.util.Deque
add, size
 

Constructor Detail

ListAbstract

public ListAbstract()
Method Detail

addAll

public boolean addAll(int index,
                      Collection<? extends E> elementCollection)
Specified by:
addAll in interface List<E>

isValidIndex

protected boolean isValidIndex(int index)

listIterator

public ListIterator<E> listIterator()
Specified by:
listIterator in interface List<E>

listIterator

public ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface List<E>

subList

public List<E> subList(int fromIndex,
                       int toIndex)
Specified by:
subList in interface List<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Deque<E>
Specified by:
iterator in interface List<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Deque<E>
Specified by:
remove in interface List<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Deque<E>
Specified by:
contains in interface List<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class CollectionAbstract<E>

addFirst

public void addFirst(E element)
Specified by:
addFirst in interface Deque<E>

addLast

public void addLast(E e)
Specified by:
addLast in interface Deque<E>

offerFirst

public boolean offerFirst(E element)
Specified by:
offerFirst in interface Deque<E>

offerLast

public boolean offerLast(E e)
Specified by:
offerLast in interface Deque<E>

removeFirst

public E removeFirst()
Specified by:
removeFirst in interface Deque<E>

removeLast

public E removeLast()
Specified by:
removeLast in interface Deque<E>

pollFirst

public E pollFirst()
Specified by:
pollFirst in interface Deque<E>

pollLast

public E pollLast()
Specified by:
pollLast in interface Deque<E>

getFirst

public E getFirst()
Specified by:
getFirst in interface Deque<E>

getLast

public E getLast()
Specified by:
getLast in interface Deque<E>

peekFirst

public E peekFirst()
Specified by:
peekFirst in interface Deque<E>

peekLast

public E peekLast()
Specified by:
peekLast in interface Deque<E>

removeFirstOccurrence

public boolean removeFirstOccurrence(Object o)
Specified by:
removeFirstOccurrence in interface Deque<E>

removeLastOccurrence

public boolean removeLastOccurrence(Object o)
Specified by:
removeLastOccurrence in interface Deque<E>

offer

public boolean offer(E e)
Specified by:
offer in interface Deque<E>
Specified by:
offer in interface Queue<E>

remove

public E remove()
Specified by:
remove in interface Deque<E>
Specified by:
remove in interface Queue<E>

poll

public E poll()
Specified by:
poll in interface Deque<E>
Specified by:
poll in interface Queue<E>

element

public E element()
Specified by:
element in interface Deque<E>
Specified by:
element in interface Queue<E>

peek

public E peek()
Specified by:
peek in interface Deque<E>
Specified by:
peek in interface Queue<E>

push

public void push(E element)
Specified by:
push in interface Deque<E>

pop

public E pop()
Specified by:
pop in interface Deque<E>

descendingIterator

public Iterator<E> descendingIterator()
Specified by:
descendingIterator in interface Deque<E>


Copyright © 2013. All Rights Reserved.