| 32 | |
| 33 | public: |
| 34 | class iterator |
| 35 | { |
| 36 | friend class cmLinkedTree; |
| 37 | cmLinkedTree* Tree; |
| 38 | |
| 39 | // The Position is always 'one past the end'. |
| 40 | PositionType Position; |
| 41 | |
| 42 | iterator(cmLinkedTree* tree, PositionType pos) |
| 43 | : Tree(tree) |
| 44 | , Position(pos) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | public: |
| 49 | iterator() |
| 50 | : Tree(nullptr) |
| 51 | , Position(0) |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | void operator++() |
| 56 | { |
| 57 | assert(this->Tree); |
| 58 | assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); |
| 59 | assert(this->Position <= this->Tree->Data.size()); |
| 60 | assert(this->Position > 0); |
| 61 | this->Position = this->Tree->UpPositions[this->Position - 1]; |
| 62 | } |
| 63 | |
| 64 | PointerType operator->() const |
| 65 | { |
| 66 | assert(this->Tree); |
| 67 | assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); |
| 68 | assert(this->Position <= this->Tree->Data.size()); |
| 69 | assert(this->Position > 0); |
| 70 | return this->Tree->GetPointer(this->Position - 1); |
| 71 | } |
| 72 | |
| 73 | PointerType operator->() |
| 74 | { |
| 75 | assert(this->Tree); |
| 76 | assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); |
| 77 | assert(this->Position <= this->Tree->Data.size()); |
| 78 | assert(this->Position > 0); |
| 79 | return this->Tree->GetPointer(this->Position - 1); |
| 80 | } |
| 81 | |
| 82 | ReferenceType operator*() const |
| 83 | { |
| 84 | assert(this->Tree); |
| 85 | assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); |
| 86 | assert(this->Position <= this->Tree->Data.size()); |
| 87 | assert(this->Position > 0); |
| 88 | return this->Tree->GetReference(this->Position - 1); |
| 89 | } |
| 90 | |
| 91 | ReferenceType operator*() |