mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 19:02:35 +00:00
It is allowed to call IntervalMap::const_iterator::advanceTo() with a key that
moves the iterator to end(), and it is valid to call it on end(). That means it is valid to call advanceTo() with any monotonic key sequence. llvm-svn: 122092
This commit is contained in:
parent
900ac27338
commit
f17722908c
@ -1411,6 +1411,8 @@ public:
|
||||
/// The search is started from the current position, and no earlier positions
|
||||
/// can be found. This is much faster than find() for small moves.
|
||||
void advanceTo(KeyT x) {
|
||||
if (!valid())
|
||||
return;
|
||||
if (branched())
|
||||
treeAdvanceTo(x);
|
||||
else
|
||||
|
@ -247,6 +247,12 @@ TEST(IntervalMapTest, RootMultiCoalescing) {
|
||||
EXPECT_EQ(140u, I.start());
|
||||
EXPECT_EQ(150u, I.stop());
|
||||
|
||||
I.advanceTo(200);
|
||||
EXPECT_FALSE(I.valid());
|
||||
|
||||
I.advanceTo(300);
|
||||
EXPECT_FALSE(I.valid());
|
||||
|
||||
// Coalesce left with followers.
|
||||
// [100;110] [120;130] [140;150] [160;170]
|
||||
map.insert(111, 115, 1);
|
||||
@ -520,6 +526,14 @@ TEST(IntervalMapTest, Branched2) {
|
||||
EXPECT_EQ(2000u, I.start());
|
||||
EXPECT_EQ(2005u, I.stop());
|
||||
|
||||
// advanceTo beyond end()
|
||||
I.advanceTo(20000);
|
||||
EXPECT_FALSE(I.valid());
|
||||
|
||||
// end().advanceTo() is valid as long as x > map.stop()
|
||||
I.advanceTo(30000);
|
||||
EXPECT_FALSE(I.valid());
|
||||
|
||||
// Test clear() on branched map.
|
||||
map.clear();
|
||||
EXPECT_TRUE(map.empty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user