35
36 //------------------------------VectorSet--------------------------------------
37 class VectorSet : public AnyObj {
38 private:
39
40 static const uint word_bits = 5;
41 static const uint bit_mask = 31;
42
43 // Used 32-bit words
44 uint _size;
45 // Allocated words
46 uint _data_size;
47 uint32_t* _data;
48 Arena* _set_arena;
49 ReallocMark _nesting; // Safety checks for arena reallocation
50
51 void init(Arena* arena);
52
53 // Grow vector to required word capacity
54 void maybe_grow(uint new_word_capacity) {
55 if (new_word_capacity >= _size) {
56 grow(new_word_capacity);
57 }
58 }
59 void grow(uint new_word_capacity);
60
61 public:
62 VectorSet();
63 VectorSet(Arena* arena);
64 ~VectorSet() {}
65
66 NONCOPYABLE(VectorSet);
67 VectorSet& operator=(VectorSet&&) = delete;
68 // Allow move constructor for && (eg. capture return of function)
69 VectorSet(VectorSet&&) = default;
70
71 void insert(uint elem);
72 bool is_empty() const;
73 void reset() {
74 _size = 0;
|
35
36 //------------------------------VectorSet--------------------------------------
37 class VectorSet : public AnyObj {
38 private:
39
40 static const uint word_bits = 5;
41 static const uint bit_mask = 31;
42
43 // Used 32-bit words
44 uint _size;
45 // Allocated words
46 uint _data_size;
47 uint32_t* _data;
48 Arena* _set_arena;
49 ReallocMark _nesting; // Safety checks for arena reallocation
50
51 void init(Arena* arena);
52
53 // Grow vector to required word capacity
54 void maybe_grow(uint new_word_capacity) {
55 _nesting.check(_set_arena); // Check if a potential reallocation in the arena is safe
56 if (new_word_capacity >= _size) {
57 grow(new_word_capacity);
58 }
59 }
60 void grow(uint new_word_capacity);
61
62 public:
63 VectorSet();
64 VectorSet(Arena* arena);
65 ~VectorSet() {}
66
67 NONCOPYABLE(VectorSet);
68 VectorSet& operator=(VectorSet&&) = delete;
69 // Allow move constructor for && (eg. capture return of function)
70 VectorSet(VectorSet&&) = default;
71
72 void insert(uint elem);
73 bool is_empty() const;
74 void reset() {
75 _size = 0;
|