Collection.st
changeset 24722 ca69eab2b18e
parent 24661 910625788077
child 24727 41db8f85cade
equal deleted inserted replaced
24721:09692055554c 24722:ca69eab2b18e
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5               All Rights Reserved
     3               All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   350     "return the signal used to report a nonexisting element."
   348     "return the signal used to report a nonexisting element."
   351 
   349 
   352     ^ ValueNotFoundSignal
   350     ^ ValueNotFoundSignal
   353 ! !
   351 ! !
   354 
   352 
   355 !Collection class methodsFor:'instance creation-streaming'!
   353 !Collection class methodsFor:'instance creation - streaming'!
   356 
   354 
   357 writeStreamClass
   355 writeStreamClass
   358     "the type of stream used in writeStream"
   356     "the type of stream used in writeStream"
   359 
   357 
   360     ^ WriteStream
   358     ^ WriteStream
  4976         aStream nextPutAll:(s contents).
  4974         aStream nextPutAll:(s contents).
  4977     ].
  4975     ].
  4978     aStream nextPut:$)
  4976     aStream nextPut:$)
  4979 
  4977 
  4980     "
  4978     "
  4981      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4979      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4982      (Array new:100000) printOn:Transcript
  4980      (Array new:100000) printOn:Transcript
  4983      (Array new:100000) printOn:Stdout
  4981      (Array new:100000) printOn:Stdout
  4984      (Array new:100000) printString size
  4982      (Array new:100000) printString size
  4985      (Dictionary new at:#hello put:'world';
  4983      (Dictionary new at:#hello put:'world';
  4986                      at:#foo put:'bar'; yourself) printOn:Transcript
  4984                      at:#foo put:'bar'; yourself) printOn:Transcript
  5155 
  5153 
  5156 includesAll:aCollection
  5154 includesAll:aCollection
  5157     "return true if the receiver includes all elements of
  5155     "return true if the receiver includes all elements of
  5158      the argument, aCollection; false if any is missing.
  5156      the argument, aCollection; false if any is missing.
  5159      Notice: depending on the concrete collection,
  5157      Notice: depending on the concrete collection,
  5160              this method may have O(n²) runtime behavior,
  5158              this method may have O(n²) runtime behavior,
  5161              and may be slow for big receivers/args.
  5159              and may be slow for big receivers/args.
  5162              Think about using a Set, or Dictionary."
  5160              Think about using a Set, or Dictionary."
  5163 
  5161 
  5164     ^ aCollection conform:[:element | (self includes:element)]
  5162     ^ aCollection conform:[:element | (self includes:element)]
  5165 
  5163 
  5197     "return true if the receiver includes any from the argument, aCollection.
  5195     "return true if the receiver includes any from the argument, aCollection.
  5198      Return false if it includes none.
  5196      Return false if it includes none.
  5199      Uses #= (value compare)
  5197      Uses #= (value compare)
  5200      Notice: 
  5198      Notice: 
  5201         depending on the concrete collection,
  5199         depending on the concrete collection,
  5202         this method may have O(n²) runtime behavior,
  5200         this method may have O(n²) runtime behavior,
  5203         and may be slow for big receivers/args.
  5201         and may be slow for big receivers/args.
  5204         Think about using a Set, or Dictionary.
  5202         Think about using a Set, or Dictionary.
  5205 
  5203 
  5206         Some speedup is also possible, by arranging highly
  5204         Some speedup is also possible, by arranging highly
  5207         probable elements towards the beginning of aCollection, 
  5205         probable elements towards the beginning of aCollection, 
  5279     "return true, if the receiver includes any from the argument, aCollection.
  5277     "return true, if the receiver includes any from the argument, aCollection.
  5280      Return false if it includes none.
  5278      Return false if it includes none.
  5281      Use identity compare for comparing.
  5279      Use identity compare for comparing.
  5282      Notice:
  5280      Notice:
  5283         depending on the concrete collection,
  5281         depending on the concrete collection,
  5284         this method may have O(n²) runtime behavior for some subclasses
  5282         this method may have O(n²) runtime behavior for some subclasses
  5285         and may be slow for big receivers/args.
  5283         and may be slow for big receivers/args.
  5286         Think about using a Set or Dictionary.
  5284         Think about using a Set or Dictionary.
  5287         Some speedup is also possible, by arranging highly
  5285         Some speedup is also possible, by arranging highly
  5288         probable elements towards the beginning of either collection, to avoid useless searches."
  5286         probable elements towards the beginning of either collection, to avoid useless searches."
  5289 
  5287 
  5306 includesAnyKey:aCollectionOfKeys
  5304 includesAnyKey:aCollectionOfKeys
  5307     "return true if the receiver includes any key from aCollectionOfKeys,
  5305     "return true if the receiver includes any key from aCollectionOfKeys,
  5308      false if none is present.
  5306      false if none is present.
  5309      Notice:
  5307      Notice:
  5310         depending on the concrete collection,
  5308         depending on the concrete collection,
  5311         this method may have O(n²) runtime behavior for some subclasses
  5309         this method may have O(n²) runtime behavior for some subclasses
  5312         and may be slow for big receivers/args.
  5310         and may be slow for big receivers/args.
  5313         Think about using a Set or Dictionary."
  5311         Think about using a Set or Dictionary."
  5314 
  5312 
  5315     ^ aCollectionOfKeys contains:[:element | (self includesKey:element)]
  5313     ^ aCollectionOfKeys contains:[:element | (self includesKey:element)]
  5316 
  5314