SequenceableCollection.st
changeset 25229 ffb4208adfe8
parent 24895 f29a5574971e
child 25286 25a8dda1990b
equal deleted inserted replaced
25228:90cedbae4e5b 25229:ffb4208adfe8
   438      Abstract subclasses must redefine this again."
   438      Abstract subclasses must redefine this again."
   439 
   439 
   440     ^ self == SequenceableCollection
   440     ^ self == SequenceableCollection
   441 ! !
   441 ! !
   442 
   442 
       
   443 
       
   444 
   443 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   445 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   444 
   446 
   445 allButFirst
   447 allButFirst
   446     "Return a copy of the receiver containing all but the first element.
   448     "Return a copy of the receiver containing all but the first element.
   447      Returns an empty collection if there are not at least two elements.
   449      Returns an empty collection if there are not at least two elements.
   735 !SequenceableCollection methodsFor:'Compatibility-VW'!
   737 !SequenceableCollection methodsFor:'Compatibility-VW'!
   736 
   738 
   737 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   739 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   738     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   740     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   739 ! !
   741 ! !
       
   742 
   740 
   743 
   741 !SequenceableCollection methodsFor:'accessing'!
   744 !SequenceableCollection methodsFor:'accessing'!
   742 
   745 
   743 after:anObject
   746 after:anObject
   744     "return the element, after anObject.
   747     "return the element, after anObject.
  3609      #(1 2 3 4 1 2 3 4) copyReplaceAll:1 withAll:#(9 9 9) 
  3612      #(1 2 3 4 1 2 3 4) copyReplaceAll:1 withAll:#(9 9 9) 
  3610      #(1 2 3 4 1 2 3 4) copyReplaceAll:1 withAll:'one' 
  3613      #(1 2 3 4 1 2 3 4) copyReplaceAll:1 withAll:'one' 
  3611     "
  3614     "
  3612 
  3615 
  3613     "Modified (comment): / 16-11-2016 / 21:35:36 / cg"
  3616     "Modified (comment): / 16-11-2016 / 21:35:36 / cg"
       
  3617 !
       
  3618 
       
  3619 copyReplaceAllForWhich:checkBlock with:newElement
       
  3620     "return a copy of the receiver, where all elements for which checkBlock
       
  3621      returns true will are replaced by newElement."
       
  3622 
       
  3623     ^ (self copyFrom:1) replaceAllForWhich:checkBlock with:newElement
       
  3624 
       
  3625     "
       
  3626      #(1 2 1 3 4 5 1 2 1 2) copyReplaceAllForWhich:[:e | e > 2] with:99
       
  3627      'hello 1234 world' copyReplaceAllForWhich:#isDigit with:$*
       
  3628     "
  3614 !
  3629 !
  3615 
  3630 
  3616 copyReplaceAllSubcollections:subColl with:newColl
  3631 copyReplaceAllSubcollections:subColl with:newColl
  3617     "return a copy of the receiver, with all sequences of subColl replaced
  3632     "return a copy of the receiver, with all sequences of subColl replaced
  3618      by newColl (i.e. slice in the newColl in place of the subColl)."
  3633      by newColl (i.e. slice in the newColl in place of the subColl)."
  8030     ^ 0
  8045     ^ 0
  8031 
  8046 
  8032     "Created: 14.2.1997 / 16:13:03 / cg"
  8047     "Created: 14.2.1997 / 16:13:03 / cg"
  8033 ! !
  8048 ! !
  8034 
  8049 
       
  8050 
  8035 !SequenceableCollection methodsFor:'searching'!
  8051 !SequenceableCollection methodsFor:'searching'!
  8036 
  8052 
  8037 asMapAt:key ifAbsent:exceptionValue
  8053 asMapAt:key ifAbsent:exceptionValue
  8038     "the receiver is interpreted as a collection of alternating keys and values;
  8054     "the receiver is interpreted as a collection of alternating keys and values;
  8039      find key in the receiver and return the corresponding value.
  8055      find key in the receiver and return the corresponding value.