| Index: src/unique.h
|
| diff --git a/src/unique.h b/src/unique.h
|
| index 8ed26829012c3980139d1a5d71c6d053e70eebe4..8c7c47ed4fc0e3b76778226ba2dd359a73e6472b 100644
|
| --- a/src/unique.h
|
| +++ b/src/unique.h
|
| @@ -275,6 +275,25 @@ class UniqueSet V8_FINAL : public ZoneObject {
|
| return out;
|
| }
|
|
|
| + // Returns a new set representing all elements from this set which are not in
|
| + // that set. O(|this| * |that|).
|
| + UniqueSet<T>* Subtract(const UniqueSet<T>* that, Zone* zone) const {
|
| + if (that->size_ == 0) return this->Copy(zone);
|
| +
|
| + UniqueSet<T>* out = new(zone) UniqueSet<T>(this->size_, zone);
|
| +
|
| + int i = 0, j = 0;
|
| + while (i < this->size_) {
|
| + Unique<T> cand = this->array_[i];
|
| + if (!that->Contains(cand)) {
|
| + out->array_[j++] = cand;
|
| + }
|
| + }
|
| +
|
| + out->size_ = j;
|
| + return out;
|
| + }
|
| +
|
| // Makes an exact copy of this set. O(|this|).
|
| UniqueSet<T>* Copy(Zone* zone) const {
|
| UniqueSet<T>* copy = new(zone) UniqueSet<T>(this->size_, zone);
|
|
|