-
-
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> AsymmetricPairfunc __array__(this *<$K, $V> LinearMap) *<$K, $V> AsymmetricPairfunc __length__(this *<$K, $V> LinearMap) usizefunc __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> OptionalGets 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) boolReturns whether the linear map has an entry for the given key.
-
func remove(this *<$K, $V> LinearMap, key $K) boolRemoves the first entry for the given key.
Returns whether an entry was removed.
-
func clear(this *<$K, $V> LinearMap) voidClears the linear map.
-
func commit(this *<$K, $V> LinearMap) <$K, $V> LinearMapCommits ownership of a linear map.
Used to transfer ownership of underlying data.
-
func donate(this *<$K, $V> LinearMap) <$K, $V> LinearMapDonates 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> LinearMapGives 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> LinearMapwhere$Kand$Vare clonableClones a linear map.
-
func toOwned(this *<$K, $V> LinearMap) <$K, $V> LinearMapGives away ownership if owned, or clones, in order to give back a linear map that has ownership.
-
func empty() <$K, $V> LinearMapReturns 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) Stringwhere$Kand$VaretoString-ableConverts a linear map to a string.
-
func LinearMap\unsafeFromPOD(elements POD <<$K, $V> AsymmetricPair> List) <$K, $V> LinearMapManually constructs a linear map from a plain-old-data list.