Есть ли здесь ошибки? template <typename T> struct Node { Node<T>* left_child{};…
- User
Есть ли здесь ошибки? 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 <typename KeyType, typename ValueType> class PersistentAssociativeArray { private: AA_node<KeyType, ValueType>* base{}; std::vector<Node> versions{}; std::vector<Node> key_versions{}; std::vector keys{}; std::vector<std::pair<int, int>> parent_children_relation{};
codetemplate <typename X> void buildTree(Node<X>*, AA_node<KeyType, ValueType>*, int, int); void buildTreeValue(Node<ValueType>*, AA_node<KeyType, ValueType>*, int, int); void buildTreeKey(Node<KeyType>*, AA_node<KeyType, ValueType>*, int, int); template <typename X> void add(Node<X>*, Node<X>*, int, int, int, X); void addValue(Node<ValueType>*, Node<ValueType>*, int, int, int, ValueType); void addKey(Node<KeyType>*, Node<KeyType>*, int, int, int, KeyType); template <typename X> X get(Node<X>*, int, int, int); ValueType getValue(Node<ValueType>*, int, int, int); KeyType getKey(Node<KeyType>*, int, int, int); int countLeaves(Node<ValueType>* _node); AA_node<KeyType, ValueType>* insertRecursive(AA_node<KeyType, ValueType>*, KeyType, ValueType); AA_node<KeyType, ValueType>* searchRecursive(AA_node<KeyType, ValueType>*, KeyType); void inorderRecursive(AA_node<KeyType, ValueType>*); int sizeRecursive(AA_node<KeyType, ValueType>*); void printSliceRecursive(AA_node<KeyType, ValueType>*, int, int);public: PersistentAssociativeArray(AA_node<KeyType, ValueType>); PersistentAssociativeArray(KeyType, ValueType); PersistentAssociativeArray(ValueType, int); ~PersistentAssociativeArray();
- Assistant
В коде нет явных ошибок. Однако, чтобы убедиться в его корректности, необходимо протестировать его функциональность.