Interface CharObjectMap<VType>

All Superinterfaces:
CharObjectAssociativeContainer<VType>, Iterable<CharObjectCursor<VType>>
All Known Implementing Classes:
CharObjectHashMap, CharObjectScatterMap

@Generated(date="2023-10-26T04:33:09+0000", value="KTypeVTypeMap.java") public interface CharObjectMap<VType> extends CharObjectAssociativeContainer<VType>
An associative container with unique binding from keys to a single value.
  • Method Details

    • get

      VType get(char key)
      Returns:
      Returns the value associated with the given key or the default value for the key type, if the key is not associated with any value. Important note: For primitive type values, the value returned for a non-existing key may not be the default value of the primitive type (it may be any value previously assigned to that slot).
    • getOrDefault

      VType getOrDefault(char key, VType defaultValue)
      Returns:
      Returns the value associated with the given key or the provided default value if the key is not associated with any value.
    • put

      VType put(char key, VType value)
      Place a given key and value in the container.
      Returns:
      The value previously stored under the given key in the map is returned.
    • putAll

      int putAll(CharObjectAssociativeContainer<? extends VType> container)
      Puts all keys from another container to this map, replacing the values of existing keys, if such keys are present.
      Returns:
      Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.
    • putAll

      int putAll(Iterable<? extends CharObjectCursor<? extends VType>> iterable)
      Puts all keys from an iterable cursor to this map, replacing the values of existing keys, if such keys are present.
      Returns:
      Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.
    • remove

      VType remove(char key)
      Remove all values at the given key. The default value for the key type is returned if the value does not exist in the map.
    • equals

      boolean equals(Object obj)
      Compares the specified object with this set for equality. Returns true if and only if the specified object is also a CharObjectMap and both objects contains exactly the same key-value pairs.
      Overrides:
      equals in class Object
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      A hash code of elements stored in the map. The hash code is defined as a sum of hash codes of keys and values stored within the set). Because sum is commutative, this ensures that different order of elements in a set does not affect the hash code.
    • indexOf

      int indexOf(char key)
      Returns a logical "index" of a given key that can be used to speed up follow-up value setters or getters in certain scenarios (conditional logic). The semantics of "indexes" are not strictly defined. Indexes may (and typically won't be) contiguous. The index is valid only between map modifications (it will not be affected by read-only operations like iteration or value retrievals).
      Parameters:
      key - The key to locate in the map.
      Returns:
      A non-negative value of the logical "index" of the key in the map or a negative value if the key did not exist.
      See Also:
    • indexExists

      boolean indexExists(int index)
      Parameters:
      index - The index of a given key, as returned from indexOf(char).
      Returns:
      Returns true if the index corresponds to an existing key or false otherwise. This is equivalent to checking whether the index is a positive value (existing keys) or a negative value (non-existing keys).
      See Also:
    • indexGet

      VType indexGet(int index)
      Returns the value associated with an existing key.
      Parameters:
      index - The index of an existing key.
      Returns:
      Returns the value currently associated with the key.
      Throws:
      AssertionError - If assertions are enabled and the index does not correspond to an existing key.
      See Also:
    • indexReplace

      VType indexReplace(int index, VType newValue)
      Replaces the value associated with an existing key and returns any previous value stored for that key.
      Parameters:
      index - The index of an existing key.
      Returns:
      Returns the previous value associated with the key.
      Throws:
      AssertionError - If assertions are enabled and the index does not correspond to an existing key.
      See Also:
    • indexInsert

      void indexInsert(int index, char key, VType value)
      Inserts a key-value pair for a key that is not present in the map. This method may help in avoiding double recalculation of the key's hash.
      Parameters:
      index - The index of a previously non-existing key, as returned from indexOf(char).
      Throws:
      AssertionError - If assertions are enabled and the index corresponds to an existing key.
      See Also:
    • clear

      void clear()
      Clear all keys and values in the container.
      See Also:
    • release

      void release()
      Removes all elements from the collection and additionally releases any internal buffers. Typically, if the object is to be reused, a simple clear() should be a better alternative since it'll avoid reallocation.
      See Also:
    • visualizeKeyDistribution

      String visualizeKeyDistribution(int characters)
      Visually depict the distribution of keys.
      Parameters:
      characters - The number of characters to "squeeze" the entire buffer into.
      Returns:
      Returns a sequence of characters where '.' depicts an empty fragment of the internal buffer and 'X' depicts full or nearly full capacity within the buffer's range and anything between 1 and 9 is between.