1 #ifndef theplu_yat_utility_ranking_iterator 2 #define theplu_yat_utility_ranking_iterator 28 #include "NodeValue.h" 30 #include <yat/utility/yat_assert.h> 31 #include <boost/iterator/iterator_facade.hpp> 48 :
public boost::iterator_facade<
49 Iterator<T>, const T, std::bidirectional_iterator_tag
54 explicit Iterator(
const NodeBase* node);
55 const NodeBase* node_;
57 friend class boost::iterator_core_access;
58 const T& dereference(
void)
const;
59 bool equal(Iterator other)
const;
66 Iterator<T>::Iterator(
void)
73 Iterator<T>::Iterator(
const NodeBase* node)
81 const T& Iterator<T>::dereference(
void)
const 84 YAT_ASSERT(node_->is_head_node()==
false);
87 return static_cast<const NodeValue<T>*
>(node_)->value();
92 bool Iterator<T>::equal(Iterator<T> other)
const 94 return node_ == other.node_;
99 void Iterator<T>::increment(
void)
102 YAT_ASSERT(!node_->is_head_node());
103 YAT_ASSERT(node_->validate());
107 node_ = node_->right_->left_most();
113 const NodeBase* child = node_;
114 YAT_ASSERT(child->parent_);
115 while (child->is_right_node()) {
116 child = child->parent_;
117 YAT_ASSERT(child->parent_);
118 YAT_ASSERT(child->validate());
121 node_ = child->parent_;
127 void Iterator<T>::decrement(
void)
131 if (node_->is_head_node()) {
132 node_ = node_->left_->right_most();
137 node_ = node_->left_->right_most();
143 const NodeBase* child = node_;
144 YAT_ASSERT(child->parent_);
145 while (child->is_left_node()) {
146 child = child->parent_;
147 YAT_ASSERT(child->parent_);
150 node_ = child->parent_;
The Department of Theoretical Physics namespace as we define it.