Does the collection contain at least each element of other?

assert [1,3,4,2].has_all([1..2])    == true
assert [1,3,4,2].has_all([1..5])    == false

Repeated elements in the collections are not considered.

assert [1,1,1].has_all([1])         == true
assert [1..5].has_all([1,1,1])      == true

Note that the default implementation is general and correct for any lawful Collections. It is memory-efficient but relies on has so may be CPU-inefficient for some kind of collections.

Property definitions

core $ Collection :: has_all
	# Does the collection contain at least each element of `other`?
	#
	#     assert [1,3,4,2].has_all([1..2])    == true
	#     assert [1,3,4,2].has_all([1..5])    == false
	#
	# Repeated elements in the collections are not considered.
	#
	#     assert [1,1,1].has_all([1])         == true
	#     assert [1..5].has_all([1,1,1])      == true
	#
	# Note that the default implementation is general and correct for any lawful Collections.
	# It is memory-efficient but relies on `has` so may be CPU-inefficient for some kind of collections.
	fun has_all(other: Collection[nullable Object]): Bool
	do
		if is_same_instance(other) then return true
		var ol = other.length
		var  l = length
		if ol == 0 then return true
		if l == 0 then return false
		if ol == 1 then return has(other.first)
		for x in other do if not has(x) then return false
		return true
	end
lib/core/collection/abstract_collection.nit:138,2--160,4

pthreads $ ConcurrentCollection :: has_all
	redef fun has_all(e)
	do
		mutex.lock
		var r = real_collection.has_all(e)
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:108,2--114,4