17 #ifndef COM_BORA_SOFTWARE__BALAU_CONTAINER__BALAU_TRIE 18 #define COM_BORA_SOFTWARE__BALAU_CONTAINER__BALAU_TRIE 23 #pragma clang diagnostic push 24 #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" 42 private:
class ObjectAdder {
45 std::vector<ObjectAdder> childAdders;
47 ObjectAdder(T && value_, std::vector<ObjectAdder> && childAdders_)
48 :
value(std::move(value_))
49 , childAdders(std::move(childAdders_)) {}
51 public: ObjectAdder(ObjectAdder && ) noexcept =
default;
58 return ObjectAdder(std::move(
value), {});
64 public:
template <
typename ... ObjectAdderT>
65 static ObjectAdder
child(T &&
value, ObjectAdderT && ... childAdder) {
74 public:
template <
typename ... ObjectAdderT>
87 for (
auto & childAdder : childAdders) {
89 children.back().
add(std::move(childAdder.childAdders));
143 match->
value = std::move(value);
191 public:
template <
typename CompareT>
196 match->
value = std::move(value);
219 public:
template <
typename CompareT>
251 public:
template <
typename CompareT,
typename ReplaceT, ReplaceT replace>
256 replace(match->
value, std::move(value));
283 public:
template <
typename CompareT,
typename ReplaceT>
288 replace(match->
value, value);
309 return children.back();
325 return children.back();
375 match->
value = std::move(value);
400 public:
template <
typename CompareT>
430 public:
template <
typename CompareT>
435 match->
value = std::move(value);
464 public:
template <
typename CompareT,
typename ReplaceT>
469 replace(match->
value, value);
498 public:
template <
typename CompareT,
typename ReplaceT>
503 replace(match->
value, std::move(value));
517 for (
size_t m = 0; m < children.size(); m++) {
518 if (children[m].value == value) {
533 for (
size_t m = 0; m < children.size(); m++) {
534 if (children[m].value == value) {
552 public:
template <
typename CompareT>
554 for (
size_t m = 0; m < children.size(); m++) {
555 if (compare(children[m].value, value)) {
573 public:
template <
typename CompareT>
575 for (
size_t m = 0; m < children.size(); m++) {
576 if (compare(children[m].value, value)) {
595 public:
template <
typename U,
typename CompareT>
597 for (
size_t m = 0; m < children.size(); m++) {
598 if (compare(children[m].value, value)) {
617 public:
template <
typename U,
typename CompareT>
619 for (
size_t m = 0; m < children.size(); m++) {
620 if (compare(children[m].value, value)) {
637 for (
size_t m = 0; m < children.size(); m++) {
638 if (children[m].value == value) {
644 return children.back();
656 for (
size_t m = 0; m < children.size(); m++) {
657 if (children[m].value == value) {
663 return children.back();
678 public:
template <
typename U,
typename CompareT>
680 for (
size_t m = 0; m < children.size(); m++) {
681 if (compare(children[m].value, value)) {
687 return children.back();
703 public:
template <
typename U,
typename CompareT,
typename Create>
705 for (
size_t m = 0; m < children.size(); m++) {
706 if (compare(children[m].value, value)) {
712 return children.back();
719 return children[index];
726 return children[index];
733 return children.size();
740 return children.empty();
761 return &children.back();
768 return &children.back();
779 :
value(std::move(rhs.value))
780 , children(std::move(rhs.children)) {}
785 , children(copy.children) {}
791 :
value(std::move(value_)) {}
795 children = copy.children;
801 value = std::move(rhs.value);
802 children = std::move(rhs.children);
808 for (
size_t m = 0; m < toCascade.children.size(); m++) {
814 selfChild->cascadeChildren(childToCascade);
822 private:
template <
typename U>
void cascadeChildren(
ObjectTrieNode<T> & toCascade, U moveFunction) {
823 for (
size_t m = 0; m < toCascade.children.size(); m++) {
828 selfChild->
value = moveFunction(childToCascade.
value);
829 selfChild->cascadeChildren(childToCascade);
836 template <
typename U>
friend class ObjectTrie;
838 private: std::vector<ObjectTrieNode<T>> children;
881 private:
class IteratorNode {
884 public:
size_t index;
886 public: IteratorNode(
ObjectTrieNode<T> * node_,
size_t index_) : node(node_), index(index_) {}
893 : nodeStack(copy.nodeStack) {}
899 nodeStack = copy.nodeStack;
907 if (!nodeStack.size()) {
911 while (nodeStack.size() > 0) {
912 if (nodeStack.back().index < nodeStack.back().node->children.size()) {
913 ++nodeStack.back().index;
914 nodeStack.push_back({ &nodeStack.back().node->children[nodeStack.back().index - 1], 0 });
917 nodeStack.pop_back();
928 return *nodeStack.back().node;
935 return *nodeStack.back().node;
942 return nodeStack.back().node;
949 return nodeStack.back().node;
961 if (nodeStack.size() <= level) {
965 return nodeStack[nodeStack.size() - 1 - level].node;
977 if (nodeStack.size() <= level) {
981 return nodeStack[nodeStack.size() - 1 - level].node;
992 for (
const auto & iteratorNode : nodeStack) {
993 output.emplace_back(iteratorNode.node);
1001 return nodeStack.size() == rhs.nodeStack.size()
1002 && (!nodeStack.size() || nodeStack.back().node == rhs.nodeStack.back().node);
1017 : nodeStack({ IteratorNode(&parent->trieRoot, 0) }) {}
1020 private: std::vector<IteratorNode> nodeStack;
1027 private:
class IteratorNode {
1030 public:
size_t index;
1032 public: IteratorNode(
const ObjectTrieNode<T> * node_,
size_t index_) : node(node_), index(index_) {}
1039 : nodeStack(copy.nodeStack) {}
1045 nodeStack = copy.nodeStack;
1053 if (!nodeStack.size()) {
1057 while (nodeStack.size() > 0) {
1058 if (nodeStack.back().index < nodeStack.back().node->children.size()) {
1059 ++nodeStack.back().index;
1060 nodeStack.push_back({ &nodeStack.back().node->children[nodeStack.back().index - 1], 0 });
1063 nodeStack.pop_back();
1074 return *nodeStack.back().node;
1081 return nodeStack.back().node;
1093 if (nodeStack.size() <= level) {
1097 return nodeStack[nodeStack.size() - 1 - level].node;
1108 for (
const auto & iteratorNode : nodeStack) {
1109 output.emplace_back(iteratorNode.node);
1117 return nodeStack.size() == rhs.nodeStack.size()
1118 && (!nodeStack.size() || nodeStack.back().node == rhs.nodeStack.back().node);
1133 : nodeStack({ IteratorNode(&parent->trieRoot, 0) }) {}
1136 private: std::vector<IteratorNode> nodeStack;
1161 : nodeQueue(copy.nodeQueue) {}
1167 nodeQueue = copy.nodeQueue;
1175 if (!nodeQueue.size()) {
1182 for (
size_t m = 0; m < previous->children.size(); m++) {
1183 nodeQueue.push(&previous->children[m]);
1186 if (!nodeQueue.size()) {
1197 return *nodeQueue.front();
1204 return *nodeQueue.front();
1211 return nodeQueue.front();
1218 return nodeQueue.front();
1225 return nodeQueue.size() == rhs.nodeQueue.size()
1226 && (!nodeQueue.size() || nodeQueue.front() == rhs.nodeQueue.front());
1241 : nodeQueue({ &parent->trieRoot }) {}
1244 private: std::queue<ObjectTrieNode<T> *> nodeQueue;
1255 : nodeQueue(copy.nodeQueue) {}
1261 nodeQueue = copy.nodeQueue;
1269 if (!nodeQueue.size()) {
1276 for (
size_t m = 0; m < previous->children.size(); m++) {
1277 nodeQueue.push(&previous->children[m]);
1280 if (!nodeQueue.size()) {
1291 return *nodeQueue.front();
1298 return nodeQueue.front();
1305 return nodeQueue.size() == rhs.nodeQueue.size()
1306 && (!nodeQueue.size() || nodeQueue.front() == rhs.nodeQueue.front());
1321 : nodeQueue({ &parent->trieRoot }) {}
1324 private: std::queue<const ObjectTrieNode<T> *> nodeQueue;
1338 public:
explicit ObjectTrie(
const T & trieRoot_) : trieRoot(trieRoot_) {}
1362 trieRoot = std::move(rhs.trieRoot);
1370 trieRoot = rhs.trieRoot;
1393 public:
template <
typename ... ObjectAdderT>
1395 auto &
child = trieRoot.addAndReturnChild(std::move(
value));
1407 return trieRoot.
add(value);
1417 return trieRoot.
add(std::move(
value));
1464 public:
template <
typename CompareT>
1481 public:
template <
typename CompareT>
1497 public:
template <
typename CompareT,
typename ReplaceT>
1513 public:
template <
typename CompareT,
typename ReplaceT>
1599 public:
template <
typename CompareT>
1619 public:
template <
typename CompareT>
1639 public:
template <
typename CompareT,
typename ReplaceT>
1659 public:
template <
typename CompareT,
typename ReplaceT>
1668 return trieRoot.children[index];
1675 return trieRoot.children[index];
1682 return trieRoot.children.size();
1689 return trieRoot.children.empty();
1696 return depthBegin();
1702 public: ConstDepthIterator
begin()
const {
1703 return depthBegin();
1716 public: ConstDepthIterator
end()
const {
1724 return DepthIterator(
this);
1731 return ConstDepthIterator(
this);
1738 return DepthIterator::endMarker;
1745 return ConstDepthIterator::endMarker;
1752 return BreadthIterator(
this);
1759 return ConstBreadthIterator(
this);
1766 return BreadthIterator::endMarker;
1773 return ConstBreadthIterator::endMarker;
1789 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
1791 return find(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
1807 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
1809 return find(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
1828 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
1830 if (values.empty()) {
1834 auto iter = values.
begin();
1837 if (!(compare(trieRoot.value, *iter))) {
1846 while (iter != values.end()) {
1847 node = node->template find<U, CompareT>(*iter, compare);
1849 if (node ==
nullptr) {
1875 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
1877 if (values.empty()) {
1881 auto iter = values.
begin();
1884 if (!(compare(trieRoot.value, *iter))) {
1893 while (iter != values.end()) {
1894 node = node->template find<U, CompareT>(*iter, compare);
1896 if (node ==
nullptr) {
1925 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
1927 return findOrAdd(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; });
1951 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
1955 if (values.empty()) {
1959 auto iter = values.
begin();
1961 while (iter != values.end()) {
1962 node = &node->template findOrAddChild<U, CompareT>(*iter, compare);
1994 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT,
typename Create>
1998 if (values.empty()) {
2002 auto iter = values.
begin();
2004 while (iter != values.end()) {
2005 node = &node->template findOrAddChild<U, CompareT>(*iter, compare, create);
2027 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
2029 return findNearest(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
2047 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
2049 return findNearest(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
2070 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
2072 if (values.empty()) {
2076 auto iter = values.
begin();
2081 if (!compare(trieRoot.value, *iter)) {
2086 currentNode = &trieRoot;
2091 while (iter != values.end()) {
2092 nextNode = nodeToSearch->
find(*iter, compare);
2094 if (nextNode ==
nullptr) {
2099 currentNode = nextNode;
2100 nodeToSearch = nextNode;
2124 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
2126 if (values.empty()) {
2130 auto iter = values.
begin();
2135 if (!compare(trieRoot.value, *iter)) {
2140 currentNode = &trieRoot;
2145 while (iter != values.end()) {
2146 nextNode = nodeToSearch->
find(*iter, compare);
2148 if (nextNode ==
nullptr) {
2153 currentNode = nextNode;
2154 nodeToSearch = nextNode;
2175 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
2177 return findNearestLeaf(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
2195 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC>
2197 return findNearestLeaf(values, [] (
auto & lhs,
auto & rhs) {
return lhs == rhs; }, skipRoot);
2218 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
2220 auto node = findNearest(values, compare, skipRoot);
2221 return node !=
nullptr && node->children.empty() ? node :
nullptr;
2242 public:
template <
typename U,
template <
typename ...>
class ContainerT,
typename ... UC,
typename CompareT>
2244 auto node = findNearest(values, compare, skipRoot);
2245 return node !=
nullptr && node->children.empty() ? node :
nullptr;
2258 cascade(toCascade, stdCopyFunction);
2273 cascade(std::move(toCascade), stdMoveFunction);
2287 if (!(trieRoot.value == toCascade.trieRoot.value)) {
2291 trieRoot.value = copyFunction(toCascade.trieRoot.value);
2292 trieRoot.cascadeChildren(toCascade.trieRoot);
2307 if (!(trieRoot.value == toCascade.trieRoot.value)) {
2311 trieRoot.value = moveFunction(toCascade.trieRoot.value);
2312 trieRoot.cascadeChildren(toCascade.trieRoot, moveFunction);
2317 private:
static const T & stdCopyFunction(
const T & in) {
2321 private:
static T && stdMoveFunction(T & in) {
2322 return std::move(in);
2328 template <
typename T>
2331 template <
typename T>
2334 template <
typename T>
2337 template <
typename T>
2343 template <
typename T>
2344 std::ostream & operator << (std::ostream & stream, const ObjectTrie<T> & trie) {
2348 while (iter != end) {
2349 stream << iter->value <<
"\n";
2358 #pragma clang diagnostic pop 2360 #endif // COM_BORA_SOFTWARE__BALAU_CONTAINER__BALAU_TRIE void cascade(ObjectTrie< T > &&toCascade)
Cascades the supplied trie onto this trie, moving the source values.
Definition: ObjectTrie.hpp:2272
const ObjectTrieNode< T > * end() const
Get a const iterator positioned at the end of the vector of children.
Definition: ObjectTrie.hpp:767
DepthIterator(const DepthIterator ©)
Make a copy of the supplied iterator.
Definition: ObjectTrie.hpp:892
bool operator==(const BalauException &lhs, const BalauException &rhs)
Base class comparison function for Balau exceptions.
Definition: BalauException.hpp:112
A depth first iterator for the trie.
Definition: ObjectTrie.hpp:880
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value, CompareT compare, ReplaceT replace)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1660
ObjectTrieNode< T > * findNearestLeaf(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2219
DepthIterator begin()
Get a depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1695
T value
The publicly accessible data contained in the node.
Definition: ObjectTrie.hpp:98
ObjectTrieNode< T > * findNearest(const ContainerT< U, UC ... > &values, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2028
const ObjectTrieNode< T > * find(const T &value, CompareT compare) const
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:574
ObjectTrie(ObjectTrie< T > &&rhs) noexcept
Move a trie.
Definition: ObjectTrie.hpp:1356
static std::vector< T > pushBack()
Create and populate a vector via emplace back of multiple elements (empty case).
Definition: Vectors.hpp:71
ObjectTrieNode< T > & addOrReplace(const T &value, CompareT compare, ReplaceT replace)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:284
DepthIterator end()
Get a depth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1709
ObjectTrieNode< T > & findOrAdd(const ContainerT< U, UC ... > &values)
Descend into the trie, locating matches of the supplied values, or creating them if they do not exist...
Definition: ObjectTrie.hpp:1926
ObjectTrieNode< T > & findOrAddChild(const T &value)
Locates the first child matching the supplied value or creates a one.
Definition: ObjectTrie.hpp:636
ObjectTrieNode< T > & operator[](size_t index)
Get a reference to the specified child.
Definition: ObjectTrie.hpp:718
Various container classes, apart from interprocess containers.
Definition: ArrayBlockingQueue.hpp:25
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1580
bool empty() const
Returns true if the trie is empty.
Definition: ObjectTrie.hpp:1688
A breadth first const iterator for the trie.
Definition: ObjectTrie.hpp:1250
ObjectTrieNode< T > & addAndReturnChild(T &&value)
Append a root node child containing a the supplied data.
Definition: ObjectTrie.hpp:1542
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value, CompareT compare)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:401
size_t count() const
Get the number of children in the root node.
Definition: ObjectTrie.hpp:1681
ObjectTrieNode< T > & addAndReturnChild(const T &value)
Append a child containing a copy of the supplied data.
Definition: ObjectTrie.hpp:307
The node type contained in the object trie.
Definition: ObjectTrie.hpp:40
ObjectTrieNode< T > & addOrReplace(const T &value, CompareT compare)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1465
ConstDepthIterator(const ConstDepthIterator ©)
Make a copy of the supplied iterator.
Definition: ObjectTrie.hpp:1038
ConstDepthIterator depthEnd() const
Get a const depth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1744
ObjectTrieNode< T > & addAndReturnChild(T &&value)
Append a child containing the supplied data.
Definition: ObjectTrie.hpp:323
size_t count() const
Get the number of children in the node.
Definition: ObjectTrie.hpp:732
A breadth first iterator for the trie.
Definition: ObjectTrie.hpp:1156
ObjectTrieNode< T > & findOrAdd(const ContainerT< U, UC ... > &values, CompareT compare)
Descend into the trie, locating matches of the supplied values, or creating them if they do not exist...
Definition: ObjectTrie.hpp:1952
DepthIterator depthEnd()
Get a depth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1737
ObjectTrieNode< T > & add(T &&value, ObjectAdderT &&... childAdder)
Append a list of children to the node.
Definition: ObjectTrie.hpp:75
ObjectTrieNode< T > & addOrReplace(const T &value, CompareT compare, ReplaceT replace)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1498
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1561
ConstBreadthIterator breadthEnd() const
Get a const breadth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1772
ObjectTrieNode< T > * find(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:1829
A depth first const iterator for the trie.
Definition: ObjectTrie.hpp:1026
ObjectTrieNode< T > & findOrAddChild(T &&value)
Locates the first child matching the supplied value or creates a one.
Definition: ObjectTrie.hpp:655
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value, CompareT compare)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1600
ObjectTrieNode< T > & addOrReplace(const T &value)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:164
ObjectTrieNode< T > * find(const T &value, CompareT compare)
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:553
static ObjectAdder child(T &&value)
Add a child of the child being added.
Definition: ObjectTrie.hpp:57
const ObjectTrieNode< T > * find(const U &value, CompareT compare) const
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:618
static ObjectAdder child(T &&value, ObjectAdderT &&... childAdder)
Add a child of the child being added, plus descendants of the child.
Definition: ObjectTrie.hpp:65
ConstDepthIterator depthBegin() const
Get a const depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1730
ObjectTrieNode< T > & addOrReplace(T &&value)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1448
ObjectTrieNode< T > & findOrAddChild(const U &value, CompareT compare)
Locates the first child matching the supplied value or creates one.
Definition: ObjectTrie.hpp:679
ObjectTrieNode< T > & add(std::vector< ObjectAdder > &&childAdders)
Append a vector of children to the node.
Definition: ObjectTrie.hpp:86
bool empty() const
Returns true if the trie node is empty.
Definition: ObjectTrie.hpp:739
ObjectTrieNode< T > & findOrAdd(const ContainerT< U, UC ... > &values, CompareT compare, Create create)
Descend into the trie, locating matches of the supplied values, or creating them if they do not exist...
Definition: ObjectTrie.hpp:1995
ObjectTrieNode< T > & add(T &&value, ObjectAdderT &&... childNode)
Append a child containing the supplied data to the root node, plus children of the new child...
Definition: ObjectTrie.hpp:1394
ObjectTrieNode< T > * findNearestLeaf(const ContainerT< U, UC ... > &values, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2176
const ObjectTrieNode< T > * findNearest(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2125
ObjectTrieNode< T > & addOrReplace(T &&value, CompareT compare)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1482
ObjectTrie(const T &trieRoot_)
Construct the trie by making a copy of the supplied root value.
Definition: ObjectTrie.hpp:1338
ObjectTrieNode< T > & addOrReplace(const T &value, CompareT compare)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:220
BreadthIterator(const BreadthIterator ©)
Make a copy of the supplied iterator.
Definition: ObjectTrie.hpp:1160
const ObjectTrieNode< T > * find(const ContainerT< U, UC ... > &values, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:1808
ConstBreadthIterator(const ConstBreadthIterator ©)
Make a copy of the supplied iterator.
Definition: ObjectTrie.hpp:1254
const ObjectTrieNode< T > * findNearestLeaf(const ContainerT< U, UC ... > &values, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2196
void getAncestors(std::vector< ObjectTrieNode< T > *const > &output) const
Populate the supplied const pointer vector with the node's ancestors and the current node...
Definition: ObjectTrie.hpp:1105
ObjectTrieNode< T > & root()
Get the root node of the trie.
Definition: ObjectTrie.hpp:1377
ObjectTrieNode< T > * begin()
Get a depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:746
const ObjectTrieNode< T > * begin() const
Get a const depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:753
ObjectTrie(const ObjectTrie< T > ©)
Create a trie by copying an existing trie.
Definition: ObjectTrie.hpp:1351
const ObjectTrieNode< T > * find(const T &value) const
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:532
ObjectTrieNode< T > & addAndReturnChild(const T &value)
Append a root node child containing a copy of the supplied data.
Definition: ObjectTrie.hpp:1528
void cascade(const ObjectTrie< T > &toCascade)
Cascades the supplied trie onto this trie, copying the values.
Definition: ObjectTrie.hpp:2257
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value, CompareT compare)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:431
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value, CompareT compare, ReplaceT replace)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1640
const ObjectTrieNode< T > * getAncestor(size_t level) const
Get a const pointer to the nth ancestor of the current node.
Definition: ObjectTrie.hpp:976
ObjectTrieNode< T > * find(const ContainerT< U, UC ... > &values, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:1790
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value, CompareT compare, ReplaceT replace)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:499
ObjectTrieNode< T > & addOrReplace(T &&value, CompareT compare)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:192
ObjectTrieNode< T > * find(const U &value, CompareT compare)
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:596
const ObjectTrieNode< T > * getAncestor(size_t level) const
Get a const pointer to the nth ancestor of the current node.
Definition: ObjectTrie.hpp:1092
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value, CompareT compare)
Append a root node child containing a copy of the supplied data if a child equal to the supplied valu...
Definition: ObjectTrie.hpp:1620
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value, CompareT compare, ReplaceT replace)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:465
ObjectTrieNode< T > & addOrReplaceAndReturnChild(const T &value)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:344
DepthIterator depthBegin()
Get a depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1723
void getAncestors(std::vector< const ObjectTrieNode< T > *> &output) const
Populate the supplied const pointer vector with the node's ancestors and the current node...
Definition: ObjectTrie.hpp:989
ObjectTrieNode< T > & addOrReplace(T &&value, CompareT compare)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:252
ObjectTrieNode< T > * find(const T &value)
Locates the first child matching the supplied value or return nullptr if not found.
Definition: ObjectTrie.hpp:516
ConstDepthIterator const_iterator
Default (depth first) const iterator.
Definition: ObjectTrie.hpp:1151
ObjectTrieNode< T > & addOrReplace(const T &value)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1432
ObjectTrieNode< T > & add(T &&value)
Append a child containing the supplied data.
Definition: ObjectTrie.hpp:108
const ObjectTrieNode< T > & root() const
Get the root node of the trie.
Definition: ObjectTrie.hpp:1384
DepthIterator iterator
Default (depth first) iterator.
Definition: ObjectTrie.hpp:1144
ObjectTrieNode< T > & addOrReplaceAndReturnChild(T &&value)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:371
const ObjectTrieNode< T > * find(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:1876
void cascade(ObjectTrie< T > &&toCascade, U moveFunction)
Cascades the supplied trie onto this trie.
Definition: ObjectTrie.hpp:2306
void cascade(const ObjectTrie< T > &toCascade, U copyFunction)
Cascades the supplied trie onto this trie.
Definition: ObjectTrie.hpp:2286
ObjectTrieNode< T > * findNearest(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true)
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2071
ConstDepthIterator end() const
Get a const depth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1716
ObjectTrieNode< T > & add(const T &value)
Append a child containing a copy of the supplied data to the root node.
Definition: ObjectTrie.hpp:1406
ConstDepthIterator begin() const
Get a const depth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1702
ObjectTrieNode< T > & add(const T &value)
Append a child containing the supplied data.
Definition: ObjectTrie.hpp:121
ObjectTrie(T &&trieRoot_)
Construct the trie by moving the supplied root value.
Definition: ObjectTrie.hpp:1346
const ObjectTrieNode< T > * findNearest(const ContainerT< U, UC ... > &values, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2048
ObjectTrieNode< T > & addOrReplace(T &&value)
Append a child containing the supplied data if a child equal to the supplied value is not present...
Definition: ObjectTrie.hpp:139
ObjectTrieNode< T > & add(T &&value)
Append a child containing the supplied data to the root node.
Definition: ObjectTrie.hpp:1416
const ObjectTrieNode< T > * findNearestLeaf(const ContainerT< U, UC ... > &values, CompareT compare, bool skipRoot=true) const
Descend into the trie, locating matches of the supplied values.
Definition: ObjectTrie.hpp:2243
ObjectTrieNode< T > & findOrAddChild(const U &value, CompareT compare, Create create)
Locates the first child matching the supplied value or creates one.
Definition: ObjectTrie.hpp:704
BreadthIterator breadthBegin()
Get a breadth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1751
ConstBreadthIterator breadthBegin() const
Get a const breadth iterator positioned at the beginning of the trie.
Definition: ObjectTrie.hpp:1758
BreadthIterator breadthEnd()
Get a breadth iterator positioned at the end of the trie.
Definition: ObjectTrie.hpp:1765
ObjectTrieNode< T > & addOrReplace(T &&value, CompareT compare, ReplaceT replace)
Append a child containing the supplied data to the root node if a child equal to the supplied value i...
Definition: ObjectTrie.hpp:1514
ObjectTrieNode< T > * getAncestor(size_t level)
Get a pointer to the nth ancestor of the current node.
Definition: ObjectTrie.hpp:960
An object based trie used for parent-child hierarchies.
Definition: ObjectTrie.hpp:28
ObjectTrieNode< T > * end()
Get an iterator positioned at the end of the vector of children.
Definition: ObjectTrie.hpp:760