Class LongToObjectHashMap<V>

java.lang.Object
edu.wpi.first.units.collections.LongToObjectHashMap<V>
Type Parameters:
V - the type of the values stored in the map

public class LongToObjectHashMap<V>
extends Object
A variant on java.util.HashMap<K, V> that uses primitive long ints for map keys instead of autoboxed Long objects like would be used for a Map<Long, V>.
  • Constructor Details

  • Method Details

    • put

      public V put​(long key, V value)
      Puts a value value corresponding to key key in the map.
      Parameters:
      key - the associated key
      value - the value to insert
      Returns:
      the previous value that was mapped to the key, or null if no such value existed
    • get

      public V get​(long key)
      Gets the value associated with the given key.
      Parameters:
      key - the key to retrieve the value for
      Returns:
      the value mapped to the key, or null if the key is not in the map
    • remove

      public V remove​(long key)
      Removes the value associated with the given key and returns it.
      Parameters:
      key - the key to remove
      Returns:
      the value corresponding to the key, or null if the key is not in the map
    • containsKey

      public boolean containsKey​(long key)
      Checks if a key is contained in the map.
      Parameters:
      key - the key to check
      Returns:
      true if the key has an associated value, false if not
    • clear

      public void clear()
      Clears and removes all entries from the map.
    • size

      public int size()
      Gets the number of key-value pairs currently contained in the map.
      Returns:
      the current size of the map
    • isEmpty

      public boolean isEmpty()
      Checks if the map contains any entries.
      Returns:
      true if at least one entry is present, false otherwise
    • keySet

      Gets the keys contained in the map. Ordering is not guaranteed. The returned set is read-only and immutable. This uses a custom class for primitive long values to avoid unnecessary autoboxing to java.lang.Long.
      Returns:
      a read-only set of keys
    • values

      public Collection<V> values()
      Gets the values contained in the map. Ordering is not guaranteed. The returned collection is read-only and immutable.
      Returns:
      a read-only collection of values
    • forEach

      public void forEach​(LongToObjectHashMap.IteratorFunction<? super V> function)
      Iterates over every key-value pair in the map and passes them to the given function.
      Parameters:
      function - the function to apply to every key-value pair.