6 #include "size_holder.hpp" 7 #include "tree_iterator.hpp" 10 #ifdef YGG_STORE_SEQUENCE 11 #include "benchmark_sequence.hpp" 20 template <
class Node,
class Options = DefaultOptions,
class Tag =
int>
23 namespace ztree_internal {
26 template <
class Tree,
bool enable>
27 struct dbg_verify_size_helper
29 void operator()(
const Tree & t,
size_t node_count);
32 template <
class Node,
class Options,
bool use_hash,
bool store>
33 class ZTreeRankGenerator;
35 template <
class Node,
class Options>
36 class ZTreeRankGenerator<Node, Options, true, false> {
39 static void update_rank(Node & node) noexcept;
40 static int get_rank(
const Node & node) noexcept;
43 template <
class Node,
class Options>
44 class ZTreeRankGenerator<Node, Options, true, true> {
47 static void update_rank(Node & node) noexcept;
48 static size_t get_rank(
const Node & node) noexcept;
51 template <
class,
class,
class>
53 typename Options::ztree_rank_type::type rank;
56 template <
class Node,
class Options>
57 class ZTreeRankGenerator<Node, Options, false, true> {
61 ZTreeRankGenerator(URBG && g);
62 static void update_rank(Node & node) noexcept;
63 static size_t get_rank(
const Node & node) noexcept;
66 template <
class,
class,
class>
68 typename Options::ztree_rank_type::type rank;
71 template <
class Node,
class Options>
72 class ZTreeRankGenerator<Node, Options, false, false> {
76 static_assert(!std::is_class<Node>::value || std::is_class<Node>::value,
77 "If rank-by-hash is not used, ranks must be stored.");
97 template <
class Node,
class Options,
class Tag>
101 size_t get_depth() const noexcept;
116 update_rank() noexcept
118 ztree_internal::ZTreeRankGenerator<
119 Node, Options, Options::ztree_use_hash,
120 Options::ztree_store_rank>::update_rank(*static_cast<Node *>(
this));
124 template <
class,
class,
bool,
bool>
125 friend class ztree_internal::ZTreeRankGenerator;
127 ztree_internal::ZTreeRankGenerator<Node, Options, Options::ztree_use_hash,
128 Options::ztree_store_rank>
132 template <
class Node>
139 void init_zipping(Node * to_be_deleted)
const noexcept {(void)to_be_deleted;};
140 void delete_without_zipping(Node * to_be_deleted)
const noexcept {(void)to_be_deleted;};
141 void before_zip_from_left(Node * left_head)
const noexcept {(void)left_head;};
142 void before_zip_from_right(Node * right_head)
const noexcept {(void)right_head;};
143 void zipping_ended_left_without_tree(Node * prev_left_head)
const noexcept {(void)prev_left_head;};
144 void zipping_ended_right_without_tree(Node * prev_right_head)
const noexcept {(void)prev_right_head;};
145 void before_zip_tree_from_left(Node * left_head)
const noexcept {(void)left_head;};
146 void before_zip_tree_from_right(Node * right_head)
const noexcept {(void)right_head;};
147 void zipping_done(Node * head, Node * tail)
const noexcept {(void)head; (void)tail;}
152 void init_unzipping(Node * to_be_inserted)
const noexcept {(void) to_be_inserted;};
153 void unzip_to_left(Node * n)
const noexcept {(void)n;}
154 void unzip_to_right(Node * n)
const noexcept {(void)n;}
155 void unzip_done(Node * unzip_root, Node * left_spine_end, Node * right_spine_end)
const noexcept
158 (void) left_spine_end;
159 (void) right_spine_end;
190 class Node,
class NodeTraits,
class Options = DefaultOptions,
191 class Tag = int,
class Compare = ygg::utilities::flexible_less,
192 class RankGetter = ztree_internal::ZTreeRankGenerator<
193 Node, Options, Options::ztree_use_hash, Options::ztree_store_rank>>
205 static_assert(std::is_base_of<NB, Node>::value,
206 "Node class not properly derived from node base!");
231 template <
bool reverse>
232 using iterator =
typename TB::template iterator<reverse>;
233 template <
bool reverse>
234 using const_iterator =
typename TB::template const_iterator<reverse>;
250 void insert(Node & node) noexcept;
251 void insert(Node & node, Node & hint) noexcept;
260 void remove(Node & node) CMP_NOEXCEPT(node);
283 template <
class Comparable>
284 utilities::select_type_t<size_t, Node *, Options::stl_erase>
285 erase(
const Comparable & c) CMP_NOEXCEPT(c);
301 template <
bool reverse>
302 utilities::select_type_t<const iterator<reverse>, Node *, Options::stl_erase>
303 erase(
const iterator<reverse> & it) CMP_NOEXCEPT(*it);
306 void dbg_verify()
const;
307 void dbg_print_rank_stats()
const;
317 void dump_to_dot(
const std::string & filename)
const;
320 void unzip(Node & oldn, Node & newn) noexcept;
321 void zip(Node & old_root) noexcept;
324 void dbg_verify_consistency(Node * sub_root, Node * lower_bound,
325 Node * upper_bound)
const;
326 void dbg_verify_size()
const;
328 template <
class NodeNameGetter>
329 void dump_to_dot_base(
const std::string & filename,
330 NodeNameGetter name_getter)
const;
332 template <
class NodeNameGetter>
333 void output_node_base(
const Node * node, std::ofstream & out,
334 NodeNameGetter name_getter)
const;
336 #ifdef YGG_STORE_SEQUENCE 337 typename ygg::utilities::template BenchmarkSequenceStorage<
338 typename Options::SequenceInterface::KeyT>
345 #ifndef YGG_ZIPTREE_CPP 346 #include "ziptree.cpp"
The Zip Tree.
Definition: ziptree.hpp:194
Definition: ziptree.hpp:133
Base class (template) to supply your node class with metainformation.
Definition: ziptree.hpp:21
Definition: rbtree.hpp:18