mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[wpiutil] Add reverse/bidirectional iterators to wpi::circular_buffer (#8275)
Use std::reverse_iterator<> to create reverse iterators, make other iterators bidirectional to allow for this. Added unit tests.
This commit is contained in:
@@ -251,4 +251,18 @@ TEST(CircularBufferTest, Iterator) {
|
||||
EXPECT_EQ(values[i], elem);
|
||||
++i;
|
||||
}
|
||||
|
||||
// reverse_iterator
|
||||
i = 2;
|
||||
for (auto it = queue.rbegin(); it != queue.rend(); ++it) {
|
||||
EXPECT_EQ(values[i], *it);
|
||||
--i;
|
||||
}
|
||||
|
||||
// const_reverse_iterator
|
||||
i = 2;
|
||||
for (auto it = queue.crbegin(); it != queue.crend(); ++it) {
|
||||
EXPECT_EQ(values[i], *it);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,4 +145,18 @@ TEST(StaticCircularBufferTest, Iterator) {
|
||||
EXPECT_EQ(values[i], elem);
|
||||
++i;
|
||||
}
|
||||
|
||||
// reverse_iterator
|
||||
i = 2;
|
||||
for (auto it = queue.rbegin(); it != queue.rend(); ++it) {
|
||||
EXPECT_EQ(values[i], *it);
|
||||
--i;
|
||||
}
|
||||
|
||||
// const_reverse_iterator
|
||||
i = 2;
|
||||
for (auto it = queue.crbegin(); it != queue.crend(); ++it) {
|
||||
EXPECT_EQ(values[i], *it);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user