Class LongToObjectHashMap<V>
java.lang.Object
org.wpilib.units.collections.LongToObjectHashMap<V>
- Type Parameters:
V- the type of the values stored in the map
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>.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for map iterator function. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears and removes all entries from the map.booleancontainsKey(long key) Checks if a key is contained in the map.voidforEach(LongToObjectHashMap.IteratorFunction<? super V> function) Iterates over every key-value pair in the map and passes them to the given function.get(long key) Gets the value associated with the given key.booleanisEmpty()Checks if the map contains any entries.keySet()Gets the keys contained in the map.Puts a valuevaluecorresponding to keykeyin the map.remove(long key) Removes the value associated with the given key and returns it.intsize()Gets the number of key-value pairs currently contained in the map.values()Gets the values contained in the map.
-
Constructor Details
-
LongToObjectHashMap
public LongToObjectHashMap()Default constructor.
-
-
Method Details
-
put
-
get
-
remove
-
containsKey
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
Clears and removes all entries from the map. -
size
Gets the number of key-value pairs currently contained in the map.- Returns:
- the current size of the map
-
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 tojava.lang.Long.- Returns:
- a read-only set of keys
-
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
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.
-