|
|
@ -178,12 +178,14 @@ bool VectorRep::Iterator::Valid() const { |
|
|
|
// Returns the key at the current position.
|
|
|
|
// Returns the key at the current position.
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
const char* VectorRep::Iterator::key() const { |
|
|
|
const char* VectorRep::Iterator::key() const { |
|
|
|
|
|
|
|
assert(sorted_); |
|
|
|
return *cit_; |
|
|
|
return *cit_; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Advances to the next position.
|
|
|
|
// Advances to the next position.
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
void VectorRep::Iterator::Next() { |
|
|
|
void VectorRep::Iterator::Next() { |
|
|
|
|
|
|
|
assert(sorted_); |
|
|
|
if (cit_ == bucket_->end()) { |
|
|
|
if (cit_ == bucket_->end()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -193,6 +195,7 @@ void VectorRep::Iterator::Next() { |
|
|
|
// Advances to the previous position.
|
|
|
|
// Advances to the previous position.
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
void VectorRep::Iterator::Prev() { |
|
|
|
void VectorRep::Iterator::Prev() { |
|
|
|
|
|
|
|
assert(sorted_); |
|
|
|
if (cit_ == bucket_->begin()) { |
|
|
|
if (cit_ == bucket_->begin()) { |
|
|
|
// If you try to go back from the first element, the iterator should be
|
|
|
|
// If you try to go back from the first element, the iterator should be
|
|
|
|
// invalidated. So we set it to past-the-end. This means that you can
|
|
|
|
// invalidated. So we set it to past-the-end. This means that you can
|
|
|
|