Class UnsafeOneToManyIndex<K,V>
java.lang.Object
com.atlassian.bamboo.plan.cache.index.util.unsafe.UnsafeOneToManyIndex<K,V>
A class that allows to index any key <-> value, one-to-many relationship. The key characteristics of this class is that,
unlike Multimap<K,V>, it doesn't require linear scan when removing by value.
Both K and V must have hashCode() and equals() correctly defined.
The class is _not_ thread safe.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addToIndex
(K key, V value) To be used when you can be sure no prior mapping exists for the value.void
clear()
getByKeyUnsafe
(K key) Does not perform a copy, can only be used in context that are thread safe from perspective of this objectgetByValue
(V value) void
void
Replace key value pair with a new value.reindexSet
(K key, @NotNull Set<V> values) Replace complete value set for a key.removeByKey
(K key) removeByValue
(V value) void
removeMatchingValuesForKey
(K key, @NotNull Predicate<V> predicate)
-
Constructor Details
-
UnsafeOneToManyIndex
public UnsafeOneToManyIndex()
-
-
Method Details
-
addToIndex
To be used when you can be sure no prior mapping exists for the value. -
index
-
reindex
Replace key value pair with a new value. This is useful if value object can change content without changing identity. -
reindexSet
Replace complete value set for a key.- Returns:
- the old set
-
getForwardMapping
-
getBackwardMapping
-
removeByKey
-
removeByValue
-
removeMatchingValuesForKey
-
getByKey
-
getByKeyUnsafe
Does not perform a copy, can only be used in context that are thread safe from perspective of this object -
getByValue
-
clear
public void clear()
-