public class NioSelectedKeySet extends AbstractSet<SelectionKey>
Selector to avoid excessive allocation.
Assumes single threaded usage.| Constructor and Description |
|---|
NioSelectedKeySet()
Construct a key set with default capacity
|
NioSelectedKeySet(int initialCapacity)
Construct a key set with the given capacity.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(SelectionKey selectionKey) |
int |
capacity()
Capacity of the current set.
|
void |
clear()
Null out the keys and set size to 0.
|
boolean |
contains(Object o) |
int |
forEach(ToIntFunction<SelectionKey> function)
Iterate over the key set and apply a given function.
|
boolean |
isEmpty() |
Iterator<SelectionKey> |
iterator() |
SelectionKey[] |
keys()
Return selected keys for direct processing which is valid up to
size() index. |
boolean |
remove(Object o) |
void |
reset()
Reset for next iteration.
|
void |
reset(int skipCount)
Reset for next iteration, having only processed a subset of the selection keys.
|
int |
size() |
equals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streampublic NioSelectedKeySet()
public NioSelectedKeySet(int initialCapacity)
initialCapacity - for the key setpublic int size()
size in interface Collection<SelectionKey>size in interface Set<SelectionKey>size in class AbstractCollection<SelectionKey>public int capacity()
public boolean isEmpty()
isEmpty in interface Collection<SelectionKey>isEmpty in interface Set<SelectionKey>isEmpty in class AbstractCollection<SelectionKey>public boolean add(SelectionKey selectionKey)
add in interface Collection<SelectionKey>add in interface Set<SelectionKey>add in class AbstractCollection<SelectionKey>public boolean remove(Object o)
remove in interface Collection<SelectionKey>remove in interface Set<SelectionKey>remove in class AbstractCollection<SelectionKey>public boolean contains(Object o)
contains in interface Collection<SelectionKey>contains in interface Set<SelectionKey>contains in class AbstractCollection<SelectionKey>public SelectionKey[] keys()
size() index.size() index.public void reset()
public void clear()
clear in interface Collection<SelectionKey>clear in interface Set<SelectionKey>clear in class AbstractCollection<SelectionKey>public void reset(int skipCount)
The NioSelectedKeySet will still contain the keys representing IO events after
the skip Count have been removed, the remaining events can be processed in a future iteration.
skipCount - the number of keys to be skipped over that have already been processed.public int forEach(ToIntFunction<SelectionKey> function)
function - to apply to each SelectionKeypublic Iterator<SelectionKey> iterator()
iterator in interface Iterable<SelectionKey>iterator in interface Collection<SelectionKey>iterator in interface Set<SelectionKey>iterator in class AbstractCollection<SelectionKey>Copyright © 2014-2021 Real Logic Limited. All Rights Reserved.