mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-04 17:58:22 +00:00
Support backwards iteration starting from end().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119871 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a197cba66d
commit
db52566d68
@ -1235,7 +1235,7 @@ public:
|
||||
if (!branched()) {
|
||||
assert(rootOffset && "Cannot decrement begin()");
|
||||
--rootOffset;
|
||||
} else if (treeLeafOffset())
|
||||
} else if (valid() && treeLeafOffset())
|
||||
--treeLeafOffset();
|
||||
else
|
||||
treeDecrement();
|
||||
|
@ -352,6 +352,16 @@ TEST(IntervalMapTest, Branched) {
|
||||
EXPECT_FALSE(I.valid());
|
||||
EXPECT_TRUE(I == map.end());
|
||||
|
||||
// Backwards iteration.
|
||||
for (unsigned i = 99; i; --i) {
|
||||
--I;
|
||||
ASSERT_TRUE(I.valid());
|
||||
EXPECT_EQ(10*i, I.start());
|
||||
EXPECT_EQ(10*i+5, I.stop());
|
||||
EXPECT_EQ(i, *I);
|
||||
}
|
||||
EXPECT_TRUE(I == map.begin());
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user