public class ReadOnlySegmentAwareMap<K,V> extends AbstractDelegatingMap<K,V>
Any operation that would modify this map will throw an UnsupportedOperationException
This map is useful when you don't want to copy an entire map but only need to see entries from the given segments.
Note many operations are not constant time when using this map. The
values()
method is not supported as well. 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 Map<K,V> |
map |
protected ReadOnlySegmentAwareEntrySet<K,V> |
segmentAwareEntrySet |
protected ReadOnlySegmentAwareSet<K> |
segmentAwareKeySet |
Constructor and Description |
---|
ReadOnlySegmentAwareMap(Map<K,V> map,
ConsistentHash ch,
Set<Integer> allowedSegments) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
protected Map<K,V> |
delegate() |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
boolean |
isEmpty()
Checks if the provided map is empty.
|
protected boolean |
keyAllowed(Object key) |
Set<K> |
keySet() |
int |
size()
Returns the size of the read only map.
|
String |
toString() |
Collection<V> |
values()
NOTE: this method is not supported.
|
clear, put, putAll, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
protected final ConsistentHash ch
protected ReadOnlySegmentAwareSet<K> segmentAwareKeySet
protected ReadOnlySegmentAwareEntrySet<K,V> segmentAwareEntrySet
protected boolean keyAllowed(Object key)
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractDelegatingMap<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class AbstractDelegatingMap<K,V>
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).
public int size()
If you are using this method to verify if the map is empty, you should instead use
the ReadOnlySegmentAwareEntryMap#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).
public Collection<V> values()
Copyright © 2024 JBoss, a division of Red Hat. All rights reserved.