How I can reorganize my classes? #ifndef PERSISTENTH #define PERSISTENTH #include…
- User
How I can reorganize my classes? #ifndef PERSISTENT_H #define PERSISTENT_H
#include #include #include #include #include
template struct Node { Node* left_child{}; Node* right_child{}; T value{}; };
template <typename KeyType, typename ValueType> struct AA_node { KeyType key{}; ValueType value{}; AA_node<KeyType, ValueType>* left{}; AA_node<KeyType, ValueType>* right{};
codeAA_node(KeyType k, ValueType v) : key(k), value(v), left(nullptr), right(nullptr) {}};
template struct DL_node { T value{}; DL_node* prev{}; DL_node* next{};
code//DL_node(int d) : data(d), prev(nullptr), next(nullptr) {}};
template class PersistentArray { private:
code// base version T* base{}; // size of base version int size{}; // container for roots of versions std::vector<Node<T>*> versions{}; std::vector<std::pair<int, int>> parent_children_relation{}; // recursive function to build tree with leafs as elemnts of _array in [_l..._r] and _node as root of version void buildTree(Node<T>* _node, T* _array, int _left_border, int _right_border); // recursive function to add new version by changing one value in one of previous version void add(Node<T>* _to, Node<T>* _from, int _left_border, int _right_border, int _position, T _new_value); // recursive function to get element of specific node T get(Node<T>* _node, int _left_border, int _right_border, int _position); // recursive function to count leaves in a tree int countLeaves(Node<T>* _node); // print from [_left] to [_right] void printSlice(T* _arr, int _left, int _right);public:
code - Assistant