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 IntSet |
allowedSegments |
protected Map<K,V> |
map |
protected Set<Map.Entry<K,V>> |
segmentAwareEntrySet |
protected Set<K> |
segmentAwareKeySet |
protected LocalizedCacheTopology |
topology |
Constructor and Description |
---|
ReadOnlySegmentAwareMap(Map<K,V> map,
LocalizedCacheTopology topology,
IntSet 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, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
protected final LocalizedCacheTopology topology
protected final IntSet allowedSegments
public ReadOnlySegmentAwareMap(Map<K,V> map, LocalizedCacheTopology topology, IntSet allowedSegments)
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 © 2021 JBoss by Red Hat. All rights reserved.