SequenceableCollection.st
changeset 24564 9b1d96485f8f
parent 24487 1de280e2c31f
child 24584 b3a7c24ab1db
equal deleted inserted replaced
24563:dabe24b121db 24564:9b1d96485f8f
       
     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
   205     ^ MissingClassInLiteralArrayErrorSignal
   207     ^ MissingClassInLiteralArrayErrorSignal
   206 
   208 
   207     "Created: / 18.5.1999 / 14:50:04 / cg"
   209     "Created: / 18.5.1999 / 14:50:04 / cg"
   208 ! !
   210 ! !
   209 
   211 
   210 !SequenceableCollection class methodsFor:'instance creation-multiDimensional'!
       
   211 
       
   212 _at:nIndices
       
   213     "this is a synthetic selector, generated by the compiler,
       
   214      if a construct of the form expr[idx...] is parsed.
       
   215      I.e.
       
   216 	Array[n]
       
   217      generates
       
   218 	Array _at: n
       
   219     "
       
   220 
       
   221     ^ self new:nIndices
       
   222 !
       
   223 
       
   224 _at:dim1 at:dim2
       
   225     "this is a synthetic selector, generated by the compiler,
       
   226      if a construct of the form expr[idx...] is parsed.
       
   227      I.e.
       
   228         Array[n,m]
       
   229      generates
       
   230         Array _at:n at:m
       
   231     "
       
   232 
       
   233     "MultiDimensionalArrayAccessor is in package stx:goodies/math/matrix.
       
   234      This method should probably be an extension method of this package"
       
   235 
       
   236     |data|
       
   237 
       
   238     data := self newWithSize:(dim1 * dim2).
       
   239     ^ MultiDimensionalArrayAccessor
       
   240         collection:data
       
   241         dimensions:(Array with:dim1 with:dim2)
       
   242 
       
   243     "Modified (format): / 22-02-2019 / 11:57:05 / Stefan Vogel"
       
   244 !
       
   245 
       
   246 _at:dim1 at:dim2 at:dim3
       
   247     "this is a synthetic selector, generated by the compiler,
       
   248      if a construct of the form expr[idx...] is parsed.
       
   249      I.e.
       
   250         Array[n,m,o]
       
   251      generates
       
   252         Array _at:n at:m at:o
       
   253     "
       
   254 
       
   255     "MultiDimensionalArrayAccessor is in package stx:goodies/math/matrix.
       
   256      This method should probably be an extension method of this package"
       
   257 
       
   258     |data|
       
   259 
       
   260     data := self newWithSize:(dim1 * dim2 * dim3).
       
   261     ^ MultiDimensionalArrayAccessor
       
   262         collection:data
       
   263         dimensions:(Array with:dim1 with:dim2 with:dim3)
       
   264 
       
   265     "Modified (comment): / 22-02-2019 / 11:56:54 / Stefan Vogel"
       
   266 ! !
       
   267 
   212 
   268 !SequenceableCollection class methodsFor:'instance creation-streaming'!
   213 !SequenceableCollection class methodsFor:'instance creation-streaming'!
   269 
   214 
   270 new:newSize streamContents:blockWithArg 
   215 new:newSize streamContents:blockWithArg 
   271     "create a write-stream on an instance of the receiver-class with initial size,
   216     "create a write-stream on an instance of the receiver-class with initial size,
   442      True is returned for SequenceableCollection here; false for subclasses.
   387      True is returned for SequenceableCollection here; false for subclasses.
   443      Abstract subclasses must redefine this again."
   388      Abstract subclasses must redefine this again."
   444 
   389 
   445     ^ self == SequenceableCollection
   390     ^ self == SequenceableCollection
   446 ! !
   391 ! !
   447 
       
   448 
       
   449 
   392 
   450 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   393 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
   451 
   394 
   452 allButFirst
   395 allButFirst
   453     "Return a copy of the receiver containing all but the first element.
   396     "Return a copy of the receiver containing all but the first element.
   739 !SequenceableCollection methodsFor:'Compatibility-VW'!
   682 !SequenceableCollection methodsFor:'Compatibility-VW'!
   740 
   683 
   741 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   684 replaceElementsFrom:start to:stop withArray:anArray startingAt:repStart
   742     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   685     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
   743 ! !
   686 ! !
   744 
       
   745 
   687 
   746 !SequenceableCollection methodsFor:'accessing'!
   688 !SequenceableCollection methodsFor:'accessing'!
   747 
   689 
   748 after:anObject
   690 after:anObject
   749     "return the element, after anObject.
   691     "return the element, after anObject.
  7853     "
  7795     "
  7854 
  7796 
  7855 !
  7797 !
  7856 
  7798 
  7857 keys
  7799 keys
  7858     "return a collection with all keys in the Smalltalk dictionary"
  7800     "return a collection with all keys of the receiver"
  7859 
  7801 
  7860     |sz|
  7802     |sz|
  7861 
  7803 
  7862     sz := self size.
  7804     sz := self size.
  7863     sz == 0 ifTrue:[
  7805     sz == 0 ifTrue:[
  7864 	^ #()
  7806         ^ #()
  7865     ].
  7807     ].
  7866     ^ 1 to:sz
  7808     ^ 1 to:sz
  7867 !
  7809 !
  7868 
  7810 
  7869 lastIndex
  7811 lastIndex
  7894 
  7836 
  7895     ^ 0
  7837     ^ 0
  7896 
  7838 
  7897     "Created: 14.2.1997 / 16:13:03 / cg"
  7839     "Created: 14.2.1997 / 16:13:03 / cg"
  7898 ! !
  7840 ! !
  7899 
       
  7900 
  7841 
  7901 !SequenceableCollection methodsFor:'searching'!
  7842 !SequenceableCollection methodsFor:'searching'!
  7902 
  7843 
  7903 detect:aBlock startingAt:startIndex
  7844 detect:aBlock startingAt:startIndex
  7904     "find the first element, for which evaluation of the argument, aBlock returns true.
  7845     "find the first element, for which evaluation of the argument, aBlock returns true.