org.omnaest.utils.structure.collection.list.sorted
Interface SortedList<E>

Type Parameters:
E -
All Superinterfaces:
Collection<E>, Iterable<E>, List<E>
All Known Subinterfaces:
SortedSplitableList<E>
All Known Implementing Classes:
InsertionSortedList, SortedListAbstract, SortedListAbstract.SortedListAbstractSublist, SortedListDispatcher, SortedListDispatcherSizeBased, TreeList

public interface SortedList<E>
extends List<E>

Extension of the List interface for sorted lists.

Author:
Omnaest
See Also:
List, SortedSet

Method Summary
 boolean add(E element)
          This does add the given element at the right order position.
 void add(int index, E element)
          The add(int, Object) ignores the given index position and acts similar to the add(Object) method
 Comparator<? super E> comparator()
          Returns the Comparator used by this SortedList
 E first()
          Returns the first (lowest) element currently in this SortedList.
 SortedList<E> headList(E toElement)
          Returns a view to the current SortedList which starts at the beginning and ends by the given element which itself is excluded from the head list.
 E last()
          Returns the last (highest) element currently in this SortedList.
 E set(int index, E element)
          Uses List.remove(int) to remove the element from the given index position an returns it.
 SortedList<E> subList(E fromElement, E toElement)
          Returns a sublist view of the current SortedList starting by the given fromElement which will be included in the sublist and ending by the given toElement which will be excluded from the sublist.
 SortedList<E> subList(int fromIndex, int toIndex)
          Similar to List#subList(int, int)
 SortedList<E> tailList(E fromElement)
          Returns a view to the current SortedList starting by the given element up to the end including the given element.
 
Methods inherited from interface java.util.List
addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

comparator

Comparator<? super E> comparator()
Returns the Comparator used by this SortedList

Returns:

subList

SortedList<E> subList(E fromElement,
                      E toElement)
Returns a sublist view of the current SortedList starting by the given fromElement which will be included in the sublist and ending by the given toElement which will be excluded from the sublist.

Parameters:
fromElement - lower point (inclusive)
toElement - higher pint (exclusive)

headList

SortedList<E> headList(E toElement)
Returns a view to the current SortedList which starts at the beginning and ends by the given element which itself is excluded from the head list.

Parameters:
toElement - end element (exclusive)
Returns:

tailList

SortedList<E> tailList(E fromElement)
Returns a view to the current SortedList starting by the given element up to the end including the given element.

Parameters:
fromElement -
Returns:

first

E first()
Returns the first (lowest) element currently in this SortedList.


last

E last()
Returns the last (highest) element currently in this SortedList.


subList

SortedList<E> subList(int fromIndex,
                      int toIndex)
Similar to List#subList(int, int)

Specified by:
subList in interface List<E>

add

boolean add(E element)
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.

Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>

add

void add(int index,
         E element)
The add(int, Object) ignores the given index position and acts similar to the add(Object) method

Specified by:
add in interface List<E>

set

E set(int index,
      E element)
Uses List.remove(int) to remove the element from the given index position an returns it. The newly given element will NOT be inserted at the given index position, instead it will be inserted at its right sort position similar to calling the add(Object) method on it.

Specified by:
set in interface List<E>


Copyright © 2013. All Rights Reserved.