Collection.st
changeset 24603 154e9e58b45e
parent 24510 e309e5fdf190
child 24611 ce5a30fb0ba3
equal deleted inserted replaced
24602:cf345afadfb0 24603:154e9e58b45e
     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
  3132     "Modified (format): / 20-03-2018 / 14:57:56 / stefan"
  3130     "Modified (format): / 20-03-2018 / 14:57:56 / stefan"
  3133     "Modified (format): / 29-08-2018 / 16:25:39 / Claus Gittinger"
  3131     "Modified (format): / 29-08-2018 / 16:25:39 / Claus Gittinger"
  3134 !
  3132 !
  3135 
  3133 
  3136 do:aBlock
  3134 do:aBlock
  3137     "evaluate the argument, aBlock for each element"
  3135     "evaluate the argument, aBlock for each element.
       
  3136      Return the receiver 
       
  3137      (subclasses should care to also return the receiver, 
       
  3138       in case do: is used in a chain of messages.)"
  3138 
  3139 
  3139     ^ self subclassResponsibility
  3140     ^ self subclassResponsibility
  3140 !
  3141 !
  3141 
  3142 
  3142 do:aBlock inBetweenDo:betweenBlock
  3143 do:aBlock inBetweenDo:betweenBlock
  4973         aStream nextPutAll:(s contents).
  4974         aStream nextPutAll:(s contents).
  4974     ].
  4975     ].
  4975     aStream nextPut:$)
  4976     aStream nextPut:$)
  4976 
  4977 
  4977     "
  4978     "
  4978      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4979      #(1 2 3 'hello' $a $ü) printOn:Transcript
  4979      (Array new:100000) printOn:Transcript
  4980      (Array new:100000) printOn:Transcript
  4980      (Array new:100000) printOn:Stdout
  4981      (Array new:100000) printOn:Stdout
  4981      (Array new:100000) printString size
  4982      (Array new:100000) printString size
  4982      (Dictionary new at:#hello put:'world';
  4983      (Dictionary new at:#hello put:'world';
  4983                      at:#foo put:'bar'; yourself) printOn:Transcript
  4984                      at:#foo put:'bar'; yourself) printOn:Transcript
  5152 
  5153 
  5153 includesAll:aCollection
  5154 includesAll:aCollection
  5154     "return true if the receiver includes all elements of
  5155     "return true if the receiver includes all elements of
  5155      the argument, aCollection; false if any is missing.
  5156      the argument, aCollection; false if any is missing.
  5156      Notice: depending on the concrete collection,
  5157      Notice: depending on the concrete collection,
  5157              this method may have O² runtime behavior,
  5158              this method may have O² runtime behavior,
  5158              and may be slow for big receivers/args.
  5159              and may be slow for big receivers/args.
  5159              Think about using a Set, or Dictionary."
  5160              Think about using a Set, or Dictionary."
  5160 
  5161 
  5161     ^ aCollection conform:[:element | (self includes:element)]
  5162     ^ aCollection conform:[:element | (self includes:element)]
  5162 
  5163 
  5189     "return true if the receiver includes any from the argument, aCollection.
  5190     "return true if the receiver includes any from the argument, aCollection.
  5190      Return false if it includes none.
  5191      Return false if it includes none.
  5191      Uses #= (value compare)
  5192      Uses #= (value compare)
  5192      Notice: 
  5193      Notice: 
  5193         depending on the concrete collection,
  5194         depending on the concrete collection,
  5194         this method may have O² runtime behavior,
  5195         this method may have O² runtime behavior,
  5195         and may be slow for big receivers/args.
  5196         and may be slow for big receivers/args.
  5196         Think about using a Set, or Dictionary.
  5197         Think about using a Set, or Dictionary.
  5197 
  5198 
  5198         Some speedup is also possible, by arranging highly
  5199         Some speedup is also possible, by arranging highly
  5199         probable elements towards the beginning of aCollection, 
  5200         probable elements towards the beginning of aCollection, 
  5271     "return true, if the receiver includes any from the argument, aCollection.
  5272     "return true, if the receiver includes any from the argument, aCollection.
  5272      Return false if it includes none.
  5273      Return false if it includes none.
  5273      Use identity compare for comparing.
  5274      Use identity compare for comparing.
  5274      Notice:
  5275      Notice:
  5275         depending on the concrete collection,
  5276         depending on the concrete collection,
  5276         this method may have O² runtime behavior for some subclasses
  5277         this method may have O² runtime behavior for some subclasses
  5277         and may be slow for big receivers/args.
  5278         and may be slow for big receivers/args.
  5278         Think about using a Set or Dictionary.
  5279         Think about using a Set or Dictionary.
  5279         Some speedup is also possible, by arranging highly
  5280         Some speedup is also possible, by arranging highly
  5280         probable elements towards the beginning of aCollection, to avoid useless searches."
  5281         probable elements towards the beginning of aCollection, to avoid useless searches."
  5281 
  5282