yfast 0.6.1
Loading...
Searching...
No Matches
xfast.h
1#ifndef _YFAST_INTERNAL_XFAST_H
2#define _YFAST_INTERNAL_XFAST_H
3
4#include <yfast/utils/aligned.h>
5
6namespace yfast::internal {
7
8template <typename _Key, typename T>
10 typedef _Key Key;
11
12 const Key key;
13 T* prv;
14 T* nxt;
15};
16
17template <typename Leaf>
18struct XFastNode: private utils::aligned_ptr<2, Leaf> {
19 using utils::aligned_ptr<2, Leaf>::value;
20
21 XFastNode(): utils::aligned_ptr<2, Leaf>() {}
22 XFastNode(std::uintptr_t value): utils::aligned_ptr<2, Leaf>(value) {}
23 XFastNode(Leaf* leaf, bool left_present, bool right_present): utils::aligned_ptr<2, Leaf>(leaf, left_present, right_present) {}
24
25 Leaf* descendant() const { return this->get_ptr(); };
26 [[nodiscard]] bool left_present() const { return this->get_bit(0); };
27 [[nodiscard]] bool right_present() const { return this->get_bit(1); };
28
29 void set_descendant(Leaf* leaf) { this->set_ptr(leaf); };
30 void set_left_present() { this->set_bit(0); };
31 void set_right_present() { this->set_bit(1); };
32 void clear_left_present() { this->clear_bit(0); };
33 void clear_right_present() { this->clear_bit(1); };
34};
35
36}
37
38#endif
Definition xfast.h:9
Definition aligned.h:22