Collection.st
changeset 15807 67f21e530e48
parent 15756 c63aea2dcfe5
child 15812 5301a3a03510
equal deleted inserted replaced
15806:62bc6058e34f 15807:67f21e530e48
  1221      First elements-to-remove are collected, then removed in one operation."
  1221      First elements-to-remove are collected, then removed in one operation."
  1222 
  1222 
  1223     |removedElements|
  1223     |removedElements|
  1224 
  1224 
  1225     removedElements := OrderedCollection new.
  1225     removedElements := OrderedCollection new.
  1226     self do:[:element |
  1226     self do:[:eachElement |
  1227         (aBlock value:element) ifTrue: [
  1227         (aBlock value:eachElement) ifTrue: [
  1228             removedElements add:element
  1228             removedElements add:eachElement
  1229         ]
  1229         ]
  1230     ].
  1230     ].
  1231     self removeAll:removedElements.
  1231     self removeAllIdenticalFoundIn:removedElements.
  1232     ^ removedElements
  1232     ^ removedElements
  1233 
  1233 
  1234     "
  1234     "
  1235      |coll|
  1235      |coll|
  1236 
  1236 
  1237      coll := #(1 2 3 4 5 6 7 8 9 10) asOrderedCollection.
  1237      coll := #(1 2 2 3 4 5 6 7 8 9 10) asOrderedCollection.
  1238      coll removeAllSuchThat:[:el | el even].
  1238      coll removeAllSuchThat:[:el | el even].
  1239      coll     
  1239      coll     
  1240     "
  1240     "
       
  1241 
       
  1242     "
       
  1243      |coll bla|
       
  1244 
       
  1245      bla := 'bla' copy.
       
  1246      coll := #(1 'bla' 3 4 5 6 7 8 9 10) asOrderedCollection.
       
  1247      coll add:bla.
       
  1248      coll removeAllSuchThat:[:el | el == bla].
       
  1249      coll     
       
  1250     "
       
  1251 
  1241     "
  1252     "
  1242      |coll|
  1253      |coll|
  1243 
  1254 
  1244      coll := #(1 2 3 4 5 6 7 8 9 10) asSet.
  1255      coll := #(1 2 3 4 5 6 7 8 9 10) asSet.
  1245      coll removeAllSuchThat:[:el | el even].
  1256      coll removeAllSuchThat:[:el | el even].
  1246      coll     
  1257      coll     
  1247     "
  1258     "
  1248 
       
  1249 !
  1259 !
  1250 
  1260 
  1251 removeFirst
  1261 removeFirst
  1252     "remove the first element from the receiver.
  1262     "remove the first element from the receiver.
  1253      Return the removed element."
  1263      Return the removed element."
  4901 ! !
  4911 ! !
  4902 
  4912 
  4903 !Collection class methodsFor:'documentation'!
  4913 !Collection class methodsFor:'documentation'!
  4904 
  4914 
  4905 version
  4915 version
  4906     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.316 2013-09-10 07:35:52 stefan Exp $'
  4916     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.317 2013-11-12 18:17:10 stefan Exp $'
  4907 !
  4917 !
  4908 
  4918 
  4909 version_CVS
  4919 version_CVS
  4910     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.316 2013-09-10 07:35:52 stefan Exp $'
  4920     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.317 2013-11-12 18:17:10 stefan Exp $'
  4911 ! !
  4921 ! !
  4912 
  4922 
  4913 
  4923 
  4914 Collection initialize!
  4924 Collection initialize!