SequenceableCollection.st
changeset 20391 beea43e4a428
parent 20267 2f7863ac4188
child 20398 8cb53f870d39
child 20764 891db338d088
equal deleted inserted replaced
20390:57faf25b3d15 20391:beea43e4a428
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
    85 
    87 
    86     |collection
    88     |collection
    87      sz "{ Class: SmallInteger }"|
    89      sz "{ Class: SmallInteger }"|
    88 
    90 
    89     sz := anArray size.
    91     sz := anArray size.
    90     collection := self newWithSize:sz-1.
    92     collection := self mutableClass newWithSize:sz-1.
    91     2 to:sz do:[:idx| collection at:idx-1 put:(anArray at:idx) decodeAsLiteralArray].
    93     2 to:sz do:[:idx| collection at:idx-1 put:(anArray at:idx) decodeAsLiteralArray].
    92     ^ collection
    94     ^ collection
    93 
    95 
    94     "
    96     "
    95      Array
    97      Array decodeFromLiteralArray:#(Array 1 2 3)
    96         decodeFromLiteralArray:#(Array 1 2 3)
       
    97     "
    98     "
    98 !
    99 !
    99 
   100 
   100 new:size withAll:element
   101 new:size withAll:element
   101     "return a new collection of size, where all elements are
   102     "return a new collection of size, where all elements are
   447      Abstract subclasses must redefine this again."
   448      Abstract subclasses must redefine this again."
   448 
   449 
   449     ^ self == SequenceableCollection
   450     ^ self == SequenceableCollection
   450 ! !
   451 ! !
   451 
   452 
   452 
       
   453 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   453 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   454 
   454 
   455 allButFirst
   455 allButFirst
   456     "Return a copy of the receiver containing all but the first element.
   456     "Return a copy of the receiver containing all but the first element.
   457      Returns an empty collection if there are not at least two elements.
   457      Returns an empty collection if there are not at least two elements.
   759 !SequenceableCollection methodsFor:'Compatibility-VW'!
   759 !SequenceableCollection methodsFor:'Compatibility-VW'!
   760 
   760 
   761 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   761 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   762     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   762     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   763 ! !
   763 ! !
   764 
       
   765 
   764 
   766 !SequenceableCollection methodsFor:'accessing'!
   765 !SequenceableCollection methodsFor:'accessing'!
   767 
   766 
   768 after:anObject
   767 after:anObject
   769     "return the element, after anObject.
   768     "return the element, after anObject.
  7873     ^ 0
  7872     ^ 0
  7874 
  7873 
  7875     "Created: 14.2.1997 / 16:13:03 / cg"
  7874     "Created: 14.2.1997 / 16:13:03 / cg"
  7876 ! !
  7875 ! !
  7877 
  7876 
  7878 
       
  7879 !SequenceableCollection methodsFor:'searching'!
  7877 !SequenceableCollection methodsFor:'searching'!
  7880 
  7878 
  7881 detect:aBlock startingAt:startIndex
  7879 detect:aBlock startingAt:startIndex
  7882     "find the first element, for which evaluation of the argument, aBlock returns true.
  7880     "find the first element, for which evaluation of the argument, aBlock returns true.
  7883      Start the search at startIndex.
  7881      Start the search at startIndex.