Collection.st
branchjv
changeset 20362 fea6b00ed63a
parent 20343 0719a15ae26d
parent 20355 55b551788af6
child 20398 8cb53f870d39
equal deleted inserted replaced
20361:f48f50e335a6 20362:fea6b00ed63a
     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
  4333         aStream nextPutAll:(s contents).
  4331         aStream nextPutAll:(s contents).
  4334     ].
  4332     ].
  4335     aStream nextPut:$)
  4333     aStream nextPut:$)
  4336 
  4334 
  4337     "
  4335     "
  4338      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4336      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4339      (Array new:100000) printOn:Transcript
  4337      (Array new:100000) printOn:Transcript
  4340      (Array new:100000) printOn:Stdout
  4338      (Array new:100000) printOn:Stdout
  4341      (Array new:100000) printString size
  4339      (Array new:100000) printString size
  4342      (Dictionary new at:#hello put:'world';
  4340      (Dictionary new at:#hello put:'world';
  4343                      at:#foo put:'bar'; yourself) printOn:Transcript
  4341                      at:#foo put:'bar'; yourself) printOn:Transcript
  5632 
  5630 
  5633     "Created: / 21-12-2011 / 15:54:08 / cg"
  5631     "Created: / 21-12-2011 / 15:54:08 / cg"
  5634 !
  5632 !
  5635 
  5633 
  5636 capacity
  5634 capacity
  5637     "return the number of elements, that the receiver is
  5635     "return the number of elements, that the receiver is prepared to take. 
  5638      prepared to take. For most collections, this is the actual
  5636      For most collections, this is the actual size. 
  5639      size. However, some have more space preallocated to allow
  5637      However, some have more space preallocated to allow
  5640      for faster adding of elements.
  5638      for faster adding of elements (i.e. there are logical vs. physical sizes).
  5641      Not used by the system; added for ST-80 compatibility."
  5639      Not used by the system; added for ST-80 compatibility."
  5642 
  5640 
  5643     ^ self size
  5641     ^ self size
  5644 !
  5642 !
  5645 
  5643 
  5687 !
  5685 !
  5688 
  5686 
  5689 includesAll:aCollection
  5687 includesAll:aCollection
  5690     "return true if the receiver includes all elements of
  5688     "return true if the receiver includes all elements of
  5691      the argument, aCollection; false if any is missing.
  5689      the argument, aCollection; false if any is missing.
  5692      Notice: this method has O² runtime behavior and may be
  5690      Notice: this method has O² runtime behavior and may be
  5693              slow for big receivers/args.
  5691              slow for big receivers/args.
  5694              Think about using a Set, or Dictionary."
  5692              Think about using a Set, or Dictionary."
  5695 
  5693 
  5696     ^ aCollection conform:[:element | (self includes:element)]
  5694     ^ aCollection conform:[:element | (self includes:element)]
  5697 
  5695 
  5707 includesAny:searchedElementsCollection
  5705 includesAny:searchedElementsCollection
  5708     "return true if the receiver includes any from the argument, aCollection.
  5706     "return true if the receiver includes any from the argument, aCollection.
  5709      Return false if it includes none.
  5707      Return false if it includes none.
  5710      Uses #= (value compare)
  5708      Uses #= (value compare)
  5711      Notice:
  5709      Notice:
  5712         this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
  5710         this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
  5713         Think about using a Set or Dictionary.
  5711         Think about using a Set or Dictionary.
  5714         Some speedup is also possible, by arranging highly
  5712         Some speedup is also possible, by arranging highly
  5715         probable elements towards the beginning of aCollection, to avoid useless searches.
  5713         probable elements towards the beginning of aCollection, to avoid useless searches.
  5716 
  5714 
  5717         Also: I am not sure, if (and if so, at which breakeven),
  5715         Also: I am not sure, if (and if so, at which breakeven),
  5777 includesAnyIdentical:searchedElementsCollection
  5775 includesAnyIdentical:searchedElementsCollection
  5778     "return true, if the receiver includes any from the argument, aCollection.
  5776     "return true, if the receiver includes any from the argument, aCollection.
  5779      Return false if it includes none.
  5777      Return false if it includes none.
  5780      Use identity compare for comparing.
  5778      Use identity compare for comparing.
  5781      Notice:
  5779      Notice:
  5782         this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
  5780         this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
  5783         Think about using a Set or Dictionary.
  5781         Think about using a Set or Dictionary.
  5784         Some speedup is also possible, by arranging highly
  5782         Some speedup is also possible, by arranging highly
  5785         probable elements towards the beginning of aCollection, to avoid useless searches."
  5783         probable elements towards the beginning of aCollection, to avoid useless searches."
  5786 
  5784 
  5787     searchedElementsCollection do:[:element |
  5785     searchedElementsCollection do:[:element |