Class: Toybox.Lang.Dictionary
- Inherits:
-
Toybox.Lang.Object
Overview
A Dictionary is a hash table or associative array used to map keys to values.
Both the keys and values can be any Object type, though they do not all
need to be of the same type. Objects used as a key should override the
hashCode() method. Due to the nature of
hash tables, the order of Dictionary elements are not guaranteed to match
the insertion order. null cannot be used as a key.
See Also:
Instance Method Summary collapse
-
get(key)
Retrieve a value from a Dictionary for a given key.
-
hasKey(key) as Lang.Boolean
Determine whether a key exists within a Dictionary.
-
isEmpty() as Lang.Boolean
Determine whether a Dictionary is empty.
-
keys() as Lang.Array
Retrieve the keys in the Dictionary.
-
put(key, value) as Void
Place a value in the Dictionary with a given key.
-
remove(key) as Void
Delete an item from a Dictionary.
-
size() as Lang.Number
Retrieve the number of elements in a Dictionary.
-
toString() as Lang.String
Convert a Dictionary to a String.
-
values() as Lang.Array
Retrieve the values in the Dictionary.
Instance Method Details
get(key)
Retrieve a value from a Dictionary for a given key.
hasKey(key) as Lang.Boolean
Determine whether a key exists within a Dictionary.
isEmpty() as Lang.Boolean
Determine whether a Dictionary is empty.
keys() as Lang.Array
Retrieve the keys in the Dictionary.
put(key, value) as Void
Place a value in the Dictionary with a given key.
remove(key) as Void
Delete an item from a Dictionary.
size() as Lang.Number
Retrieve the number of elements in a Dictionary.
toString() as Lang.String
Convert a Dictionary to a String.
Due to the nature of hash tables, the order of Dictionary elements are not guaranteed to match the insertion order when converting to a String.
values() as Lang.Array
Retrieve the values in the Dictionary.