From 1983fadcbca1ab5fab252220ff8ee7d9f1570c85 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 13 Apr 2015 17:33:24 -0700 Subject: [PATCH] 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 --- util/vectorrep.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/vectorrep.cc b/util/vectorrep.cc index 102c17da2..4e4827aac 100644 --- a/util/vectorrep.cc +++ b/util/vectorrep.cc @@ -178,12 +178,14 @@ bool VectorRep::Iterator::Valid() const { // Returns the key at the current position. // REQUIRES: Valid() const char* VectorRep::Iterator::key() const { + assert(sorted_); return *cit_; } // Advances to the next position. // REQUIRES: Valid() void VectorRep::Iterator::Next() { + assert(sorted_); if (cit_ == bucket_->end()) { return; } @@ -193,6 +195,7 @@ void VectorRep::Iterator::Next() { // Advances to the previous position. // REQUIRES: Valid() void VectorRep::Iterator::Prev() { + assert(sorted_); if (cit_ == bucket_->begin()) { // 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