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.

    Extends: Bundling, with all public methods available.

Parameters:
Name Type Attributes Description
name string <optional>

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

Methods

add(key, value)

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.

erase(keyopt)

Description:
  • Erases a symbol in the container.

Parameters:
Name Type Attributes Description
key Symbol <optional>

The symbol key to add or modify.

  • Without key argument erases all keys.

get(key) → {Symbol}

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

    • For a map with >_i B_(y_i) x_i returns
      • x_i if y_i is a map key mapping only one symbol.
      • >_(i_j) x_(i_j) if y_i is a map key mapping several symbols x_(i_j).
      • B(y_i~) >_j B_(y_j) x_j if y_i is not a map key.
Parameters:
Name Type Description
key Symbol | String

The symbol key y_i.

Returns:

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

  • If several values associated to a key, it is returned as a bundling.
Type
Symbol

get()

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

     for(auto it = associativeMap.get().cbegin(); it != associativeMap.get().cend(); it++) {
       const Symbol& key = *(it->second.first);
        for(auto jt = it->second.second.cbegin(); jt != it->second.second.cend(); jt++) {
          const Symbol& value = *(jt->second);
       ../..
     }
    
    • This is NOT a VSA plausible operation (unless another List data structure is used) by a debugging function.
    • A map can have several values for one key, combined in the values bundling.
Returns:

A const std::unordered_map < unsigned int, std::pair < const Symbol *, std::unordered_map < unsigned int, Symbol * >>> & reference for associative map iteration.

getBundling() → {Bundling}

Description:
  • Returns the bundling representation of this associative map.

Returns:

A reference to the bundling representation.

Type
Bundling

getSize() → {uint}

Description:
  • Returns the number of key-value pairs this associative map.

Returns:

The number of key-value pairs.

Type
uint

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

getValue(key) → {Symbol}

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

Parameters:
Name Type Description
key Symbol | String

The symbol key key_i.

Returns:

value A reference to the stored values as a bundling, available until program end.

Type
Symbol

getKey(value) → {Symbol}

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

Parameters:
Name Type Description
value Symbol | String

The symbol value value_i.

Returns:

key A reference to the stored keys as a bundling, available until program end.

Type
Symbol