Import std.collections.map
std.collections.map
Map<K, V>: a hash map from keys to values, in the order they were added. Its entries are in an
array, each bucket starts a chain of the entries whose hashes land in it, and each entry links
to the ones added before and after it, so removing one leaves the others in order. What a
change takes out or replaces is let go of once the Map is whole again, so a key's or value's
Destroy that it runs can use the Map.
std/collections/map.fb
Types
Map
class
@DebugEntries Public Class Map<K: Hashable, V> Implements Iterable<(K, V)>, Cloneable, Defaultable
A hash map from keys to values, which keeps its entries in the order they were added.
Examples
Local ages = {"Ada": 36, "Alan": 41}
ages["Grace"] = 85
Expect(ages.Get("Ada") == 36)
Expect(ages.Get("Bob") == Null)
Expect(ages.Keys() == ["Ada", "Alan", "Grace"])std/collections/map.fb, line 31
-
A new, empty Map.
-
A Map whose [] gives value for a key that isn't there, without adding the key. It's one value, which every such read gives: a default that's an object or an array is shared, so to give each key one of its own, use GetOrAdd.
-
How many entries it holds.
-
Adds an entry, or gives an existing
keyits new value. -
Adds an entry when the
keyisn't there, and tells whether it wasn't. -
Adds each of
other's entries, in its order, as Add does. -
The
key's value, or Null when it isn't there. -
The
key's value, orfallbackwhen it isn't there. -
The
key's value, adding whatmakegives for it first when it isn't there, which is thekey's value thoughmakeadded thekeyitself. -
Gives the
key's value whatchangegives for it, and tells whether thekeywas there. A key thatchangeremoved stays removed. -
The key's value. A key that isn't there gives the Map's default, without adding the key, or panics when the Map has none.
-
Gives the key a value, adding it when it isn't there.
-
Whether
keyhas an entry. -
Removes the
key's entry, and tells whether there was one. The others keep their order. -
Removes each entry that
testsays to, and tells how many went. -
Takes every entry out.
-
Makes room for
countentries in all, so adding up to that many doesn't move them again. -
Its keys, in order, in a new array.
-
Its values, in order, in a new array.
-
A new, empty Map.
-
A new Map with the same entries, in the same order, and the same default.
-
A new Map of the entries that
keepsays to keep. -
The first entry that
testsays is the one, or Null. -
Whether
testsays yes for any entry, going no further than the first. -
A new Map of the same keys, in the same order, each with what
changegives for its value. -
Each key and its value, for 'For key, value In map'. Giving a key a new value while going over them is fine, but adding or removing one panics.
MapIterator
struct
Public Struct MapIterator<K: Hashable, V> Implements Iterator<(K, V)>
The entries of a Map, as (key, value), in order, which For ... In goes over.
std/collections/map.fb, line 405
-
The next value, or Null when there are no more.
Doc from
std.core.iterator.Iterator.Next.
Extends
Map
extend
Extend Map<K, V> Implements Equatable
No doc comment.
std/collections/map.fb, line 424
-
Whether
aandbare equal.Doc from
std.core.interfaces.Equatable.Operator==.
Map
extend
Extend Map<K, V> Implements Hashable
No doc comment.
std/collections/map.fb, line 438
-
Its hash, the same for values that are equal.
Doc from
std.core.interfaces.Hashable.Hash.
Map
extend
Extend Map<K, V> Implements Printable
No doc comment.
std/collections/map.fb, line 451
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Report an issue with this page or with FutureBlitz on GitHub.