Category talk:Wren-set: Difference between revisions
Content added Content deleted
m (→Source code: Added quotes to 'lang' attribute.) |
(→Source code: Added sameDistinct and allDistinct methods to Bag class.) |
||
Line 499: | Line 499: | ||
// as the elements of another Bag and vice versa. |
// as the elements of another Bag and vice versa. |
||
!=(other) { !(this == other) } |
!=(other) { !(this == other) } |
||
// Returns whether or not the distinct elements of this instance are the same |
|||
// as the distinct elements of another Bag and vice versa. |
|||
sameDistinct(other) { |
|||
if (other.type != Bag) Fiber.abort("Argument must be a Bag.") |
|||
if (_m.count != other.count) return false |
|||
for (k in _m.keys) { |
|||
if (!other.contains(k)) return false |
|||
} |
|||
return true |
|||
} |
|||
// Returns whether or not all elements of this instance are distinct. |
|||
allDistinct { _m.values.all { |v| v == 1 } } |
|||
// Returns the string representation of the current instance enclosed in angle brackets |
// Returns the string representation of the current instance enclosed in angle brackets |