return std::find(_set.begin(), _set.end(), index) != _set.end();
}
+void IndexSet::replace(const Index &from, const Index &to)
+{
+ std::replace(_set.begin(), _set.end(), from, to);
+}
+
} // namespace operand
} // namespace graph
} // namespace neurun
const Index &at(IO::Index set_index) const { return _set.at(set_index.asInt()); }
const Index &at(uint32_t index) const { return _set.at(index); }
bool contains(const Index &index) const;
+ void replace(const Index &from, const Index &to);
public:
std::vector<Index>::const_iterator begin(void) const { return _set.begin(); }
using neurun::graph::operand::Index;
using neurun::graph::operand::IndexSet;
-TEST(graph_operand_IndexSet, index_set_test)
+TEST(graph_operand_IndexSet, append)
{
IndexSet iset{0, 2, 4, 8};
ASSERT_TRUE(iset.contains(Index{10}));
ASSERT_FALSE(iset.contains(Index{11}));
}
+
+TEST(graph_operand_IndexSet, replace)
+{
+ IndexSet iset{0, 1, 2, 3};
+
+ iset.replace(Index{1}, Index{9});
+ ASSERT_FALSE(iset.contains(Index{1}));
+ ASSERT_TRUE(iset.contains(Index{9}));
+}