#DOCUMENTATION by cg
class: Collection
comment/format in:
#includes:
#includesAny:
#includesAnyIdentical:
#includesIdentical:
--- a/Collection.st Sat Apr 30 15:51:56 2016 +0200
+++ b/Collection.st Sat Apr 30 17:14:06 2016 +0200
@@ -5563,17 +5563,19 @@
"Created: / 21-12-2011 / 15:59:19 / cg"
!
-includes:anElement
- "return true, if an object equal to the argument, anObject is in the list.
+includes:searchedElement
+ "return true, if an element equal to the argument, searchedElement is in the collection.
This compares using #= (i.e. it does not look for the object itself,
instead, one that compares equal).
See #includesIdentical: when identity is asked for.
This is a *very* slow fallback - many subclasses redefine this for performance."
- self do:[:element |
- (anElement = element) ifTrue:[^ true].
+ self do:[:eachElement |
+ (searchedElement = eachElement) ifTrue:[^ true].
].
^ false
+
+ "Modified (format): / 30-04-2016 / 17:10:22 / cg"
!
includesAll:aCollection
@@ -5594,16 +5596,15 @@
"Modified: / 13-10-2006 / 12:54:50 / cg"
!
-includesAny:searchCollection
- "return true, if the the receiver includes any elements of
- the argument, aCollection; false if it includes none.
+includesAny:searchedElementsCollection
+ "return true, if the receiver includes any from the argument, aCollection.
+ Return false if it includes none.
+ Uses #= (value compare)
Notice:
- this method has OČ runtime behavior and may be
- slow for big receivers/args.
+ this method has OČ runtime behavior for some subclasses and may be slow for big receivers/args.
Think about using a Set or Dictionary.
Some speedup is also possible, by arranging highly
- probable elements towards the beginning of aCollection,
- to avoid useless searches.
+ probable elements towards the beginning of aCollection, to avoid useless searches.
Also: I am not sure, if (and if so, at which breakeven),
it is better to reverse the loops, and walk over the receiver's
@@ -5611,12 +5612,12 @@
If the receiver is large, caching effects will definitely favour this.
"
- self size < searchCollection size ifTrue:[
+ self size < searchedElementsCollection size ifTrue:[
self do:[:existingElement |
- (searchCollection includes:existingElement) ifTrue:[^ true].
+ (searchedElementsCollection includes:existingElement) ifTrue:[^ true].
].
] ifFalse:[
- searchCollection do:[:searchedElement |
+ searchedElementsCollection do:[:searchedElement |
(self includes:searchedElement) ifTrue:[^ true].
].
].
@@ -5656,20 +5657,21 @@
].
"
-!
-
-includesAnyIdentical:aCollection
- "return true, if the the receiver includes any elements of
- the argument, aCollection; false if it includes none.
+
+ "Modified (comment): / 30-04-2016 / 17:13:33 / cg"
+!
+
+includesAnyIdentical:searchedElementsCollection
+ "return true, if the receiver includes any from the argument, aCollection.
+ Return false if it includes none.
Use identity compare for comparing.
- Notice: this method has OČ runtime behavior and may be
- slow for big receivers/args.
- Think about using a Set or Dictionary.
- Some speedup is also possible, by arranging highly
- probable elements towards the beginning of aCollection,
- to avoid useless searches."
-
- aCollection do:[:element |
+ Notice:
+ this method has OČ runtime behavior for some subclasses and may be slow for big receivers/args.
+ Think about using a Set or Dictionary.
+ Some speedup is also possible, by arranging highly
+ probable elements towards the beginning of aCollection, to avoid useless searches."
+
+ searchedElementsCollection do:[:element |
(self includesIdentical:element) ifTrue:[^ true].
].
^ false
@@ -5680,18 +5682,22 @@
#(1 2 3 4 5 6 7) includesAnyIdentical:#(7 8 9)
#(1 2 3 4 5 6 7) includesAnyIdentical:#(8 9 10)
"
-!
-
-includesIdentical:anElement
- "return true, if the argument, anObject is in the collection.
+
+ "Modified (comment): / 30-04-2016 / 17:13:38 / cg"
+!
+
+includesIdentical:searchedElement
+ "return true, if the argument, searchedElement is in the collection.
This compares using #== (i.e. object identity).
See #includes: when equality is asked for.
This is a *very* slow fallback - many subclasses redefine this for performance."
- self do:[:element |
- (anElement == element) ifTrue:[^ true].
+ self do:[:eachElement |
+ (searchedElement == eachElement) ifTrue:[^ true].
].
^ false
+
+ "Modified (comment): / 30-04-2016 / 17:10:34 / cg"
!
isCollection
@@ -5877,7 +5883,6 @@
^ aVisitor visitCollection:self with:aParameter
! !
-
!Collection class methodsFor:'documentation'!
version