From b7057b59ea0386010209cf2459dd3acca4d02e2c Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 26 Nov 2014 15:40:32 -0500 Subject: [PATCH] lib/collection: improve documentation of `has_all` Signed-off-by: Jean Privat --- lib/standard/collection/abstract_collection.nit | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index 56633ce..9d79de9 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -123,12 +123,18 @@ interface Collection[E] return iterator.item end - # Is the collection contains all the elements of `other`? + # Does the collection contain at least each element of `other`? # - # assert [1,1,1].has_all([1]) == true - # assert [1,1,1].has_all([1,2]) == false # 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[E]): Bool do for x in other do if not has(x) then return false -- 1.7.9.5