public class ReadOnlySegmentAwareSet<E> extends AbstractDelegatingSet<E>
This set is useful when you don't want to copy an entire set but only need to see values from the given segments.
Note many operations are not constant time when using this set. Please check the method you are using to see if it will perform differently than normally expected.
| Modifier and Type | Field and Description |
|---|---|
protected Set<Integer> |
allowedSegments |
protected ConsistentHash |
ch |
protected Set<E> |
set |
| Constructor and Description |
|---|
ReadOnlySegmentAwareSet(Set<E> set,
ConsistentHash ch,
Set<Integer> allowedSegments) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
protected Set<E> |
delegate() |
boolean |
isEmpty()
Checks if the provided set is empty.
|
Iterator<E> |
iterator() |
int |
size()
Returns the size of the read only set.
|
protected boolean |
valueAllowed(Object obj) |
add, addAll, clear, forEach, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArrayclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, addAll, clear, equals, hashCode, remove, removeAll, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streamprotected final ConsistentHash ch
public ReadOnlySegmentAwareSet(Set<E> set, ConsistentHash ch, Set<Integer> allowedSegments)
protected Set<E> delegate()
delegate in class AbstractDelegatingSet<E>protected boolean valueAllowed(Object obj)
public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractDelegatingCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractDelegatingCollection<E>public boolean isEmpty()
This method should always be preferred over checking the size to see if it is empty.
This time complexity for this method between O(1) to O(N).
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractDelegatingCollection<E>public int size()
If you are using this method to verify if the set is empty, you should instead use
the isEmpty() as it will perform better if the
size is only used for this purpose.
This time complexity for this method is always O(N).
size in interface Collection<E>size in interface Set<E>size in class AbstractDelegatingCollection<E>Copyright © 2024 JBoss, a division of Red Hat. All rights reserved.