Class SortedScheduledEntries<K,V extends Comparable<? super V>>
- java.lang.Object
-
- org.wildfly.clustering.ee.cache.scheduler.SortedScheduledEntries<K,V>
-
- All Implemented Interfaces:
Iterable<Map.Entry<K,V>>,ScheduledEntries<K,V>
public class SortedScheduledEntries<K,V extends Comparable<? super V>> extends Object implements ScheduledEntries<K,V>
ScheduledEntriesimplemented using aConcurrentSkipListSet, where entries are sorted based on the entry value. Bothadd(Object, Comparable)andremove(Object)run in O(log N) time.- Author:
- Paul Ferraro
-
-
Constructor Summary
Constructors Constructor Description SortedScheduledEntries()Creates a new entries object whose iteration order is based on the entry value.SortedScheduledEntries(Comparator<Map.Entry<K,V>> comparator)Creates a new entries object whose iteration order is based on the specified comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(K key, V value)Adds an entry using the specified key and value.booleancontains(K key)Indicates whether specified key exists among the scheduled entries.voidforEach(Consumer<? super Map.Entry<K,V>> action)booleanisSorted()Indicates whether the entries are sorted, or if iteration order recapitulates insertion order.Iterator<Map.Entry<K,V>>iterator()Map.Entry<K,V>peek()Returns, but does not remove, the first entry.voidremove(K key)Removes the entry with the specified key.Spliterator<Map.Entry<K,V>>spliterator()Stream<Map.Entry<K,V>>stream()Returns a stream of scheduled entries.StringtoString()
-
-
-
Constructor Detail
-
SortedScheduledEntries
public SortedScheduledEntries()
Creates a new entries object whose iteration order is based on the entry value.
-
SortedScheduledEntries
public SortedScheduledEntries(Comparator<Map.Entry<K,V>> comparator)
Creates a new entries object whose iteration order is based on the specified comparator.- Parameters:
comparator- the comparator used to determine the iteration order
-
-
Method Detail
-
isSorted
public boolean isSorted()
Description copied from interface:ScheduledEntriesIndicates whether the entries are sorted, or if iteration order recapitulates insertion order.- Specified by:
isSortedin interfaceScheduledEntries<K,V extends Comparable<? super V>>- Returns:
- true, if these entries are sorted, false otherwise.
-
add
public void add(K key, V value)
Description copied from interface:ScheduledEntriesAdds an entry using the specified key and value.- Specified by:
addin interfaceScheduledEntries<K,V extends Comparable<? super V>>- Parameters:
key- an entry keyvalue- an entry value
-
remove
public void remove(K key)
Description copied from interface:ScheduledEntriesRemoves the entry with the specified key.- Specified by:
removein interfaceScheduledEntries<K,V extends Comparable<? super V>>- Parameters:
key- an entry key
-
contains
public boolean contains(K key)
Description copied from interface:ScheduledEntriesIndicates whether specified key exists among the scheduled entries.- Specified by:
containsin interfaceScheduledEntries<K,V extends Comparable<? super V>>- Parameters:
key- an entry key- Returns:
- true, if the key is a scheduled entry, false otherwise
-
peek
public Map.Entry<K,V> peek()
Description copied from interface:ScheduledEntriesReturns, but does not remove, the first entry.- Specified by:
peekin interfaceScheduledEntries<K,V extends Comparable<? super V>>
-
stream
public Stream<Map.Entry<K,V>> stream()
Description copied from interface:ScheduledEntriesReturns a stream of scheduled entries.- Specified by:
streamin interfaceScheduledEntries<K,V extends Comparable<? super V>>- Returns:
- a stream of scheduled entries.
-
iterator
public Iterator<Map.Entry<K,V>> iterator()
- Specified by:
iteratorin interfaceIterable<K>- Specified by:
iteratorin interfaceScheduledEntries<K,V extends Comparable<? super V>>
-
spliterator
public Spliterator<Map.Entry<K,V>> spliterator()
- Specified by:
spliteratorin interfaceIterable<K>
-
-