This commit extends Shuffle class with defined method.
This 'defined' method allows users to check whether a specified
element is specified as a target in Shuffle instruction without
using heavy range call.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
std::set<ElemID> range(void) const;
public:
+ // @brief Return true if a given elem is updated after execution
+ bool defined(const ElemID &dst) const { return _content.find(dst) != _content.end(); }
+
+public:
/**
* Let M be the return of at(N). This means that N-th element in the destination
* bag will be filled with the value of M-th element in the source bag.
EXPECT_NE(range.count(coco::ElemID{2}), 0);
EXPECT_NE(range.count(coco::ElemID{5}), 0);
}
+
+TEST_F(ShuffleTest, defined)
+{
+ auto shuffle = allocate();
+
+ shuffle->insert(coco::ElemID{3}, coco::ElemID{2});
+
+ EXPECT_TRUE(shuffle->defined(coco::ElemID{2}));
+ EXPECT_FALSE(shuffle->defined(coco::ElemID{3}));
+}