org.omnaest.utils.structure.collection.list.sorted
Class InsertionSortedList<E>

java.lang.Object
  extended by org.omnaest.utils.structure.collection.CollectionAbstract<E>
      extended by org.omnaest.utils.structure.collection.list.ListAbstract<E>
          extended by org.omnaest.utils.structure.collection.list.sorted.SortedListAbstract<E>
              extended by org.omnaest.utils.structure.collection.list.sorted.InsertionSortedList<E>
Type Parameters:
E -
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, SortedList<E>, SortedSplitableList<E>

public class InsertionSortedList<E>
extends SortedListAbstract<E>

SortedList implementation using insertion sort algorithm based on a simple ArrayList

Author:
Omnaest
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.omnaest.utils.structure.collection.list.sorted.SortedListAbstract
SortedListAbstract.SortedListAbstractSublist<E>
 
Nested classes/interfaces inherited from class org.omnaest.utils.structure.collection.list.ListAbstract
ListAbstract.ListAbstractSublist<E>
 
Field Summary
protected  List<E> list
           
 
Fields inherited from class org.omnaest.utils.structure.collection.list.sorted.SortedListAbstract
comparator
 
Constructor Summary
InsertionSortedList()
           
InsertionSortedList(Collection<E> collection)
           
InsertionSortedList(Collection<E> collection, Comparator<E> comparator)
           
InsertionSortedList(Comparator<E> comparator)
           
 
Method Summary
 boolean add(E element)
          This does add the given element at the right order position.
 void clear()
           
 E get(int index)
           
 int indexOf(Object object)
           
 int lastIndexOf(Object object)
           
protected  SortedList<E> newInstance(Collection<E> collection)
          Creates a new SortedList instance
protected  ArrayList<E> newInternalList()
          Returns a new unsorted List instance.
 E remove(int index)
           
 int size()
           
 
Methods inherited from class org.omnaest.utils.structure.collection.list.sorted.SortedListAbstract
add, comparator, first, first, getFirst, getLast, headList, headList, last, last, set, splitAt, subList, subList, subList, tailList, tailList
 
Methods inherited from class org.omnaest.utils.structure.collection.list.ListAbstract
addAll, addFirst, addLast, contains, descendingIterator, element, isValidIndex, iterator, listIterator, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence
 
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
addAll, addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, listIterator, listIterator, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

list

protected final List<E> list
Constructor Detail

InsertionSortedList

public InsertionSortedList()
See Also:
InsertionSortedList

InsertionSortedList

public InsertionSortedList(Collection<E> collection,
                           Comparator<E> comparator)
Parameters:
collection -
comparator -
See Also:
InsertionSortedList

InsertionSortedList

public InsertionSortedList(Collection<E> collection)
Parameters:
collection -
See Also:
InsertionSortedList

InsertionSortedList

public InsertionSortedList(Comparator<E> comparator)
Parameters:
comparator -
See Also:
InsertionSortedList
Method Detail

add

public boolean add(E element)
Description copied from interface: SortedList
This does add the given element at the right order position. This does break the contract of the Collection interface, since the new element is not appended to the Collection.


size

public int size()

get

public E get(int index)

remove

public E remove(int index)

indexOf

public int indexOf(Object object)

lastIndexOf

public int lastIndexOf(Object object)

newInternalList

protected ArrayList<E> newInternalList()
Returns a new unsorted List instance. Per default the ArrayList implementation is used, but this can be overriden by subclasses

Returns:
new List

clear

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

newInstance

protected SortedList<E> newInstance(Collection<E> collection)
Description copied from class: SortedListAbstract
Creates a new SortedList instance

Overrides:
newInstance in class SortedListAbstract<E>
Returns:


Copyright © 2013. All Rights Reserved.