@@ -261,9 +261,11 @@ function symdiff!(s::AbstractSet, itr)
261261 s
262262end
263263
264- == (l:: Set , r:: Set ) = (length (l) == length (r)) && (l <= r)
265- < ( l:: Set , r:: Set ) = (length (l) < length (r)) && (l <= r)
266- <= (l:: Set , r:: Set ) = issubset (l, r)
264+ == (l:: AbstractSet , r:: AbstractSet ) = length (l) == length (r) && l ⊆ r
265+ # convenience functions for AbstractSet
266+ # (if needed, only their synonyms ⊊ and ⊆ must be specialized)
267+ < ( l:: AbstractSet , r:: AbstractSet ) = l ⊊ r
268+ <= (l:: AbstractSet , r:: AbstractSet ) = l ⊆ r
267269
268270"""
269271 issubset(a, b)
@@ -290,21 +292,35 @@ function issubset(l, r)
290292 end
291293 return true
292294end
293-
294295# use the implementation below when it becoms as efficient
295296# issubset(l, r) = all(_in(r), l)
296297
297298const ⊆ = issubset
298- ⊊ (l:: Set , r:: Set ) = < (l, r)
299- ⊈ (l:: Set , r:: Set ) = ! ⊆ (l, r)
300- ⊇ (l, r) = issubset (r, l)
301- ⊉ (l:: Set , r:: Set ) = ! ⊇ (l, r)
302- ⊋ (l:: Set , r:: Set ) = < (r, l)
303299
304- ⊊ (l:: T , r:: T ) where {T<: AbstractSet } = < (l, r)
305- ⊈ (l:: T , r:: T ) where {T<: AbstractSet } = ! ⊆ (l, r)
306- ⊉ (l:: T , r:: T ) where {T<: AbstractSet } = ! ⊇ (l, r)
307- ⊋ (l:: T , r:: T ) where {T<: AbstractSet } = < (r, l)
300+ """
301+ issetequal(a, b)
302+
303+ Determine whether `a` and `b` have the same elements. Equivalent
304+ to `a ⊆ b && b ⊆ a`.
305+
306+ # Examples
307+ ```jldoctest
308+ julia> issetequal([1, 2], [1, 2, 3])
309+ false
310+
311+ julia> issetequal([1, 2], [2, 1])
312+ true
313+ ```
314+ """
315+ issetequal (l, r) = length (l) == length (r) && l ⊆ r
316+ issetequal (l:: AbstractSet , r:: AbstractSet ) = l == r
317+
318+ ⊊ (l, r) = length (l) < length (r) && l ⊆ r
319+ ⊈ (l, r) = ! ⊆ (l, r)
320+
321+ ⊇ (l, r) = r ⊆ l
322+ ⊉ (l, r) = r ⊈ l
323+ ⊋ (l, r) = r ⊊ l
308324
309325"""
310326 unique(itr)
@@ -534,7 +550,7 @@ function mapfilter(pred, f, itr, res)
534550end
535551
536552const hashs_seed = UInt === UInt64 ? 0x852ada37cfe8e0ce : 0xcfe8e0ce
537- function hash (s:: Set , h:: UInt )
553+ function hash (s:: AbstractSet , h:: UInt )
538554 hv = hashs_seed
539555 for x in s
540556 hv ⊻= hash (x)
0 commit comments