template <typename SequenceT>
typename std::enable_if<!std::is_convertible<SequenceT, T>::value>::type
insert(SequenceT &&Input) {
+ if (std::begin(Input) == std::end(Input))
+ // Nothing to do for an empty input sequence.
+ return;
+
// First pull the input sequence into the vector as a bulk append
// operation.
ptrdiff_t StartIndex = V.size();
V.insert(V.end(), std::begin(Input), std::end(Input));
// Now walk backwards fixing up the index map and deleting any duplicates.
- for (auto i : reverse(seq<ptrdiff_t>(StartIndex, V.size()))) {
+ for (ptrdiff_t i = V.size() - 1; i >= StartIndex; --i) {
auto InsertResult = M.insert({V[i], i});
if (InsertResult.second)
continue;
EXPECT_EQ(7, W.pop_back_val());
EXPECT_EQ(2, W.pop_back_val());
ASSERT_TRUE(W.empty());
+
+ ASSERT_TRUE(W.insert(2));
+ ASSERT_TRUE(W.insert(7));
+ // Inserting an empty sequence does nothing.
+ W.insert(std::vector<int>());
+ EXPECT_EQ(7, W.pop_back_val());
+ EXPECT_EQ(2, W.pop_back_val());
+ ASSERT_TRUE(W.empty());
}
TYPED_TEST(PriorityWorklistTest, EraseIf) {