AssociativeMap

AssociativeMap

new AssociativeMap(nameopt)

Description:
  • Implements a macroscopic ersatz of a VSA associative map.

    • An associative map is created adding new key/value pairs of symbol.
    • It is implemented via Bundling and Binding, without using a C++ std::map.
Parameters:
Name Type Attributes Description
name string <optional>

An optional name. By default, a #index unique name is generated.

Methods

add(key, value) → {AssociativeMap}

Description:
  • Adds a new symbol pair to the container.

    • Adding twice the same key/value pair corresponds to adding their belief level tau.
Parameters:
Name Type Description
key Symbol

The symbol key to add or modify.

value Symbol

The symbol value to add.

Returns:

A reference to this associative map, allowing to chain add methods.

Type
AssociativeMap

erase(key) → {AssociativeMap}

Description:
  • Erases a symbol in the container.

Parameters:
Name Type Description
key Symbol

The symbol key to add or modify.

Returns:

A reference to this associative map, allowing to chain add methods.

Type
AssociativeMap

get(key) → {Symbol}

Description:
  • Returns an approximate value of the associative map by unbinding.

    • The result is reduced with respect to binding/unbinding operations.
Parameters:
Name Type Description
key Symbol

The symbol key.

Returns:

value A reference to the stored value, available until program end.

Type
Symbol

get()

Description:
  • Defines an iterator over the associative map symbols, used in a construct of the form:

     for(auto it = associativeMap.Bundling::get().cbegin(); it != associativeMap.Bundling::get().cend(); it++) {
       const Binding& binding = dynamic_cast < const Binding& > (it->second);
       const Symbol& key = binding.y(), value = binding.x();
       ../..
     }
    
Returns:

A const std::map < Symbol* >& reference for associative map iteration.

asString() → {String}

Description:
  • Returns the value as a string.

Returns:

A string of the form { key: value ...}_<belief>, omitting the belief if tau=1, sigma=0.

Type
String