-
-
Notifications
You must be signed in to change notification settings - Fork 9
LinearMap
LinearMap
represents a dumb associative array.
Type | Size | Memory Management Model | File |
---|---|---|---|
LinearMap |
32 bytes | Scoped | 2.8/LinearMap.adept |
record <$K, $V> LinearMap (elements <<$K, $V> AsymmetricPair> List)
where
$K is able to be checked for equality
$V is any valid type
Name | Type | Description |
---|---|---|
elements |
<<$K, $V> AsymmetricPair> List | List of associations |
func __access__(this *<$K, $V> LinearMap, index usize) *<$K, $V> AsymmetricPair
func __array__(this *<$K, $V> LinearMap) *<$K, $V> AsymmetricPair
func __length__(this *<$K, $V> LinearMap) usize
func __assign__(this *<$K, $V> LinearMap, other POD <$K, $V> LinearMap)
Elements are freed when the linear map runs out of scope.
-
func get(this *<$K, $V> LinearMap, key $K) <$V> Optional
Gets the value associated with a given key.
-
func set(this *<$K, $V> LinearMap, key POD $K, value POD $V)
Sets the value associated with a given key.
-
func has(this *<$K, $V> LinearMap, key $K) bool
Returns whether the linear map has an entry for the given key.
-
func remove(this *<$K, $V> LinearMap, key $K) bool
Removes the first entry for the given key.
Returns whether an entry was removed.
-
func clear(this *<$K, $V> LinearMap) void
Clears the linear map.
-
func commit(this *<$K, $V> LinearMap) <$K, $V> LinearMap
Commits ownership of a linear map.
Used to transfer ownership of underlying data.
-
func donate(this *<$K, $V> LinearMap) <$K, $V> LinearMap
Donates ownership of a linear map, making the original no longer usable.
Used to transfer ownership of underlying data.
-
func give(this *<$K, $V> LinearMap) <$K, $V> LinearMap
Gives away ownership of a linear map, panics if no ownership to give.
Used to transfer ownership of underlying data.
-
func clone(this *<$K, $V> LinearMap) <$K, $V> LinearMap
where$K
and$V
are clonableClones a linear map.
-
func toOwned(this *<$K, $V> LinearMap) <$K, $V> LinearMap
Gives away ownership if owned, or clones, in order to give back a linear map that has ownership.
-
func empty() <$K, $V> LinearMap
Returns an empty linear map.
Example usage:
my_map <String, int> LinearMap = empty() ~> <String, int> LinearMap
-
func toString(map <$K, $V> LinearMap, quote String = "", friendly bool = true) String
where$K
and$V
aretoString
-ableConverts a linear map to a string.
-
func LinearMap\unsafeFromPOD(elements POD <<$K, $V> AsymmetricPair> List) <$K, $V> LinearMap
Manually constructs a linear map from a plain-old-data list.