fix iterator bug
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@550 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
d5b4106b7e
commit
3c297d1a66
1 changed files with 7 additions and 5 deletions
|
@ -21,15 +21,16 @@ private:
|
|||
typedef typename MEMTREE::const_iterator MTITER;
|
||||
|
||||
public:
|
||||
memTreeIterator( MEMTREE *s ) : first_(true), it_(s->begin()), itend_(s->end()) { }
|
||||
memTreeIterator( MEMTREE *s, TUPLE &key ) : first_(true), it_(s->find(key)), itend_(s->end()) { }
|
||||
memTreeIterator( MEMTREE *s ) : first_(true), done_(false), it_(s->begin()), itend_(s->end()) { }
|
||||
memTreeIterator( MEMTREE *s, TUPLE &key ) : first_(true), done_(false), it_(s->find(key)), itend_(s->end()) { }
|
||||
|
||||
~memTreeIterator() { }
|
||||
|
||||
TUPLE* getnext() {
|
||||
if(it_==itend_) { return NULL; }
|
||||
if(first_) { first_ = 0;} else { it_++; }
|
||||
TUPLE *t = new TUPLE();
|
||||
if(done_) { return NULL; }
|
||||
if(first_) { first_ = 0;} else { it_++; }
|
||||
if(it_==itend_) { done_= true; return NULL; }
|
||||
TUPLE *t = new TUPLE();
|
||||
t->clone(*it_);
|
||||
return t;
|
||||
}
|
||||
|
@ -41,6 +42,7 @@ private:
|
|||
int operator-(memTreeIterator & t) { abort(); }
|
||||
private:
|
||||
bool first_;
|
||||
bool done_;
|
||||
MTITER it_;
|
||||
MTITER itend_;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue