Class BoundedBufferMap<K,​V>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all of the mappings from this map.
      int getCapacity()  
      boolean isEmpty()
      Returns true if this map contains no key-value mappings
      boolean isFull()
      Indicates whether the map is full.
      boolean offer​(K key, V value, long timeOut, TimeUnit timeUnit)
      Inserts the specified key value pair into the map, waiting up to the specified wait time for space to become available if the map is full.
      V peek​(K key)
      Retrieves the value, but does not remove, the key value pair of this map, or returns null if the value cannot be found.
      V poll​(K key, long timeOut, TimeUnit timeUnit)
      Retrieves and removes a value from this map, waiting up to the specified wait time if necessary for the key to become available.
      int size()
      Returns the number of key-value mappings in this map.
    • Constructor Detail

      • BoundedBufferMap

        public BoundedBufferMap​(int capacity)
      • BoundedBufferMap

        public BoundedBufferMap()
    • Method Detail

      • getCapacity

        public int getCapacity()
      • offer

        public boolean offer​(K key,
                             V value,
                             long timeOut,
                             TimeUnit timeUnit)
                      throws InterruptedException
        Inserts the specified key value pair into the map, waiting up to the specified wait time for space to become available if the map is full.
        Parameters:
        key - key
        value - value
        timeOut - time out
        timeUnit - unit
        Returns:
        true if successful, or false if the specified waiting time elapses before space is available
        Throws:
        InterruptedException - if interrupted while waiting
      • poll

        public V poll​(K key,
                      long timeOut,
                      TimeUnit timeUnit)
               throws InterruptedException
        Retrieves and removes a value from this map, waiting up to the specified wait time if necessary for the key to become available.
        Parameters:
        key - key
        timeOut - time out
        timeUnit - unit
        Returns:
        the value for the given key if successful, or null if the specified waiting time elapses before the corresponding value was added
        Throws:
        InterruptedException - if interrupted while waiting
      • peek

        public V peek​(K key)
        Retrieves the value, but does not remove, the key value pair of this map, or returns null if the value cannot be found.
        Parameters:
        key - key
        Returns:
        value or null
      • isEmpty

        public boolean isEmpty()
        Returns true if this map contains no key-value mappings
        Returns:
        true if this map contains no key-value mappings
      • isFull

        public boolean isFull()
        Indicates whether the map is full.
        Returns:
        true or false.
      • size

        public int size()
        Returns the number of key-value mappings in this map.
        Returns:
        the number of key-value mappings in this map
      • clear

        public void clear()
        Removes all of the mappings from this map. The map will be empty after this call returns.