RunArray.st
changeset 906 30c1ab2aee8d
parent 904 f4791de2295b
child 966 dd7e0a32bcc1
equal deleted inserted replaced
905:d6fced2d6d12 906:30c1ab2aee8d
   546 
   546 
   547      Transcript showCR:c.   
   547      Transcript showCR:c.   
   548     "
   548     "
   549 
   549 
   550     "Modified: / 30.10.1997 / 14:38:45 / cg"
   550     "Modified: / 30.10.1997 / 14:38:45 / cg"
   551 !
       
   552 
       
   553 size
       
   554     "Answer how many elements the receiver contains.
       
   555      Thsi is not the number of runs (but the simulated number of elements)."
       
   556 
       
   557     |n     "{ Class: SmallInteger }"
       
   558      runSz "{ Class: SmallInteger }"|
       
   559 
       
   560     n := 0.
       
   561     runSz := contentsArray size.
       
   562     1 to:runSz by:2 do:[:i |
       
   563         n := n + (contentsArray at:i)
       
   564     ].
       
   565     ^ n
       
   566 
       
   567     "Modified: 11.5.1996 / 13:34:27 / cg"
       
   568 ! !
   551 ! !
   569 
   552 
   570 !RunArray methodsFor:'adding & removing'!
   553 !RunArray methodsFor:'adding & removing'!
   571 
   554 
   572 add:newObject
   555 add:newObject
  1084     "
  1067     "
  1085 
  1068 
  1086     "Modified: 11.5.1996 / 13:34:53 / cg"
  1069     "Modified: 11.5.1996 / 13:34:53 / cg"
  1087 ! !
  1070 ! !
  1088 
  1071 
       
  1072 !RunArray methodsFor:'queries'!
       
  1073 
       
  1074 size
       
  1075     "Answer how many elements the receiver contains.
       
  1076      Thsi is not the number of runs (but the simulated number of elements)."
       
  1077 
       
  1078     |n     "{ Class: SmallInteger }"
       
  1079      runSz "{ Class: SmallInteger }"|
       
  1080 
       
  1081     n := 0.
       
  1082     runSz := contentsArray size.
       
  1083     1 to:runSz by:2 do:[:i |
       
  1084         n := n + (contentsArray at:i)
       
  1085     ].
       
  1086     ^ n
       
  1087 
       
  1088     "Modified: 11.5.1996 / 13:34:27 / cg"
       
  1089 ! !
       
  1090 
  1089 !RunArray methodsFor:'searching'!
  1091 !RunArray methodsFor:'searching'!
  1090 
  1092 
  1091 findFirst:aBlock
  1093 findFirst:aBlock
  1092     "find the first element, for which evaluation of the argument, aBlock
  1094     "find the first element, for which evaluation of the argument, aBlock
  1093      returns true; return its index or 0 if none detected.
  1095      returns true; return its index or 0 if none detected.
  1246 ! !
  1248 ! !
  1247 
  1249 
  1248 !RunArray class methodsFor:'documentation'!
  1250 !RunArray class methodsFor:'documentation'!
  1249 
  1251 
  1250 version
  1252 version
  1251     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.18 2000-08-22 13:49:22 cg Exp $'
  1253     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.19 2000-08-22 13:57:19 cg Exp $'
  1252 ! !
  1254 ! !