Note that the keys in the returned list are arbitrarily ordered.
Package
Initializers
Methods
Type Methods
Value Type π―πElementβͺοΈπ
Dictionary, holding key value pairs.
Dictionaries allow you to associate keys with values. π― is implemented as a hash table and is O(1)
on average and O(n)
in worst case.
π― is a value type. This means that copies of π― are independent:
πΏ π€Janeπ€ β‘οΈ 45 π€Sharonπ€ β‘οΈ 22 π€Bobπ€ β‘οΈ 64 π β‘οΈ ages
ages β‘οΈ ππagesCopy
46 β‘οΈ π½agesCopy π€Janeπ€βοΈ
In the above example the dictionary in ages
will still contain 45 for the key π€Janeπ€
as only agesCopy
was modified.
To learn more about collection literals see the Language Reference.
Initializers
π
π π
Creates an empty π―.
πβΆοΈπ΄
π πβΆοΈπ΄ minCapacity π’
Creates an empty π― with a capacity of at least minCapacity.
Methods
π½βοΈ
βοΈ π½ key π‘ β‘οΈ π¬Element
Returns the value assigned to key. If key is not in the π―, no value is returned.
π¨βοΈ
π βοΈ π¨ key π‘
Removes key and its assigned value from the π―. No action is performed if key is not in the π―.
π½β‘οΈ
π β‘οΈ π½ ππ₯‘ value Element ππ₯‘ key π‘
Assings a value to the provided key.
πβοΈ
βοΈ π β‘οΈ π¨ππ‘π
Returns a list consisting of all keys in this π―.
πβοΈ
π βοΈ π β‘οΈ π’
Removes all key-value pairs in this π― and returns the number of deleted items.