const classafConcurrent::LocalMap

sys::Obj
  afConcurrent::LocalMap

Manages a Map stored in Actor.locals with a unique key.

Note that LocalMaps are lazy; that is, no Map is created or stored in Actor.locals until accessed.

caseInsensitive

Source

const Bool caseInsensitive := false

Configures case sensitivity for maps with Str keys.

LocalMap("name") { it.keyType = Str#; it.caseInsensitive = true }
syntax: fantom
clear

Source

This clear()

Remove all key/value pairs from the map. Return this.

containsKey

Source

Bool containsKey(Obj key)

Returns true if the map contains the given key

def

Source

const Obj? def := null

The default value to use for get when a key isn't mapped.

each

Source

Void each(|Obj?,Obj c)

Call the specified function for every key/value in the map.

get

Source

@Operator
Obj? get(Obj key, Obj? def := this.def)

Returns the value associated with the given key. If key is not mapped, then return the value of the def parameter. If def is omitted it defaults to null.

getOrAdd

Source

Obj? getOrAdd(Obj key, |Obj->Obj? valFunc)

Returns the value associated with the given key. If it doesn't exist then it is added from the value function.

This method is thread safe. valFunc will not be called twice for the same key.

isEmpty

Source

Bool isEmpty()

Return true if size() == 0

keyType

Source

const Type keyType := sys::Obj#

Used to parameterize the backing map. Must be non-nullable.

LocalMap("name") { it.keyType = Int# }
keys

Source

Obj[] keys()

Returns a list of all the mapped keys.

localRef

Source

const LocalRef localRef

The LocalRef this LocalMap wraps.

make

Source

new make(Str name := "LocalMap", |This? f := null)

Makes a LocalMap instance. name is passed to LocalRef.

ordered

Source

const Bool ordered := false

If true the map will maintain the order in which key/value pairs are added.

LocalMap("name") { it.ordered = true }
remove

Source

Obj? remove(Obj key)

Remove the key/value pair identified by the specified key from the map and return the value. If the key was not mapped then return null.

set

Source

@Operator
Void set(Obj key, Obj? item)

Sets the key / value pair, ensuring no data is lost during multi-threaded race conditions. Though the same key may be overridden. Both the key and val must be immutable.

size

Source

Int size()

Get the number of key/value pairs in the map.

toStr

Source

virtual override Str toStr()

Returns a string representation the map.

val

Source

Obj:Obj? val

Gets or sets the thread local map

valType

Source

const Type valType := sys::Obj?#

Used to parameterize the backing map.

LocalMap("name") { it.valType = Str# }
vals

Source

Obj?[] vals()

Returns a list of all the mapped values.