#include "coco/ADT/PtrLink.h"
#include <map>
+#include <set>
namespace coco
{
void into(Bag *);
public:
+ // @brief Return a set of elements in the destination bag that Shuffle will update
+ std::set<ElemID> range(void) const;
+
+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.
namespace coco
{
+std::set<ElemID> Shuffle::range(void) const
+{
+ std::set<ElemID> res;
+
+ for (auto it = _content.begin(); it != _content.end(); ++it)
+ {
+ res.insert(it->first);
+ }
+
+ return res;
+}
+
void Shuffle::insert(const ElemID &from, const ElemID &into) { _content[into] = from; }
std::set<Bag *> Shuffle::reads(void) const
ASSERT_NE(mutable_ptr->asShuffle(), nullptr);
ASSERT_EQ(mutable_ptr->asShuffle(), immutable_ptr->asShuffle());
}
+
+TEST_F(ShuffleTest, range)
+{
+ auto shuffle = allocate();
+
+ shuffle->insert(coco::ElemID{3}, coco::ElemID{2});
+ shuffle->insert(coco::ElemID{3}, coco::ElemID{5});
+
+ auto range = shuffle->range();
+
+ EXPECT_EQ(range.size(), 2);
+ EXPECT_NE(range.count(coco::ElemID{2}), 0);
+ EXPECT_NE(range.count(coco::ElemID{5}), 0);
+}