Category talk:Wren-set: Difference between revisions
→Source code: Bug fix.
(→Source code: Added a Bag class plus couple other minor changes.) |
(→Source code: Bug fix.) |
||
Line 282:
}
// Merges all the elements of another Bag
// increasing values where necessary. A specialized version of 'addAll'.
merge(other) {
if (other.type != Bag
Fiber.abort("Argument must be a Bag
}
for (e in other.distinct) _m[e] = _m.containsKey(e) ? _m[e] + other[e] : other[e]
}
// Removes an element 'e' from the current instance, if it exists and whether distinct
Line 374:
}
// Copies all elements of this instance and another Bag
union(other) {
if (other.type != Bag
Fiber.abort("Argument must be a Bag
}
var b = Bag.new()
Line 385:
}
// Copies all elements which this instance and another Bag
// to a new Bag object.
intersect(other) {
if (other.type != Bag
Fiber.abort("Argument must be a Bag
}
var b = Bag.new()
Line 403:
}
// Copies all elements of this instance which are not elements of another Bag
// to a new Bag object.
except(other) {
if (other.type != Bag
Fiber.abort("Argument must be a Bag
}
var b = Bag.new()
|