K
- The type of keys in the sorted list, to be used for sorting.V
- The type of elements in the list.public class KeySortedList<K extends Comparable<K>,V> extends AbstractSequentialList<V> implements Serializable
This class is not thread-safe. Synchronizations (if wanted) are user's reponsability.
modCount
Constructor and Description |
---|
KeySortedList()
Creates a new, initially empty list.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V element)
Inserts the specified element at a position determined by the specified key.
|
void |
clear()
Removes all of the elements from this list.
|
boolean |
containsKey(K key)
Returns
true if the list contains an element added with the specified key. |
int |
count(K key)
Returns the number of elements added with the specified
key.
|
V |
first(K key)
Returns the first element added with the specified key.
|
KeySortedList<K,V> |
headList(K toKey)
Returns a view of the portion of this list whose keys are strictly less than
toKey . |
V |
last(K key)
Returns the last element added with the specified key.
|
ListIterator<V> |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence), starting at the
specified position.
|
ListIterator<V> |
listIterator(K fromKey)
Returns a list iterator of the elements in this list (in proper sequence), starting at the
elements added with the specified key.
|
int |
removeAll(K key)
Removes all values that were added with the specified
key.
|
int |
size()
Returns the number of elements in this list.
|
KeySortedList<K,V> |
tailList(K fromKey)
Returns a view of the portion of this list whose keys are greater than or equal to
fromKey . |
add, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public void clear()
clear
in interface Collection<V>
clear
in interface List<V>
clear
in class AbstractList<V>
public int size()
size
in interface Collection<V>
size
in interface List<V>
size
in class AbstractCollection<V>
public void add(K key, V element)
Map
would do), but instead add the new element with the same key.key
- Key to be used to find the right location.element
- Object to be inserted.public int removeAll(K key)
key
- The key of values to remove.public int count(K key)
key
- The key of elements to count.public boolean containsKey(K key)
public V first(K key) throws NoSuchElementException
key
- The key for the element to search for.NoSuchElementException
- if there is no element for the specified key.public V last(K key) throws NoSuchElementException
key
- The key for the element to search for.NoSuchElementException
- if there is no element for the specified key.public ListIterator<V> listIterator(K fromKey)
fromKey
- The key of the first element to returns.IndexOutOfBoundsException
- if the index is out of range.public ListIterator<V> listIterator(int index)
next()
method.listIterator
in interface List<V>
listIterator
in class AbstractSequentialList<V>
index
- Index of first element to be returned from the list iterator.IndexOutOfBoundsException
- if the index is out of range.public KeySortedList<K,V> headList(K toKey)
toKey
.
The returned list is backed by this list, so changes in the returned list are reflected in
this list, and vice-versa.toKey
- high endpoint (exclusive) of the sub list.public KeySortedList<K,V> tailList(K fromKey)
fromKey
. The returned list is backed by this list, so changes in the returned list are
reflected in this list, and vice-versa.fromKey
- low endpoint (inclusive) of the sub list.Copyright © 1996–2023 Geotools. All rights reserved.