RunArray.st
changeset 3593 3476aa995618
parent 3323 f1239164bea5
child 3597 6b1167c90973
equal deleted inserted replaced
3592:ff7df9bc1032 3593:3476aa995618
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  This class is not covered by or part of the ST/X licence.
     4  This class is not covered by or part of the ST/X licence.
     3 
     5 
     4 
     6 
     5  COPYRIGHT.
     7  COPYRIGHT.
    24 	To: goodies-lib@cs.man.ac.uk
    26 	To: goodies-lib@cs.man.ac.uk
    25 	Subject: help 
    27 	Subject: help 
    26 "
    28 "
    27 "{ Package: 'stx:libbasic2' }"
    29 "{ Package: 'stx:libbasic2' }"
    28 
    30 
       
    31 "{ NameSpace: Smalltalk }"
       
    32 
    29 SequenceableCollection subclass:#RunArray
    33 SequenceableCollection subclass:#RunArray
    30 	instanceVariableNames:'contentsArray'
    34 	instanceVariableNames:'contentsArray'
    31 	classVariableNames:''
    35 	classVariableNames:''
    32 	poolDictionaries:''
    36 	poolDictionaries:''
    33 	category:'Collections-Sequenceable'
    37 	category:'Collections-Sequenceable'
   875         ]
   879         ]
   876     ].
   880     ].
   877     ^ true
   881     ^ true
   878 !
   882 !
   879 
   883 
       
   884 contains:aBlock 
       
   885     "Return true, if aBlock returns true for any of the receiver's elements"
       
   886 
       
   887     contentsArray notNil ifTrue:[
       
   888         contentsArray pairWiseDo:[:len :val | 
       
   889             (aBlock value:val) ifTrue:[^ true].
       
   890         ].
       
   891     ].    
       
   892     ^ false
       
   893 !
       
   894 
   880 do:aBlock 
   895 do:aBlock 
   881     "Evaluate aBlock with each of the receiver's elements as the 
   896     "Evaluate aBlock with each of the receiver's elements as the 
   882     argument. "
   897     argument. "
   883 
   898 
   884     contentsArray notNil ifTrue:[
   899     contentsArray notNil ifTrue:[
   889 
   904 
   890     "Modified: / 30.10.1997 / 15:53:37 / cg"
   905     "Modified: / 30.10.1997 / 15:53:37 / cg"
   891 !
   906 !
   892 
   907 
   893 runsDo:aBlock 
   908 runsDo:aBlock 
   894     "Evaluate aBlock with each of the receiver's runs, passing
   909     "Evaluate aBlock with each of the receiver's runs, 
   895      length and value as arguments."
   910      passing length and value as arguments."
   896 
   911 
   897     contentsArray notNil ifTrue:[
   912     contentsArray notNil ifTrue:[
   898         contentsArray pairWiseDo:aBlock
   913         contentsArray pairWiseDo:aBlock
   899     ]
   914     ]
   900 
   915 
   913         contentsArray pairWiseDo:[:count :emp |
   928         contentsArray pairWiseDo:[:count :emp |
   914             aThreeArgBlock value:idx value:(idx+count-1) value:emp     
   929             aThreeArgBlock value:idx value:(idx+count-1) value:emp     
   915         ]
   930         ]
   916     ]
   931     ]
   917 ! !
   932 ! !
       
   933 
   918 
   934 
   919 !RunArray methodsFor:'printing & storing'!
   935 !RunArray methodsFor:'printing & storing'!
   920 
   936 
   921 displayOn:aGCOrStream 
   937 displayOn:aGCOrStream 
   922     "Append to aStream an expression which, if evaluated, will generate   
   938     "Append to aStream an expression which, if evaluated, will generate   
  1380     ^ contentsArray size == 0
  1396     ^ contentsArray size == 0
  1381 
  1397 
  1382     "Modified: 11.5.1996 / 13:35:17 / cg"
  1398     "Modified: 11.5.1996 / 13:35:17 / cg"
  1383 ! !
  1399 ! !
  1384 
  1400 
  1385 
       
  1386 !RunArray class methodsFor:'documentation'!
  1401 !RunArray class methodsFor:'documentation'!
  1387 
  1402 
  1388 version
  1403 version
  1389     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.37 2014-07-10 12:24:08 cg Exp $'
  1404     ^ '$Header$'
  1390 !
  1405 !
  1391 
  1406 
  1392 version_CVS
  1407 version_CVS
  1393     ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.37 2014-07-10 12:24:08 cg Exp $'
  1408     ^ '$Header$'
  1394 ! !
  1409 ! !
  1395 
  1410