RunArray.st
author Claus Gittinger <cg@exept.de>
Sat, 18 May 1996 17:33:04 +0200
changeset 350 93d5932c76e6
parent 334 023ca84ef961
child 352 e6902ee52702
permissions -rw-r--r--
showCr: -> showCR:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 This class is not covered by or part of the ST/X licence.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 COPYRIGHT.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 The above file is a Manchester Goodie protected by copyright.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 These conditions are imposed on the whole Goodie, and on any significant
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 part of it which is separately transmitted or stored:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	* You must ensure that every copy includes this notice, and that
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	  source and author(s) of the material are acknowledged.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	* These conditions must be imposed on anyone who receives a copy.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
	* The material shall not be used for commercial gain without the prior
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
	  written consent of the author(s).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
 Further information on the copyright conditions may be obtained by
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
 sending electronic mail:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	To: goodies-lib@cs.man.ac.uk
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	Subject: copyright
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
 or by writing to The Smalltalk Goodies Library Manager, Dept of
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
 Computer Science, The University, Manchester M13 9PL, UK
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
 (C) Copyright 1993 University of Manchester
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
 For more information about the Manchester Goodies Library (from which 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
 this file was distributed) send e-mail:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	To: goodies-lib@cs.man.ac.uk
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	Subject: help 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
SequenceableCollection subclass:#RunArray
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
    31
	instanceVariableNames:'contentsArray'
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	classVariableNames:''
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	poolDictionaries:''
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	category:'Collections-Sequenceable'
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
RunArray comment:'This implements an ordered collection which uses runs to minimise the amount
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 of data that it holds. Basically it should be used if you know that an ordered
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 collections is giong to contain a lot of runs of eactly the same data. Implemented
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 to allow simultation playback, since the ordered collctions which that generates
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 are so big that the complier falls over, though most of it is extremely repetetive.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 This should be totally abstracted. The user should not be a ble to see the difference
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 between an ordered collection and a ComrpessedOrderedCollection.  This has a
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 lot in common with RunArray, and the two should probably share implementation.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 but I could not do some of the things I wanted with the RunArray code, so this
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 is all done on its own.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
	Some of this could be made faster by adding a cache of the start and finish
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
 indices of each run, but since I envisage that most additions etc. will be to
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
 and from the end those are not included. In addition I have implemented the
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
 bare essentials of this for what I need it for - i.e. add to the end and take
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
 off the beginning.'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
!RunArray class methodsFor:'documentation'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
copyright
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
 This class is not covered by or part of the ST/X licence.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
 COPYRIGHT.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
 The above file is a Manchester Goodie protected by copyright.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
 These conditions are imposed on the whole Goodie, and on any significant
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
 part of it which is separately transmitted or stored:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
	* You must ensure that every copy includes this notice, and that
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
	  source and author(s) of the material are acknowledged.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
	* These conditions must be imposed on anyone who receives a copy.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
	* The material shall not be used for commercial gain without the prior
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
	  written consent of the author(s).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
 Further information on the copyright conditions may be obtained by
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
 sending electronic mail:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
	To: goodies-lib@cs.man.ac.uk
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
	Subject: copyright
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
 or by writing to The Smalltalk Goodies Library Manager, Dept of
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
 Computer Science, The University, Manchester M13 9PL, UK
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
 (C) Copyright 1993 University of Manchester
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
 For more information about the Manchester Goodies Library (from which 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
 this file was distributed) send e-mail:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
	To: goodies-lib@cs.man.ac.uk
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
	Subject: help 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
documentation
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    This implements an array which uses runs to minimise the amount
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    89
    of data that it holds. 
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    90
    Basically it should be used if you know that an array is going to contain 
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    91
    a lot of runs of exactly the same data. 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    93
    RunArrays are used by the Text class to keep character attributes
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    94
    (which we expect to remain constant for longer character ranges).
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    Notice:
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        there is only a space saving if there are really runs (i.e. multiple
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
        elements which compare same).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
        Otherwise, an Array is more compact.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   101
    [instance variables:]
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   102
        runs            <Array>         contains the runs, consisting of
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   103
                                        length/value entries.
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   104
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   105
    [implementation note:]
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   106
        structure-wise, it would have been more intuitive, to keep
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   107
        instances of Run objects (as done in CompressedOrderedCollection)
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   108
        instead of alternating length/values in the `runs' collection.
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   109
        However, doing this means that lots of additional memory is required.
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   110
        Here, we choose the more space efficient way.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    [author:]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
        Claus Gittinger
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    [see also:]
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   116
        Array OrderedCollection CompressedOrderedCollection
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
examples
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
  this eats up a lot of memory ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
  ... but its relatively fast:
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   124
                                                                        [exBegin]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    |coll|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    coll := OrderedCollection new.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   128
    Transcript showCR:(    
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   129
        Time millisecondsToRun:[
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   130
            100000 timesRepeat:[coll add:'hello'].
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   131
            100000 timesRepeat:[coll add:'world'].
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   132
        ]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    ).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    coll inspect.
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   135
                                                                        [exEnd]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
  this is very space efficient ...
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   139
  ... (and even slightly faster):
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   140
                                                                        [exBegin]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    |coll|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    coll := RunArray new.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   144
    Transcript showCR:(    
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   145
        Time millisecondsToRun:[
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   146
            100000 timesRepeat:[coll add:'hello'].
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   147
            100000 timesRepeat:[coll add:'world'].
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   148
        ]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    ).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    coll inspect.
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   151
                                                                        [exEnd]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   154
  this is very space efficient ...
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   155
  ... AND much faster:
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   156
                                                                        [exBegin]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    |coll|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    coll := RunArray new.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   160
    Transcript showCR:(    
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   161
        Time millisecondsToRun:[
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   162
            coll add:'hello' withOccurrences:100000.
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   163
            coll add:'world' withOccurrences:100000.
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   164
        ]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    ).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    coll inspect.
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   167
                                                                        [exEnd]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
300
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   170
  single-element runs;
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   171
  this is very space INEFFICIENT (requires twice as much) ...
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   172
  ... and MUCH slower:
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   173
                                                                        [exBegin]
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    |coll|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    coll := RunArray new.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   177
    Transcript showCR:(    
298
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   178
        Time millisecondsToRun:[
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   179
            1 to:1000 do:[:i | coll add:i].
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   180
        ]
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   181
    ).
8a87aeffa1c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   182
                                                                        [exEnd]
300
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   183
  compare to:
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   184
                                                                        [exBegin]
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   185
    |coll|
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   186
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   187
    coll := OrderedCollection new.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   188
    Transcript showCR:(    
300
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   189
        Time millisecondsToRun:[
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   190
            1 to:1000 do:[:i | coll add:i].
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   191
        ]
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   192
    ).
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   193
                                                                        [exEnd]
4855b70c63b6 example
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   194
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
!RunArray class methodsFor:'instance creation'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
new:size
334
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   201
    "return a new runArray, containing size nils"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
334
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   203
    ^ self basicNew setElement:nil occurrences:size
302
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   204
334
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   205
    "Modified: 14.5.1996 / 14:04:37 / cg"
302
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   206
!
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   207
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   208
new:size withAll:anObject
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   209
    "create a new runArray, containing anObject size times"
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   210
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   211
    ^ self basicNew setElement:anObject occurrences:size
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   212
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   213
    "
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   214
     RunArray new:100 withAll:#hello
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   215
    "
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   216
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   217
    "Modified: 11.5.1996 / 14:06:48 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
!RunArray methodsFor:'accessing'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
at:anInteger 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "Answer the element at index anInteger. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
     at: is used by a knowledgeable client to access an existing element 
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   225
     This is a pretty dumb thing to do to a runArray and it is 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
     not at all efficient (think of that as a discouragement)."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    |position "{ Class: SmallInteger }"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
     nRuns    "{ Class: SmallInteger }"|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    (anInteger > 0) ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
        position := 1.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   233
        nRuns := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        1 to:nRuns by:2 do:[:runIndex |
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
            |runLen|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   237
            runLen := contentsArray at:runIndex.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
            anInteger >= position ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                anInteger < (position + runLen) ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   240
                    ^ contentsArray at:(runIndex + 1)
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
                ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
            position := position + runLen
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
        ]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    ^ self errorInvalidKey:anInteger
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     c add:1; add:1; add:1; add:2; add:2; add:3; add:3; add:4; add:5.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
     c at:1. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
     c at:2. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
     c at:3. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
     c at:4.  
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
     c at:5. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
     c at:6. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
     c at:7. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
     c at:8.  
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
     c at:9.  
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
     c at:10.  
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   265
    "Modified: 11.5.1996 / 13:33:50 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
at:index put:anObject 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    "Put anObject at element index anInteger.      
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
     at:put: can not be used to append, front or back, to an ordered      
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
     collection;  it is used by a knowledgeable client to replace an     
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   272
     element. 
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   273
     This is a pretty dumb thing to do to a runArray and it is 
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   274
     very inefficient, since we have to check if runs are to be merged or
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   275
     splitted."
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    |runSz runIndex runOffset len l1 l2 prevIdx nextIdx
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
     val newRuns newValues prevLen prevVal nextLen nextVal idx|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   280
    runSz := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    runIndex := nil.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    (index > 0) ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
        runOffset := 1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
        idx := 1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
        [runIndex isNil and:[idx < runSz]] whileTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   287
            len := contentsArray at:idx.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
            nextIdx := runOffset + len.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
            index >= runOffset ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
                index < nextIdx ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
                    runIndex := idx.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
                    nextIdx := runOffset. "/ dont advance
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
                ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
            runOffset := nextIdx.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
            idx := idx + 2.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
        ]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    runIndex isNil ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
        ^ self errorInvalidKey:index
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   303
    val := contentsArray at:(runIndex + 1).
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    "/ easiest: value there is the same ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    val = anObject ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
        ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    "/ if the length is 1, this is an island ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    "/ ... which is either easy, or requires a merge.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   314
    len := contentsArray at:runIndex.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    len = 1 ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
        "/ check if it can be merged into the next or previous run
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
        runIndex > 1 ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
            prevIdx := runIndex - 2.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   320
            prevVal := contentsArray at:(prevIdx + 1).
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
            prevVal = anObject ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
                "/ can merge it into previous
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   324
                prevLen := contentsArray at:prevIdx.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
                "/ check if merge into next is also possible (filling an island)
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
                
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
                runIndex < (runSz - 1) ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
                    nextIdx := runIndex + 2.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   330
                    nextVal := contentsArray at:(nextIdx + 1).
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
                    nextVal = anObject ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
                        "/ can merge with both.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
                        
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   334
                        nextLen := contentsArray at:nextIdx.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   336
                        contentsArray at:prevIdx put:prevLen+nextLen+1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
                        runSz := (runSz - 4).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
                        newRuns := Array new:runSz.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   339
                        newRuns replaceFrom:1 to:(prevIdx + 1) with:contentsArray startingAt:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   340
                        newRuns replaceFrom:runIndex to:runSz with:contentsArray startingAt:nextIdx+2.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   341
                        contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
                        ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
                    ]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
                ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   346
                contentsArray at:prevIdx put:prevLen+1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
                runSz := (runSz - 2).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
                newRuns := Array new:runSz.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   350
                newRuns replaceFrom:1 to:(runIndex - 1) with:contentsArray startingAt:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   351
                newRuns replaceFrom:runIndex to:runSz with:contentsArray startingAt:runIndex+2.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   352
                contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
                ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
        "/ check if merge into next is possible
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
305
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   360
        runIndex < (runSz-1) ifTrue:[
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
            nextIdx := runIndex + 2.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   362
            nextVal := contentsArray at:nextIdx+1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
            nextVal = anObject ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   364
                nextLen := contentsArray at:nextIdx.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   365
                contentsArray at:nextIdx put:nextLen + 1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
                runSz := (runSz - 2).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
                newRuns := Array new:runSz.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   369
                newRuns replaceFrom:1 to:(runIndex - 1) with:contentsArray startingAt:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   370
                newRuns replaceFrom:runIndex to:runSz with:contentsArray startingAt:nextIdx.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   371
                contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
                ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        "/ no merge; island remains
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   378
        contentsArray at:(runIndex+1) put:anObject.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
        ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    runOffset == index ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
        "/ at the beginning of that run ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
        "/ check if its better added to the previous run ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
        runIndex > 1 ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
            prevIdx := runIndex - 2.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   389
            prevVal := contentsArray at:prevIdx+1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
            prevVal = anObject ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   391
                prevLen := contentsArray at:prevIdx.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   392
                contentsArray at:prevIdx put:prevLen + 1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   393
                contentsArray at:runIndex put:len - 1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
                ^ anObject.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
        "/ must cut off 1 & insert a new run before ..
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   400
        contentsArray at:runIndex put:len - 1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
        runSz := (runSz + 2).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
        newRuns := Array new:runSz.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   404
        newRuns replaceFrom:1 to:(runIndex - 1) with:contentsArray startingAt:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   405
        newRuns replaceFrom:runIndex+2 to:runSz with:contentsArray startingAt:runIndex.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   406
        contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   408
        contentsArray at:runIndex   put:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   409
        contentsArray at:runIndex+1 put:anObject.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
        ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    (runOffset + len - 1) == index ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
        "/ at the end ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
        "/ check if its better added to the next run ...
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
306
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   418
        runIndex < (runSz-1) ifTrue:[
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
            nextIdx := runIndex + 2.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   420
            nextVal := contentsArray at:nextIdx+1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
            nextVal = anObject ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   422
                nextLen := contentsArray at:nextIdx.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   423
                contentsArray at:nextIdx put:nextLen + 1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   424
                contentsArray at:runIndex put:len - 1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
                ^ anObject.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
        "/ must cut off 1 & insert a new run after ..
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   431
        contentsArray at:runIndex put:len - 1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
        runSz := (runSz + 2).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
        newRuns := Array new:runSz.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   435
        newRuns replaceFrom:1 to:(runIndex + 1) with:contentsArray startingAt:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   436
        newRuns replaceFrom:runIndex+4 to:runSz with:contentsArray startingAt:runIndex+2.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   437
        contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   439
        contentsArray at:runIndex+2 put:1.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   440
        contentsArray at:runIndex+2+1 put:anObject.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
        ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
    "/ hardest - split run into two, insert new run in-between
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
    runSz := (runSz + 4).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    newRuns := Array new:runSz.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
    runIndex > 1 ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   450
        newRuns replaceFrom:1 to:runIndex-1 with:contentsArray.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    ].
305
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   452
    newRuns replaceFrom:runIndex+6 to:runSz with:contentsArray startingAt:runIndex+2.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    l2 := len - (index - runOffset).
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    l1 := len - l2.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    l2 := l2 - 1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    newRuns at:runIndex   put:l1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
    newRuns at:runIndex+1 put:val.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    newRuns at:runIndex+4 put:l2.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    newRuns at:runIndex+5 put:val.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
    "/ insert
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
    newRuns at:runIndex+2 put:1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    newRuns at:runIndex+3 put:anObject.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   468
    contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    ^ anObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
     Transcript cr.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
     c add:1; add:1; add:1; add:2; add:2; add:3; add:3; add:4; add:5; yourself.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   478
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
     c at:1 put:$a.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   481
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
     c at:3 put:$a.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   485
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
     c at:4 put:$a.   
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   489
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
     c at:5 put:$a.   
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   493
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
     c at:2 put:$0.   
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   497
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
     c at:2 put:$a.   
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   501
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
     c.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   504
     Transcript showCR:c.   
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
306
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   507
    "Modified: 12.5.1996 / 15:55:32 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
size
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   511
    "Answer how many elements the receiver contains.
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   512
     Thsi is not the number of runs (but the simulated number of elements)."
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
    |n     "{ Class: SmallInteger }"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
     runSz "{ Class: SmallInteger }"|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    n := 0.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   518
    runSz := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
    1 to:runSz by:2 do:[:i |
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   520
        n := n + (contentsArray at:i)
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    ^ n
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   523
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   524
    "Modified: 11.5.1996 / 13:34:27 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
!RunArray methodsFor:'adding'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
add:newObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    "add newObject at the end; returns the object (sigh)"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    ^ self add:newObject withOccurrences:1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
     c add:1; add:1; add:1; add:2; add:2; add:3; add:3; add:4; add:5; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    "Modified: 10.5.1996 / 17:01:20 / cg"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
add:newObject withOccurrences:n
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    "add newObject n times at the end; returns the object (sigh)"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
    |lastIdx runSz newRuns|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   549
    contentsArray notNil ifTrue:[
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
        "/ check for merge
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   552
        runSz := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   554
        (contentsArray at:runSz) = newObject ifTrue:[
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
            lastIdx := runSz - 1.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   556
            contentsArray at:lastIdx put:(contentsArray at:lastIdx) + n.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
            ^ newObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
        newRuns := Array new:(runSz + 2).
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   561
        newRuns replaceFrom:1 to:runSz with:contentsArray.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
        newRuns at:runSz+1 put:n.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
        newRuns at:runSz+2 put:newObject.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   564
        contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
    ] ifFalse:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   566
        contentsArray := Array with:n with:newObject.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    ^ newObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
     c add:1 withOccurrences:1000; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
     c add:2 withOccurrences:1000; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   578
    "Modified: 11.5.1996 / 13:34:37 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
grow:howBig
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    "grow or shrink the receiver to contain howBig elements.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   583
     If growing, new slots will be filled (logically) with nil."
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
    |sz info runIndex runOffset runSz newRuns|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
    sz := self size.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
    howBig == sz ifTrue:[^ self].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    howBig == 0 ifTrue:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   592
        contentsArray := nil.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
        ^ self.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   596
    contentsArray isNil ifTrue:[
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   597
        contentsArray := Array with:howBig with:nil.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
        ^ self
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   601
    runSz := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    howBig > sz ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
        newRuns := Array new:(runSz + 2).
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   605
        newRuns replaceFrom:1 to:runSz with:contentsArray startingAt:1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
        newRuns at:(runSz+1) put:(howBig - sz).
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   607
        contentsArray := newRuns.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
        ^ self
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    "/ shrinking; possibly cut of a run
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    info := self runIndexAndStartIndexForIndex:howBig.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
    runIndex := info at:1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
    runOffset := info at:2.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    howBig == (runOffset - 1) ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
        "/ we are lucky - new size is up-to previous run
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   620
        contentsArray := contentsArray copyFrom:1 to:runIndex-1.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    ] ifFalse:[
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   622
        contentsArray := contentsArray copyFrom:1 to:(runIndex+1).
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   623
        contentsArray at:runIndex put:(howBig - runOffset + 1)
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
     c addAll:#(1 2 3 4 4 4 4 5 5 5 1 2 3); yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
     c grow:50; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
     c grow:7; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
     c grow:6; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
     c grow:0; yourself.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   641
    "Modified: 11.5.1996 / 13:34:53 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
!RunArray methodsFor:'converting'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
asOrderedCollection
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   647
    "return a new orderedCollection, containing the receivers elements."
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    |newCollection|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   651
    contentsArray isNil ifTrue:[^ OrderedCollection new].
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   652
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   653
    newCollection := OrderedCollection new:(self size).
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   654
    contentsArray pairWiseDo:[:len :value |
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   655
        newCollection add:value withOccurrences:len
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   656
    ].
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    ^ newCollection
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   659
    "
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   660
     |r|
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   661
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   662
     r := RunArray withAll:#(1 2 3 3 3 3 4 4 4 5 6 7 7 7 7 7 7 7).
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   663
     Transcript showCR:r.
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   664
     Transcript showCR:r asOrderedCollection
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   665
    "
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   666
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   667
    "Modified: 11.5.1996 / 13:34:59 / cg"
334
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   668
!
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   669
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   670
asRunArray
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   671
    "return a receiver itself"
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   672
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   673
    ^ self
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   674
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   675
    "Modified: 14.5.1996 / 14:59:12 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
!RunArray methodsFor:'enumerating'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
do:aBlock 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
    "Evaluate aBlock with each of the receiver's elements as the 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    argument. "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   684
    contentsArray notNil ifTrue:[
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   685
        contentsArray pairWiseDo:[:len :val | 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
            len timesRepeat: [aBlock value:val]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
        ]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
    ]
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   690
    "Modified: 11.5.1996 / 13:35:03 / cg"
305
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   691
!
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   692
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   693
runsDo:aBlock 
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   694
    "Evaluate aBlock with each of the receiver's runs, passing
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   695
     length and value as arguments."
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   696
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   697
    contentsArray notNil ifTrue:[
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   698
        contentsArray pairWiseDo:aBlock
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   699
    ]
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   700
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   701
    "Modified: 11.5.1996 / 13:35:03 / cg"
9d20b26c1e1a fix & added #runsDo:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   702
    "Created: 12.5.1996 / 11:06:51 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
303
b30b08669004 example
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   705
!RunArray methodsFor:'printing & storing'!
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
storeOn:aStream 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
    "Append to aStream an expression which, if evaluated, will generate   
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
    an object similar to the receiver."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
    aStream nextPutAll: '(RunArray new'.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   712
    contentsArray notNil ifTrue:[
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   713
        contentsArray pairWiseDo:[:len :val | 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
            aStream nextPutAll: ' add:'; nextPutAll:val storeString. 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
            len == 1 ifFalse:[
303
b30b08669004 example
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   716
                aStream nextPutAll:' withOccurrences:'; nextPutAll:len printString.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
            aStream nextPutAll:';'
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
        aStream nextPutAll:' yourself'
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    aStream nextPutAll:')'
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
     (RunArray new 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
        add:1; 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
        add:1; 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
        add:2; 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
        add:3; 
303
b30b08669004 example
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   730
        add:4 withOccurrences:100; 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
        add:5; 
303
b30b08669004 example
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   732
        yourself) storeString 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
     RunArray new storeString 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
    "
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   736
303
b30b08669004 example
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   737
    "Modified: 11.5.1996 / 14:28:38 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
!RunArray methodsFor:'private'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
find:oldObject 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
    "If I contain oldObject return its index, otherwise create an error   
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    notifier. It will answer with the position of the very first element of  
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
    that value."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
    |position|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
    position := self find:oldObject ifAbsent:0.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
    position ~~ 0 ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
	^ position
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
    self errorValueNotFound:oldObject
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
     |c|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
     c := RunArray new.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
     c add:1; add:1; add:1; add:2; add:2; add:3; add:3; add:4; add:5.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
     c find:2.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
     c find:99
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
    "
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
    "Modified: 10.5.1996 / 13:39:58 / cg"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
find:oldObject ifAbsent:exceptionBlock 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
    "If I contain oldObject return its index, otherwise execute the 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
     exception block. It will answer with the position of the very first 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
     element of that value."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    |position|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
    position := 1.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   777
    contentsArray notNil ifTrue:[
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   778
        contentsArray pairWiseDo:[:len :val | 
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
            val = oldObject ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
                ^ position
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
            position := position + len.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
    ^ exceptionBlock value
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   787
    "Modified: 11.5.1996 / 13:35:14 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
isEmpty
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    "Am I empty or not. Returns a boolean"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   793
    ^ contentsArray notNil
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   794
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   795
    "Modified: 11.5.1996 / 13:35:17 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
runIndexAndStartIndexForIndex:anIndex
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    "given a logical index, find the index of that run and the logical index
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
     of the first item in that run."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    |position nRuns "{ Class: SmallInteger }"|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
    position := 1.
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   805
    nRuns := contentsArray size.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
    1 to:nRuns by:2 do:[:runIndex | 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
        |runLen runLast|
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   809
        runLen := contentsArray at:runIndex.
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
        anIndex >= position ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
            runLast := position + runLen - 1.
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
            anIndex <= runLast ifTrue:[
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
                ^ Array with:runIndex with:position 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
            ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
        ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
        position := position + runLen
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
    ].
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    ^ #(0 0)
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    "Created: 10.5.1996 / 17:12:28 / cg"
299
2b891872f0af comments
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   822
    "Modified: 11.5.1996 / 13:35:21 / cg"
302
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   823
!
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   824
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   825
setElement:newObject occurrences:n
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   826
    "private instance setup"
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   827
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   828
    contentsArray := Array with:n with:newObject.
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   829
223e660708b2 added #new:withAll:
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
   830
    "Created: 11.5.1996 / 14:05:58 / cg"
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
334
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   833
!RunArray methodsFor:'searching'!
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   834
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   835
findFirst:aBlock
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   836
    "find the first element, for which evaluation of the argument, aBlock
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   837
     returns true; return its index or 0 if none detected.
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   838
     Notice, that not all elements are processed here 
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   839
     (the block is only evaluated for each runs first element)."
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   840
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   841
    |idx|
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   842
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   843
    idx := 1.
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   844
    contentsArray notNil ifTrue:[
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   845
        contentsArray pairWiseDo:[:len :val | 
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   846
            (aBlock value:val) ifTrue:[^ idx].
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   847
            idx := idx + len.
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   848
        ]
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   849
    ].
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   850
    ^ 0
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   851
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   852
    "
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   853
     (RunArray new 
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   854
        add:1 withOccurrences:100;
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   855
        add:2 withOccurrences:100;
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   856
        add:3 withOccurrences:100;
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   857
        add:4 withOccurrences:100;
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   858
        yourself) findFirst:[:el | el == 3] 
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   859
    "
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   860
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   861
    "Modified: 14.5.1996 / 15:54:45 / cg"
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   862
! !
023ca84ef961 faster #findFirst:
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
   863
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
!RunArray methodsFor:'user interface'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
inspect
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
    "Reimplement so that they don't get an ordered collection inspector 
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
     which would get very confused."
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
    self basicInspect
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
    "Modified: 10.5.1996 / 18:24:43 / cg"
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
! !
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
!RunArray class methodsFor:'documentation'!
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
version
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   878
    ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.10 1996-05-18 15:32:47 cg Exp $'
297
9526ea90d4f9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
! !