| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #pragma once |
|
|
| #include <algorithm> |
| #include <array> |
| #include <bitset> |
| #include <cassert> |
| #include <cstdint> |
| #include <cstring> |
| #include <memory> |
| #include <string> |
| #include <string_view> |
| #include <type_traits> |
| #include <utility> |
| #include <vector> |
|
|
| #include "arrow/buffer.h" |
| #include "arrow/memory_pool.h" |
| #include "arrow/result.h" |
| #include "arrow/type_fwd.h" |
| #include "arrow/util/bit_util.h" |
| #include "arrow/util/compare.h" |
| #include "arrow/util/functional.h" |
| #include "arrow/util/macros.h" |
| #include "arrow/util/string_builder.h" |
| #include "arrow/util/type_traits.h" |
| #include "arrow/util/visibility.h" |
|
|
| namespace arrow { |
| namespace internal { |
|
|
| |
| |
| class BitsetStack { |
| public: |
| using reference = typename std::vector<bool>::reference; |
|
|
| |
| |
| |
| void Push(int size, bool value) { |
| offsets_.push_back(bit_count()); |
| bits_.resize(bit_count() + size, value); |
| } |
|
|
| |
| int TopSize() const { |
| if (offsets_.size() == 0) return 0; |
| return bit_count() - offsets_.back(); |
| } |
|
|
| |
| void Pop() { |
| bits_.resize(offsets_.back()); |
| offsets_.pop_back(); |
| } |
|
|
| |
| |
| bool operator[](int i) const { return bits_[offsets_.back() + i]; } |
|
|
| |
| |
| reference operator[](int i) { return bits_[offsets_.back() + i]; } |
|
|
| private: |
| int bit_count() const { return static_cast<int>(bits_.size()); } |
| std::vector<bool> bits_; |
| std::vector<int> offsets_; |
| }; |
|
|
| } |
| } |
|
|