Class GridBoundedLinkedHashMap<K,​V>

  • Type Parameters:
    K - Map key.
    V - Map entry.
    All Implemented Interfaces:
    Serializable, Cloneable, Map<K,​V>

    public class GridBoundedLinkedHashMap<K,​V>
    extends LinkedHashMap<K,​V>
    Generic map with an upper bound. Once map reaches its maximum capacity, the eldest elements will be removed based on insertion order.
    See Also:
    Serialized Form
    • Constructor Detail

      • GridBoundedLinkedHashMap

        public GridBoundedLinkedHashMap​(int maxCap)
                                 throws IllegalArgumentException
        Constructs an empty insertion-ordered GridBoundedLinkedHashMap instance with the specified maximum capacity, and a default load factor (0.75).
        Parameters:
        maxCap - Maximum map capacity.
        Throws:
        IllegalArgumentException - If the maximum capacity is negative.
      • GridBoundedLinkedHashMap

        public GridBoundedLinkedHashMap​(int initCap,
                                        int maxCap)
                                 throws IllegalArgumentException
        Constructs an empty insertion-ordered GridBoundedLinkedHashMap instance with the specified initial capacity, maximum capacity, and a default load factor (0.75).
        Parameters:
        initCap - Initial map capacity.
        maxCap - Maximum map capacity.
        Throws:
        IllegalArgumentException - If the initial capacity is negative, or maximum capacity is smaller than initial capacity.
      • GridBoundedLinkedHashMap

        public GridBoundedLinkedHashMap​(int initCap,
                                        int maxCap,
                                        float loadFactor)
                                 throws IllegalArgumentException
        Constructs an empty insertion-ordered GridBoundedLinkedHashMap instance with the specified initial capacity, maximum capacity, and load factor.
        Parameters:
        initCap - Initial map capacity.
        maxCap - Maximum map capacity.
        loadFactor - Load factor.
        Throws:
        IllegalArgumentException - If the initial capacity is negative, the load factor is non-positive, or maximum capacity is smaller than initial capacity.
      • GridBoundedLinkedHashMap

        public GridBoundedLinkedHashMap​(int initCap,
                                        int maxCap,
                                        float loadFactor,
                                        boolean accessOrder)
                                 throws IllegalArgumentException
        Constructs an empty GridBoundedLinkedHashMap instance with the specified initial capacity, maximum capacity, load factor and ordering mode.
        Parameters:
        initCap - Initial map capacity.
        maxCap - Maximum map capacity.
        loadFactor - Load factor.
        accessOrder - The ordering mode - true for access-order, false for insertion-order.
        Throws:
        IllegalArgumentException - If the initial capacity is negative, the load factor is non-positive, or maximum capacity is smaller than initial capacity.