OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_BIT_VECTOR_H_ | 5 #ifndef RUNTIME_VM_BIT_VECTOR_H_ |
6 #define RUNTIME_VM_BIT_VECTOR_H_ | 6 #define RUNTIME_VM_BIT_VECTOR_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/zone.h" | 10 #include "vm/zone.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 // Bit vector implementation. | 14 // Bit vector implementation. |
15 class BitVector : public ZoneAllocated { | 15 class BitVector : public ZoneAllocated { |
16 public: | 16 public: |
17 // Iterator for the elements of this BitVector. | 17 // Iterator for the elements of this BitVector. |
18 class Iterator : public ValueObject { | 18 class Iterator : public ValueObject { |
19 public: | 19 public: |
20 explicit Iterator(BitVector* target) | 20 explicit Iterator(BitVector* target) |
21 : target_(target), | 21 : target_(target), |
22 bit_index_(-1), | 22 bit_index_(-1), |
23 word_index_(0), | 23 word_index_(0), |
24 current_word_(target->data_[0]) { | 24 current_word_(target->data_[0]) { |
25 ASSERT(target->data_length_ > 0); | 25 ASSERT(target->data_length_ > 0); |
26 Advance(); | 26 Advance(); |
27 } | 27 } |
28 ~Iterator() { } | 28 ~Iterator() {} |
29 | 29 |
30 bool Done() const { return word_index_ >= target_->data_length_; } | 30 bool Done() const { return word_index_ >= target_->data_length_; } |
31 void Advance(); | 31 void Advance(); |
32 | 32 |
33 intptr_t Current() const { | 33 intptr_t Current() const { |
34 ASSERT(!Done()); | 34 ASSERT(!Done()); |
35 return bit_index_; | 35 return bit_index_; |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 intptr_t length_; | 112 intptr_t length_; |
113 intptr_t data_length_; | 113 intptr_t data_length_; |
114 uword* data_; | 114 uword* data_; |
115 | 115 |
116 DISALLOW_COPY_AND_ASSIGN(BitVector); | 116 DISALLOW_COPY_AND_ASSIGN(BitVector); |
117 }; | 117 }; |
118 | 118 |
119 } // namespace dart | 119 } // namespace dart |
120 | 120 |
121 #endif // RUNTIME_VM_BIT_VECTOR_H_ | 121 #endif // RUNTIME_VM_BIT_VECTOR_H_ |
OLD | NEW |