fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue > Class Template Reference

A ConcurrentDictonary that maps to the appropriate platform version. More...

Public Member Functions

TValue addOrUpdate (TKey key, final TValue addValue)
 Updates a value in the dictionary or adds it if it does not exist. More...
 
TValue addOrUpdate (TKey key, TValue addValue, final fm.liveswitch.IFunction2< TKey, TValue, TValue > updateValueFactory)
 Updates a value in the dictionary or adds it if it does not exist. More...
 
void clear ()
 Clears the dictionary of all items. More...
 
boolean containsKey (TKey key)
 True if the dictionary contains the key. More...
 
int getCount ()
 Gets the number of items in the dictionary. More...
 
boolean getIsEmpty ()
 Gets true if dictionary is empty. More...
 
java.util.Collection< TKey > getKeys ()
 Gets an array of keys. More...
 
TValue getOrAdd (TKey key, final fm.liveswitch.IFunction1< TKey, TValue > valueFactory)
 Gets the value from the dictionary or adds a new one if it does not exist. More...
 
java.util.Collection< TValue > getValues ()
 Gets an array of Values. More...
 
 ManagedConcurrentDictionary ()
 Creates a new instance. More...
 
 ManagedConcurrentDictionary (fm.liveswitch.IFunction1< TKey, String > hashCallback)
 Creates a new ManagedConcurrentDictionary. More...
 
boolean tryAdd (TKey key, TValue value)
 Tries to add a new value to the dictionary. More...
 
boolean tryGetValue (TKey key, fm.liveswitch.Holder< TValue > value)
 Tries to get a value from the dictionary. More...
 
boolean tryRemove (TKey key)
 Tries and removes a value from the dictionary. More...
 
boolean tryRemove (TKey key, fm.liveswitch.Holder< TValue > value)
 Tries and removes a value from the dictionary. More...
 
boolean tryUpdate (TKey key, TValue newValue, TValue comparisonValue)
 Tries to update the value in the dictionary. More...
 

Detailed Description

A ConcurrentDictonary that maps to the appropriate platform version.

Constructor & Destructor Documentation

◆ ManagedConcurrentDictionary() [1/2]

Creates a new instance.

◆ ManagedConcurrentDictionary() [2/2]

Creates a new ManagedConcurrentDictionary.

Parameters
hashCallbackThe hash function to use when the backing dictionary requires the key to be a string.

Member Function Documentation

◆ addOrUpdate() [1/2]

TValue fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.addOrUpdate ( TKey  key,
final TValue  addValue 
)

Updates a value in the dictionary or adds it if it does not exist.

Parameters
keyThe key to use for updating for adding.
addValueThe value to be added for an absent key.

◆ addOrUpdate() [2/2]

TValue fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.addOrUpdate ( TKey  key,
TValue  addValue,
final fm.liveswitch.IFunction2< TKey, TValue, TValue >  updateValueFactory 
)

Updates a value in the dictionary or adds it if it does not exist.

Parameters
keyThe key to use for updating for adding.
addValueThe value to be added for an absent key.
updateValueFactoryThe function to use for generating a value based on an existing key.

◆ clear()

void fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.clear ( )

Clears the dictionary of all items.

◆ containsKey()

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.containsKey ( TKey  key)

True if the dictionary contains the key.

Parameters
keyThe key to check.

◆ getCount()

int fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.getCount ( )

Gets the number of items in the dictionary.

◆ getIsEmpty()

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.getIsEmpty ( )

Gets true if dictionary is empty.

◆ getKeys()

java.util.Collection<TKey> fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.getKeys ( )

Gets an array of keys.

◆ getOrAdd()

TValue fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.getOrAdd ( TKey  key,
final fm.liveswitch.IFunction1< TKey, TValue >  valueFactory 
)

Gets the value from the dictionary or adds a new one if it does not exist.

Parameters
keyThe key to use when adding to the dictionary.
valueFactoryThe Func that will create a value if needed.
Returns
The dictionary value if exist, the value returned by the Func if not.

◆ getValues()

java.util.Collection<TValue> fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.getValues ( )

Gets an array of Values.

◆ tryAdd()

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.tryAdd ( TKey  key,
TValue  value 
)

Tries to add a new value to the dictionary.

Parameters
keyThe key to use when adding.
valueThe value to be added to the dictionary.
Returns
True if added, false if key already exists.

◆ tryGetValue()

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.tryGetValue ( TKey  key,
fm.liveswitch.Holder< TValue >  value 
)

Tries to get a value from the dictionary.

Parameters
keyThey key of the item to get form the dictionary.
valueThe value that was just received or null if failed.
Returns
True if succeeded.

◆ tryRemove() [1/2]

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.tryRemove ( TKey  key)

Tries and removes a value from the dictionary.

Parameters
keyThe key of the item to remove.
Returns
True if successful.

◆ tryRemove() [2/2]

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.tryRemove ( TKey  key,
fm.liveswitch.Holder< TValue >  value 
)

Tries and removes a value from the dictionary.

Parameters
keyThe key of the item to remove.
valueThe value that was just removed.
Returns
True if successful.

◆ tryUpdate()

boolean fm.liveswitch.ManagedConcurrentDictionary< TKey, TValue >.tryUpdate ( TKey  key,
TValue  newValue,
TValue  comparisonValue 
)

Tries to update the value in the dictionary.

Parameters
keyThe key to use when updating.
newValueThe new value.
comparisonValueThe value to compare with the current value in the dictionary.
Returns
True if succeeded.