MCPcopy Create free account
hub / github.com/Gecode/gecode / removeDuplicates

Function removeDuplicates

gecode/int/gcc.cpp:71–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 /// Remove duplicate entries in \a v from both \a v and \a c
70 template<class A>
71 void removeDuplicates(Home home, A& c, IntArgs& v) {
72 typedef typename A::value_type S;
73 typedef std::pair<S,int> P;
74 Region re;
75 P* a = re.alloc<P>(c.size());
76 for (int i=0; i<c.size(); i++)
77 a[i] = P(c[i],v[i]);
78 LessP<S> l;
79 Support::quicksort(a,c.size(),l);
80 A cc;
81 IntArgs vv;
82 int cur = a[0].second-1;
83 for (int i=0; i<c.size(); i++) {
84 if (a[i].second==cur) {
85 cc[cc.size()-1] = unify(home, cc[cc.size()-1], a[i].first);
86 } else {
87 cc << a[i].first;
88 vv << a[i].second;
89 cur = a[i].second;
90 }
91 }
92 re.free<P>(a,c.size());
93 c = cc;
94 v = vv;
95 }
96
97 }
98

Callers 1

countFunction · 0.85

Calls 3

quicksortFunction · 0.85
unifyFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected