Skip to content

LinearMap

Isaac Shelton edited this page Dec 27, 2023 · 2 revisions

LinearMap

LinearMap represents a dumb associative array.

Specifications

Type Size Memory Management Model File
LinearMap 32 bytes Scoped 2.8/LinearMap.adept

Definition

record <$K, $V> LinearMap (elements <<$K, $V> AsymmetricPair> List)

where

$K is able to be checked for equality
$V is any valid type

Fields

Name Type Description
elements <<$K, $V> AsymmetricPair> List List of associations

Value Management Definitions

  • 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)

Memory Management

Elements are freed when the linear map runs out of scope.

Functions

  • func get(this *<$K, $V> LinearMap, key $K) <$V> Optional

    Gets the value associated with a given key.

    [view src]

  • func set(this *<$K, $V> LinearMap, key POD $K, value POD $V)

    Sets the value associated with a given key.

    [view src]

  • func has(this *<$K, $V> LinearMap, key $K) bool

    Returns whether the linear map has an entry for the given key.

    [view src]

  • func remove(this *<$K, $V> LinearMap, key $K) bool

    Removes the first entry for the given key.

    Returns whether an entry was removed.

    [view src]

  • func clear(this *<$K, $V> LinearMap) void

    Clears the linear map.

    [view src]

  • func commit(this *<$K, $V> LinearMap) <$K, $V> LinearMap

    Commits ownership of a linear map.

    Used to transfer ownership of underlying data.

    [view src]

  • 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.

    [view src]

  • 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.

    [view src]

  • func clone(this *<$K, $V> LinearMap) <$K, $V> LinearMap where $K and $V are clonable

    Clones a linear map.

    [view src]

  • 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.

    [view src]

  • func empty() <$K, $V> LinearMap

    Returns an empty linear map.

    Example usage: my_map <String, int> LinearMap = empty() ~> <String, int> LinearMap

    [view src]

  • func toString(map <$K, $V> LinearMap, quote String = "", friendly bool = true) String where $K and $V are toString-able

    Converts a linear map to a string.

    [view src]

  • func LinearMap\unsafeFromPOD(elements POD <<$K, $V> AsymmetricPair> List) <$K, $V> LinearMap

    Manually constructs a linear map from a plain-old-data list.

    [view src]

Clone this wiki locally