Commit 64a6592b authored by David Davidović's avatar David Davidović Committed by Commit Bot

[sync::cleanup] Remove old EnumSet iter interface

https://chromium-review.googlesource.com/c/chromium/src/+/1145066 adds a
new STL-compatible interface to EnumSet and EnumSet::Iterator.

https://chromium-review.googlesource.com/c/chromium/src/+/1145182 and
https://chromium-review.googlesource.com/c/chromium/src/+/1145186 completely
remove usage of the old one.

Due to this, the old interface is not needed anymore.

This refers to the methods EnumSet::First (superseded by EnumSet::begin),
EnumSet::Iterator::Get (superseded by unary operator * for dereferencing) and
EnumSet::Iterator::Inc (superseded by unary operator ++ for incrementing).
Therefore, remove them. EnumSet::Iterator::Good remains because it is used
internally, but its visibility has been changed from public to private to
reflect this.

Bug: 860435
Change-Id: I7d27123cea02701795b6b9d278a3d9556fefc697
Reviewed-on: https://chromium-review.googlesource.com/1146929
Commit-Queue: David Davidović <davidovic@google.com>
Reviewed-by: default avatarvitaliii <vitaliii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584019}
parent 86bdbfd2
......@@ -84,26 +84,6 @@ class EnumSet {
Iterator() : enums_(nullptr), i_(kValueCount) {}
~Iterator() {}
// Copy constructor and assignment welcome.
// Returns true iff the iterator points to an EnumSet and it
// hasn't yet traversed the EnumSet entirely.
bool Good() const { return enums_ && i_ < kValueCount && enums_->test(i_); }
// Returns the value the iterator currently points to. Good()
// must hold.
E Get() const {
DCHECK(Good());
return FromIndex(i_);
}
// Moves the iterator to the next value in the EnumSet. Good()
// must hold. Takes linear time.
void Inc() {
DCHECK(Good());
i_ = FindNext(i_ + 1);
}
bool operator==(const Iterator& other) const { return i_ == other.i_; }
bool operator!=(const Iterator& other) const { return !(*this == other); }
......@@ -134,12 +114,15 @@ class EnumSet {
}
private:
friend Iterator EnumSet::First() const;
friend Iterator EnumSet::begin() const;
explicit Iterator(const EnumBitSet& enums)
: enums_(&enums), i_(FindNext(0)) {}
// Returns true iff the iterator points to an EnumSet and it
// hasn't yet traversed the EnumSet entirely.
bool Good() const { return enums_ && i_ < kValueCount && enums_->test(i_); }
size_t FindNext(size_t i) {
while ((i < kValueCount) && !enums_->test(i)) {
++i;
......@@ -241,8 +224,6 @@ class EnumSet {
size_t Size() const { return enums_.count(); }
// Returns an iterator pointing to the first element (if any).
Iterator First() const { return Iterator(enums_); }
Iterator begin() const { return Iterator(enums_); }
// Returns an iterator that does not point to any element, but to the position
......
......@@ -197,8 +197,8 @@ TEST_F(EnumSetTest, HasAll) {
TEST_F(EnumSetTest, Iterators) {
const TestEnumSet enums1(TEST_3, TEST_4);
TestEnumSet enums2;
for (TestEnumSet::Iterator it = enums1.First(); it.Good(); it.Inc()) {
enums2.Put(it.Get());
for (TestEnumSet::Iterator it = enums1.begin(); it != enums1.end(); it++) {
enums2.Put(*it);
}
EXPECT_EQ(enums2, enums1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment