Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions include/klee/ADT/ImmutableList.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,10 @@ template <typename T> class ImmutableList {

struct iterator {
const ImmutableListNode *rootNode;
std::unique_ptr<iterator> it;
size_t get;

public:
explicit iterator(const ImmutableListNode *p)
: rootNode(p), it(nullptr), get(0) {
if (rootNode && rootNode->prev.get()) {
it = std::make_unique<iterator>(rootNode->prev.get());
}
}
explicit iterator(const ImmutableListNode *p) : rootNode(p), get(0) {}

bool operator==(const iterator &b) const {
return rootNode == b.rootNode && get == b.get;
Expand All @@ -66,17 +60,16 @@ template <typename T> class ImmutableList {

iterator &operator++() {
++get;
if (get < rootNode->prev_len) {
it->operator++();
}
return *this;
}

const T &operator*() const {
if (get < rootNode->prev_len) {
return **it;
assert(get < rootNode->size() && "Out of bound");
const ImmutableListNode *curNode = rootNode;
while (get < curNode->prev_len) {
curNode = curNode->prev.get();
}
return rootNode->values[get - rootNode->prev_len];
return curNode->values[get - curNode->prev_len];
}

const T &operator->() const { return **this; }
Expand Down