File indexing completed on 2025-08-28 08:27:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <algorithm>
0021 #include <array>
0022 #include <bitset>
0023 #include <cassert>
0024 #include <cstdint>
0025 #include <cstring>
0026 #include <memory>
0027 #include <string>
0028 #include <string_view>
0029 #include <type_traits>
0030 #include <utility>
0031 #include <vector>
0032
0033 #include "arrow/buffer.h"
0034 #include "arrow/memory_pool.h"
0035 #include "arrow/result.h"
0036 #include "arrow/type_fwd.h"
0037 #include "arrow/util/bit_util.h"
0038 #include "arrow/util/compare.h"
0039 #include "arrow/util/functional.h"
0040 #include "arrow/util/macros.h"
0041 #include "arrow/util/string_builder.h"
0042 #include "arrow/util/type_traits.h"
0043 #include "arrow/util/visibility.h"
0044
0045 namespace arrow {
0046 namespace internal {
0047
0048
0049
0050 class BitsetStack {
0051 public:
0052 using reference = typename std::vector<bool>::reference;
0053
0054
0055
0056
0057 void Push(int size, bool value) {
0058 offsets_.push_back(bit_count());
0059 bits_.resize(bit_count() + size, value);
0060 }
0061
0062
0063 int TopSize() const {
0064 if (offsets_.size() == 0) return 0;
0065 return bit_count() - offsets_.back();
0066 }
0067
0068
0069 void Pop() {
0070 bits_.resize(offsets_.back());
0071 offsets_.pop_back();
0072 }
0073
0074
0075
0076 bool operator[](int i) const { return bits_[offsets_.back() + i]; }
0077
0078
0079
0080 reference operator[](int i) { return bits_[offsets_.back() + i]; }
0081
0082 private:
0083 int bit_count() const { return static_cast<int>(bits_.size()); }
0084 std::vector<bool> bits_;
0085 std::vector<int> offsets_;
0086 };
0087
0088 }
0089 }