Interface RMultimap<K,V>

Type Parameters:
K - key
V - value
All Superinterfaces:
RExpirable, RExpirableAsync, RMultimapAsync<K,V>, RObject, RObjectAsync
All Known Subinterfaces:
RListMultimap<K,V>, RListMultimapCache<K,V>, RMultimapCache<K,V>, RSetMultimap<K,V>, RSetMultimapCache<K,V>
All Known Implementing Classes:
RedissonListMultimap, RedissonListMultimapCache, RedissonMultimap, RedissonSetMultimap, RedissonSetMultimapCache

public interface RMultimap<K,V> extends RExpirable, RMultimapAsync<K,V>
Base Multimap interface. Allows to map multiple values per key.
Author:
Nikita Koksharov
  • Method Details

    • getCountDownLatch

      RCountDownLatch getCountDownLatch(K key)
      Returns RCountDownLatch instance associated with key
      Parameters:
      key - - map key
      Returns:
      countdownlatch
    • getPermitExpirableSemaphore

      RPermitExpirableSemaphore getPermitExpirableSemaphore(K key)
      Returns RPermitExpirableSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      permitExpirableSemaphore
    • getSemaphore

      RSemaphore getSemaphore(K key)
      Returns RSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      semaphore
    • getFairLock

      RLock getFairLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      fairlock
    • getReadWriteLock

      RReadWriteLock getReadWriteLock(K key)
      Returns RReadWriteLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      readWriteLock
    • getLock

      RLock getLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      lock
    • size

      int size()
      Returns the number of key-value pairs in this multimap.
      Returns:
      size of multimap
    • isEmpty

      boolean isEmpty()
      Check is map empty
      Returns:
      true if empty
    • containsKey

      boolean containsKey(Object key)
      Returns true if this multimap contains at least one key-value pair with the key key.
      Parameters:
      key - - map key
      Returns:
      true if contains a key
    • containsValue

      boolean containsValue(Object value)
      Returns true if this multimap contains at least one key-value pair with the value value.
      Parameters:
      value - - map value
      Returns:
      true if contains a value
    • containsEntry

      boolean containsEntry(Object key, Object value)
      Returns true if this multimap contains at least one key-value pair with the key key and the value value.
      Parameters:
      key - - map key
      value - - map value
      Returns:
      true if contains an entry
    • put

      boolean put(K key, V value)
      Stores a key-value pair in this multimap.

      Some multimap implementations allow duplicate key-value pairs, in which case put always adds a new key-value pair and increases the multimap size by 1. Other implementations prohibit duplicates, and storing a key-value pair that's already in the multimap has no effect.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      true if the method increased the size of the multimap, or false if the multimap already contained the key-value pair and doesn't allow duplicates
    • remove

      boolean remove(Object key, Object value)
      Removes a single key-value pair with the key key and the value value from this multimap, if such exists. If multiple key-value pairs in the multimap fit this description, which one is removed is unspecified.
      Parameters:
      key - - map key
      value - - map value
      Returns:
      true if the multimap changed
    • putAll

      boolean putAll(K key, Iterable<? extends V> values)
      Stores a key-value pair in this multimap for each of values, all using the same key, key. Equivalent to (but expected to be more efficient than):
         
      
         for (V value : values) {
           put(key, value);
         }

      In particular, this is a no-op if values is empty.

      Parameters:
      key - - map key
      values - - map values
      Returns:
      true if the multimap changed
    • replaceValues

      Collection<V> replaceValues(K key, Iterable<? extends V> values)
      Stores a collection of values with the same key, replacing any existing values for that key.

      If values is empty, this is equivalent to removeAll(key).

      Parameters:
      key - - map key
      values - - map values
      Returns:
      the collection of replaced values, or an empty collection if no values were previously associated with the key. The collection may be modifiable, but updating it will have no effect on the multimap.
    • removeAll

      Collection<V> removeAll(Object key)
      Removes all values associated with the key key.

      Once this method returns, key will not be mapped to any values

      Use fastRemove(K...) if values are not needed.

      Parameters:
      key - - map key
      Returns:
      the values that were removed (possibly empty). The returned collection may be modifiable, but updating it will have no effect on the multimap.
    • clear

      void clear()
      Removes all key-value pairs from the multimap, leaving it empty.
    • get

      Collection<V> get(K key)
      Returns a view collection of the values associated with key in this multimap, if any. Note that when containsKey(key) is false, this returns an empty collection, not null.

      Changes to the returned collection will update the underlying multimap, and vice versa.

      Parameters:
      key - - map key
      Returns:
      collection of values
    • getAll

      Collection<V> getAll(K key)
      Returns all elements at once. Result collection is NOT backed by map, so changes are not reflected in map.
      Parameters:
      key - - map key
      Returns:
      collection of values
    • keySet

      Set<K> keySet()
      Returns a view collection of all distinct keys contained in this multimap. Note that the key set contains a key if and only if this multimap maps that key to at least one value.

      Changes to the returned set will update the underlying multimap, and vice versa. However, adding to the returned set is not possible.

      Returns:
      set of keys
    • keySize

      int keySize()
      Returns the count of distinct keys in this multimap.
      Returns:
      keys amount
    • values

      Collection<V> values()
      Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (so values().size() == size()).

      Changes to the returned collection will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.

      Returns:
      collection of values
    • entries

      Collection<Map.Entry<K,V>> entries()
      Returns a view collection of all key-value pairs contained in this multimap, as Map.Entry instances.

      Changes to the returned collection or the entries it contains will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.

      Returns:
      collection of entries
    • fastRemove

      long fastRemove(K... keys)
      Removes keys from map by one operation Works faster than RMultimap.remove but not returning the value associated with key
      Parameters:
      keys - - map keys
      Returns:
      the number of keys that were removed from the hash, not including specified but non existing keys
    • fastRemoveValue

      long fastRemoveValue(V... values)
      Removes values from map by one operation
      Parameters:
      values - map values
      Returns:
      the number of values that were removed from the map
    • readAllKeySet

      Set<K> readAllKeySet()
      Read all keys at once
      Returns:
      keys