RunArray.st
changeset 3008 60b373aca4cf
parent 3002 9a77642609b5
child 3117 21453eeba760
equal deleted inserted replaced
3007:778a3c6b9877 3008:60b373aca4cf
   728      'hello' asRunArray = 'hello1' asArray     
   728      'hello' asRunArray = 'hello1' asArray     
   729     "
   729     "
   730 ! !
   730 ! !
   731 
   731 
   732 !RunArray methodsFor:'converting'!
   732 !RunArray methodsFor:'converting'!
       
   733 
       
   734 asArray
       
   735     "return a new array, containing the receiver's elements."
       
   736 
       
   737     |newCollection dstIndex|
       
   738 
       
   739     contentsArray isNil ifTrue:[^ Array new].
       
   740 
       
   741     newCollection := Array new:(self size).
       
   742     dstIndex := 1.
       
   743     contentsArray pairWiseDo:[:len :value |
       
   744         newCollection from:dstIndex to:(dstIndex + len - 1) put:value.
       
   745         dstIndex := dstIndex + len.
       
   746     ].
       
   747     ^ newCollection
       
   748 
       
   749     "
       
   750      |r|
       
   751 
       
   752      r := RunArray withAll:#(1 2 3 3 3 3 4 4 4 5 6 7 7 7 7 7 7 7).
       
   753      Transcript showCR:r.
       
   754      Transcript showCR:r asArray.
       
   755      Transcript showCR:r asRunArray.
       
   756     "
       
   757 !
   733 
   758 
   734 asOrderedCollection
   759 asOrderedCollection
   735     "return a new orderedCollection, containing the receiver's elements."
   760     "return a new orderedCollection, containing the receiver's elements."
   736 
   761 
   737     |newCollection|
   762     |newCollection|
  1329 
  1354 
  1330 
  1355 
  1331 !RunArray class methodsFor:'documentation'!
  1356 !RunArray class methodsFor:'documentation'!
  1332 
  1357 
  1333 version
  1358 version
  1334     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.33 2013-06-03 18:40:19 cg Exp $'
  1359     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.34 2013-06-24 17:53:30 cg Exp $'
  1335 !
  1360 !
  1336 
  1361 
  1337 version_CVS
  1362 version_CVS
  1338     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.33 2013-06-03 18:40:19 cg Exp $'
  1363     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.34 2013-06-24 17:53:30 cg Exp $'
  1339 ! !
  1364 ! !
  1340 
  1365