assert(sorted) in vector rep

Summary: based on discussion on https://reviews.facebook.net/D36969

Test Plan: will let jenkins do its job

Reviewers: sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D36975
main
Igor Canadi 10 years ago
parent 9da8748016
commit 1983fadcbc
  1. 3
      util/vectorrep.cc

@ -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

Loading…
Cancel
Save