MCPcopy Create free account
hub / github.com/activeloopai/deeplake / set_bit_iterator

Class set_bit_iterator

cpp/icm/bit_vector.hpp:2069–2138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2067
2068 // Iterator support - custom iterator for bit_vector_view
2069 class set_bit_iterator
2070 {
2071 public:
2072 using iterator_category = std::bidirectional_iterator_tag;
2073 using value_type = int64_t;
2074 using difference_type = int64_t;
2075 using pointer = int64_t*;
2076 using reference = int64_t&;
2077
2078 private:
2079 const bit_vector_view* view_;
2080 int64_t current_position_;
2081
2082 public:
2083 set_bit_iterator(const bit_vector_view* view, bool at_end = false)
2084 : view_(view)
2085 {
2086 if (at_end) {
2087 current_position_ = view_->size();
2088 } else {
2089 current_position_ = view_->find_first_set();
2090 }
2091 }
2092
2093 int64_t operator*() const
2094 {
2095 ASSERT(current_position_ >= 0);
2096 return static_cast<int64_t>(current_position_);
2097 }
2098
2099 set_bit_iterator& operator++()
2100 {
2101 if (current_position_ >= 0) {
2102 current_position_ = view_->find_next_set(static_cast<int64_t>(current_position_));
2103 }
2104 return *this;
2105 }
2106
2107 set_bit_iterator operator++(int)
2108 {
2109 set_bit_iterator tmp = *this;
2110 ++*this;
2111 return tmp;
2112 }
2113
2114 set_bit_iterator& operator--()
2115 {
2116 if (current_position_ >= 0) {
2117 current_position_ = view_->find_prev_set(static_cast<int64_t>(current_position_));
2118 }
2119 return *this;
2120 }
2121
2122 set_bit_iterator operator--(int)
2123 {
2124 set_bit_iterator tmp = *this;
2125 --*this;
2126 return tmp;

Callers

nothing calls this directly

Calls 2

find_next_setMethod · 0.45
find_prev_setMethod · 0.45

Tested by

no test coverage detected