type

ConcurrentMap

src @Js
const class ConcurrentMap : Obj

ConcurrentMap is a Fantom wrapper around Java's ConcurrentHashMap. It provides high performance concurrency and allows many operations to be performed without locking. Refer to the ConcurrentHashMap Javadoc for the detailed semanatics on behavior and performance.

constructors

make

Make with initial capacity

methods

add

Add a value by key, raise exception if key was already mapped

clear

Remove all the key/value pairs

containsKey

Return true if the specified key is mapped

each

Iterate the map's key value pairs

eachWhile

Iterate the map's key value pairs until given function returns non-null and return that as the result of this method.

get

Get a value by its key or return null

getAndSet

Set a value by key and return old value.

getOrAdd

Get the value for the specified key, or if it doesn't exist then automatically add it with the given default value.

isEmpty

Return if size is zero (this is expensive and requires full segment traveral)

keys

Return list of keys

remove

Remove a value by key, ignore if key not mapped

set

Set a value by key

setAll

Append the specified map to this map be setting every key/value from m in this map.

size

Return size (this is expensive and requires full segment traveral)

vals

Return list of values

Slot Details

add

src Void add(Obj key, Obj val)

Add a value by key, raise exception if key was already mapped

clear

src Void clear()

Remove all the key/value pairs

containsKey

src Bool containsKey(Obj key)

Return true if the specified key is mapped

each

src Void each(|Obj,Obj| f)

Iterate the map's key value pairs

eachWhile

src Obj? eachWhile(|Obj,Obj->Obj?| f)

Iterate the map's key value pairs until given function returns non-null and return that as the result of this method. Otherwise itereate every pair and return null

get

src @Operator
Obj? get(Obj key)

Get a value by its key or return null

getAndSet

src Obj? getAndSet(Obj key, Obj val)

Set a value by key and return old value. Return the old value mapped by the key or null if it is not currently mapped.

getOrAdd

src Obj getOrAdd(Obj key, Obj defVal)

Get the value for the specified key, or if it doesn't exist then automatically add it with the given default value.

isEmpty

src Bool isEmpty()

Return if size is zero (this is expensive and requires full segment traveral)

keys

src Obj[] keys(Type of)

Return list of keys

make

src new make(Int initialCapacity := 256)

Make with initial capacity

remove

src Obj? remove(Obj key)

Remove a value by key, ignore if key not mapped

set

src @Operator
Void set(Obj key, Obj val)

Set a value by key

setAll

src This setAll(Map m)

Append the specified map to this map be setting every key/value from m in this map. Keys in m not yet mapped are added and keys already mapped are overwritten. Return this.

size

src Int size()

Return size (this is expensive and requires full segment traveral)

vals

src Obj[] vals(Type of)

Return list of values