mdds
Loading...
Searching...
No Matches
iterator_node.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3// SPDX-FileCopyrightText: 2021 - 2025 Kohei Yoshida
4//
5// SPDX-License-Identifier: MIT
6
7#pragma once
8
9namespace mdds { namespace detail { namespace mtv {
10
17template<typename ParentT, typename SizeT>
18struct iterator_value_node
19{
20 using parent_type = ParentT;
21 using size_type = SizeT;
22
23 mdds::mtv::element_t type;
24 size_type position;
25 size_type size;
27
28 iterator_value_node(const parent_type* parent, size_type block_index, mdds::mtv::container_id_t container_id)
29 : type(mdds::mtv::element_type_empty), position(0), size(0), data(nullptr),
30 __private_data(parent, block_index, container_id)
31 {}
32
33 void swap(iterator_value_node& other)
34 {
35 std::swap(type, other.type);
36 std::swap(position, other.position);
37 std::swap(size, other.size);
38 std::swap(data, other.data);
39
40 __private_data.swap(other.__private_data);
41 }
42
43 struct private_data
44 {
45 const parent_type* parent;
46 size_type block_index;
47 mdds::mtv::container_id_t container_id;
48
49 private_data() : parent(nullptr), block_index(0), container_id(0)
50 {}
51 private_data(const parent_type* _parent, size_type _block_index, mdds::mtv::container_id_t _container_id)
52 : parent(_parent), block_index(_block_index), container_id(_container_id)
53 {}
54
55 void swap(private_data& other)
56 {
57 std::swap(parent, other.parent);
58 std::swap(block_index, other.block_index);
59 std::swap(container_id, other.container_id);
60 }
61 };
62 private_data __private_data;
63
64 bool operator==(const iterator_value_node& other) const
65 {
66 return type == other.type && position == other.position && size == other.size && data == other.data &&
67 __private_data.parent == other.__private_data.parent &&
68 __private_data.block_index == other.__private_data.block_index;
69 }
70};
71
72template<typename ParentT, typename SizeT>
74{
76
77 static void inc(node_type&)
78 {}
79 static void dec(node_type&)
80 {}
81};
82
83template<typename ParentT, typename SizeT>
85{
87
88 static void inc(node_type& nd)
89 {
90 ++nd.__private_data.block_index;
91 }
92
93 static void dec(node_type& nd)
94 {
95 --nd.__private_data.block_index;
96 }
97};
98
99}}} // namespace mdds::detail::mtv
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition types.hpp:231
Definition iterator_node.hpp:19
Definition iterator_node.hpp:85
Definition iterator_node.hpp:74