1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __macrovsa_List__
#define __macrovsa_List__

#include "AssociativeMap.hpp"
#include "Number.hpp"

namespace macrovsa {
  /**
   * @class List
   * @description Implements a macroscopic ersatz of a VSA chained list.
   * - A chained list is created inserting current-value/next-value pairs of symbol.
   * - It is implemented via [Bundling](./Bundling.html) and [Binding](./Binding.html), without using a C++ `std::list`.
   * @extends AssociativeMap
   */
  class List: public AssociativeMap {
public:

    /**
     * @function add
     * @memberof List
     * @instance
     * @description Inserts a new symbol to the container.
     * - Adding twice the same current-value/next-value pair corresponds to adding their belief level `tau`.
     * @param {uint} current The symbol after which the value is inserted.
     * @param {Symbol} value The symbol value to insert.
     */
    void add(const Symbol& current, const Symbol& value);

    /**
     * @function erase
     * @memberof List
     * @instance
     * @description Erases a symbol in the chained.
     * - Without key argument erases all keys, it is a synonym for clear().
     * - Adding twice the same current-value/next-value pair corresponds to adding their belief level `tau`.
     * @param {Symbol} current The symbol after which the value is inserted.
     * @param {Symbol} value The symbol value to insert.
     */
    virtual void erase(const Symbol& current);

    /**
     * @function getNext
     * @memberof List
     * @instance
     * @description Returns the next element after a given symbol.
     * - It is a simple synonym of the get() function.
     * @param {uint} current The symbol current value next which element is to return.
     * @return {Symbol} value A reference to the stored value, available until program end.
     */
    const Symbol& getNext(const Symbol& current) const;

    /**
     * @function getPrevious
     * @memberof List
     * @instance
     * @description Returns the previous element before a given symbol.
     * - This function is of `O(list size)`, for this implementation, since it must scan the list.
     * @param {uint} current The symbol current value next which element is to returnb.
     * @return {Symbol} value A reference to the stored value, available until program end.
     */
    const Symbol& getPrevious(const Symbol& current) const;
  };
}

#endif