ArrayedCollection.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 24381 1a1c13d81925
child 24610 9353aecd8669
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
     1
"{ Encoding: utf8 }"
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
     2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
14058
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
     5
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
"
5497
92bb94a53929 added: RecursiveCollectionStoreStringSignal
tm
parents: 2689
diff changeset
    14
"{ Package: 'stx:libbasic' }"
92bb94a53929 added: RecursiveCollectionStoreStringSignal
tm
parents: 2689
diff changeset
    15
19100
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
    16
"{ NameSpace: Smalltalk }"
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
    17
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
SequenceableCollection subclass:#ArrayedCollection
14112
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
    19
	instanceVariableNames:''
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
    20
	classVariableNames:''
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
    21
	poolDictionaries:''
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
    22
	category:'Collections-Abstract'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    24
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    25
!ArrayedCollection class methodsFor:'documentation'!
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    26
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    27
copyright
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    28
"
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    29
 COPYRIGHT (c) 1989 by Claus Gittinger
14058
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
    30
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    31
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    32
 This software is furnished under a license and may be used
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    33
 only in accordance with the terms of that license and with the
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    35
 be provided or otherwise made available to, or used by, any
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    36
 other person.  No title to or ownership of the software is
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    37
 hereby transferred.
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    38
"
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    39
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    40
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    41
documentation
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    42
"
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    43
    ArrayedCollection is an abstract superclass for all collections where
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    44
    the elements can be accessed via an integer index,
17122
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    45
    AND the collection is a fixed size collection.
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    46
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    47
    Those fixed size collections cannot easily grow, since they store the
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    48
    elements directly within the object and a grow operation can only be done
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    49
    by #becoming another object.
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    50
    (many other collections keep a reference to the physical container,
17122
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    51
     which can be easily replaced)
360
claus
parents: 359
diff changeset
    52
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    53
    [Warning:]
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    54
        currently, ST/X supports growing fix-size collections
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    55
        (such as Arrays, ByteArrays and Strings).
17122
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    56
        However, this is done in a very slow way (using #become).
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    57
        Become is a very slow operation in a direct-pointer Smalltalk system
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    58
        (which ST/X and many other 'modern' Smalltalks are).
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    59
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    60
        Therefore, you SHOULD rewrite any application that does this,
17122
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    61
        to make use of OrderedCollections or any other collection which can grow fast.
19100
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
    62
        To remind you of that, a warning message is sent to stdErr,
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
    63
        whenever such an operation is performed (see #grow).
17122
bf8149233069 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 16711
diff changeset
    64
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    65
        Also note that some other Smalltalk systems do NOT allow
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    66
        fix size collection to change their size, and that future
20180
20cef4b412d9 #OTHER by mawalch
mawalch
parents: 19458
diff changeset
    67
        ST/X versions may be changed to trigger an error
19100
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
    68
        (instead of a warning) in those situations.
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1171
diff changeset
    69
1289
3abde2c376de checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    70
    [author:]
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    71
        Claus Gittinger
1289
3abde2c376de checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    72
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1171
diff changeset
    73
    [see also:]
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    74
        OrderedCollection Array
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    75
"
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    76
! !
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    77
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    78
!ArrayedCollection class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
5626
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    80
newFrom:aCollection 
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    81
    "Return an instance of me containing the same elements as aCollection."
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    82
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    83
    |newArray idx sz|
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    84
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    85
    sz := aCollection size.
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    86
    newArray := self new:sz.
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    87
    aCollection isSequenceable ifTrue:[
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    88
        newArray replaceFrom:1 to:sz with:aCollection startingAt:1
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    89
    ] ifFalse:[
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    90
        idx := 1.
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    91
        aCollection do:[:element | 
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    92
            newArray at:idx put:element.
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    93
            idx := idx + 1.
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    94
        ].
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    95
    ].
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    96
    ^ newArray
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    97
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    98
    "
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
    99
     Array newFrom: #[1 2 3]
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   100
     #[1 2 3] as: Array      
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   101
     #[1 2 3] as: ByteArray  
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   102
     #($c  $h  $r) as: String 
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   103
     #($c  $h  $r) as: Text
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   104
    "
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   105
!
91a2b608702f added #newFrom:
Claus Gittinger <cg@exept.de>
parents: 5557
diff changeset
   106
16711
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   107
newWithSize:size
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   108
    "return a new collection of size.
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   109
     For variable size collections, this is different from #new:,
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   110
     in that #new: creates an empty collection with preallocated size,
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   111
     while #withSize: creates a non empty one."
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   112
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   113
    ^ self new:size.
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   114
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   115
    "
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   116
     (OrderedCollection new:10)  
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   117
     (OrderedCollection newWithSize:10) 
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   118
     (Array new:10) 
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   119
     (Array newWithSize:10) 
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   120
    "
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   121
!
e0d54bbf5148 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 15855
diff changeset
   122
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
with:element
a27a279701f8 Initial revision
claus
parents:
diff changeset
   124
    "return a new SequenceableCollection with one element:anObject"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   125
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
    newCollection := self new:1.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   129
    newCollection at:1 put:element.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   130
    ^newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   131
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   132
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   133
     OrderedCollection with:1
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   134
     SortedCollection with:99 
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   135
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   136
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   137
a27a279701f8 Initial revision
claus
parents:
diff changeset
   138
with:first with:second
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
    "return a new SequenceableCollection with two elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   142
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
    newCollection := self new:2.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   144
    newCollection at:1 put:first; at:2 put:second.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
    ^newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   146
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   147
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   148
     OrderedCollection with:1 with:2
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   149
     SortedCollection with:99 with:3
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   150
     Array with:1 with:2
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   151
    "
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   152
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   153
    "Modified: 22.1.1997 / 19:35:43 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   156
with:a1 with:a2 with:a3
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   157
    "return a new SequenceableCollection with three elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   158
a27a279701f8 Initial revision
claus
parents:
diff changeset
   159
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
a27a279701f8 Initial revision
claus
parents:
diff changeset
   161
    newCollection := self new:3.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   162
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   163
    ^ newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   164
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   165
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   166
     OrderedCollection with:1 with:2 with:3
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   167
     Array with:1 with:2 with:3
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   168
    "
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   169
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   170
    "Modified: 22.1.1997 / 19:35:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   171
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   172
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   173
with:a1 with:a2 with:a3 with:a4
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   174
    "return a new SequenceableCollection with four elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   175
a27a279701f8 Initial revision
claus
parents:
diff changeset
   176
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   177
a27a279701f8 Initial revision
claus
parents:
diff changeset
   178
    newCollection := self new:4.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   179
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   180
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   181
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   182
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   183
     OrderedCollection with:1 with:2 with:3 with:4
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   184
     Array with:1 with:2 with:3 with:4
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   185
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   186
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   187
    "Modified: 22.1.1997 / 19:35:52 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   188
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   189
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   190
with:a1 with:a2 with:a3 with:a4 with:a5
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   191
    "return a new SequenceableCollection with five elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   192
a27a279701f8 Initial revision
claus
parents:
diff changeset
   193
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   194
a27a279701f8 Initial revision
claus
parents:
diff changeset
   195
    newCollection := self new:5.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   196
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4;
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   197
                  at:5 put:a5.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   198
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   199
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   200
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   201
     OrderedCollection with:1 with:2 with:3 with:4 with:5
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   202
     Array with:1 with:2 with:3 with:4 with:5
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   203
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   204
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   205
    "Modified: 22.1.1997 / 19:35:57 / cg"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   206
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   207
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   208
with:a1 with:a2 with:a3 with:a4 with:a5 with:a6
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   209
    "return a new SequenceableCollection with six elements"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   210
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   211
    |newCollection|
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   212
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   213
    newCollection := self new:6.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   214
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4;
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   215
                  at:5 put:a5; at:6 put:a6.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   216
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   217
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   218
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   219
     OrderedCollection with:1 with:2 with:3 with:4 with:5 with:6
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   220
     Array with:1 with:2 with:3 with:4 with:5 with:6
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   221
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   222
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   223
    "Modified: 22.1.1997 / 19:36:03 / cg"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   224
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   226
with:a1 with:a2 with:a3 with:a4 with:a5 with:a6 with:a7
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   227
    "return a new SequenceableCollection with seven elements"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   228
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   229
    |newCollection|
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   230
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   231
    newCollection := self new:7.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   232
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4;
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   233
                  at:5 put:a5; at:6 put:a6; at:7 put:a7.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   234
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   235
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   236
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   237
     OrderedCollection with:1 with:2 with:3 with:4 with:5 with:6 with:7
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   238
     Array with:1 with:2 with:3 with:4 with:5 with:6 with:7
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   239
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   240
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   241
    "Modified: 22.1.1997 / 19:36:20 / cg"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   242
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   243
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   244
with:a1 with:a2 with:a3 with:a4 with:a5 with:a6 with:a7 with:a8
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   245
    "return a new SequenceableCollection with eight elements"
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   246
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   247
    |newCollection|
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   248
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   249
    newCollection := self new:8.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   250
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4;
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   251
                  at:5 put:a5; at:6 put:a6; at:7 put:a7; at:8 put:a8.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   252
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   253
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   254
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   255
     OrderedCollection with:1 with:2 with:3 with:4 with:5 with:6 with:7 with:8
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   256
     Array with:1 with:2 with:3 with:4 with:5 with:6 with:7 with:8
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   257
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   258
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   259
    "Modified: 22.1.1997 / 19:35:21 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   260
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   261
14013
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   262
with:a1 with:a2 with:a3 with:a4 with:a5 with:a6 with:a7 with:a8 with:a9
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   263
    "return a new SequenceableCollection with nine elements"
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   264
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   265
    |newCollection|
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   266
14015
579bff670366 changed: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 14013
diff changeset
   267
    newCollection := self new:9.
14013
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   268
    newCollection at:1 put:a1; at:2 put:a2; at:3 put:a3; at:4 put:a4;
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   269
                  at:5 put:a5; at:6 put:a6; at:7 put:a7; at:8 put:a8;
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   270
                  at:9 put:a9.
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   271
    ^ newCollection
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   272
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   273
    "
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   274
     OrderedCollection with:1 with:2 with:3 with:4 with:5 with:6 with:7 with:8 with:9
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   275
     Array with:1 with:2 with:3 with:4 with:5 with:6 with:7 with:8w ith:9
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   276
    "
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   277
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   278
    "Created: / 14-02-2012 / 17:43:07 / cg"
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   279
!
412c81f15eb4 added: #with:with:with:with:with:with:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 11471
diff changeset
   280
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   281
withAll:aCollection
a27a279701f8 Initial revision
claus
parents:
diff changeset
   282
    "return a new Collection with all elements taken from the argument,
a27a279701f8 Initial revision
claus
parents:
diff changeset
   283
     aCollection"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   284
a27a279701f8 Initial revision
claus
parents:
diff changeset
   285
    |newCollection newSize
a27a279701f8 Initial revision
claus
parents:
diff changeset
   286
     index "{ Class: SmallInteger }" |
a27a279701f8 Initial revision
claus
parents:
diff changeset
   287
a27a279701f8 Initial revision
claus
parents:
diff changeset
   288
    newSize := aCollection size.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   289
    newCollection := self new:newSize.
359
claus
parents: 356
diff changeset
   290
    aCollection isSequenceable ifTrue:[
14058
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   291
        "/
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   292
        "/ aCollection has indexed elements
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   293
        "/ a block-replace may be faster
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   294
        "/
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   295
        newCollection replaceFrom:1 to:newSize with:aCollection startingAt:1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   296
    ] ifFalse:[
14058
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   297
        "/
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   298
        "/ must enumerate the elements individually
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   299
        "/
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   300
        index := 1.
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   301
        aCollection do:[:element |
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   302
            newCollection at:index put:element.
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   303
            index := index + 1
670252a21fb9 changed: #inspector2TabForHexDump
Claus Gittinger <cg@exept.de>
parents: 14057
diff changeset
   304
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   305
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   306
    ^ newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   307
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   308
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   309
     OrderedCollection withAll:#(1 2 3 4 5)
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   310
     SortedCollection withAll:#(99 17 53 1 101) 
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   311
    "
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   312
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   313
    "Modified: 13.4.1996 / 12:14:38 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   314
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   315
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   316
!ArrayedCollection class methodsFor:'queries'!
68
59faa75185ba *** empty log message ***
claus
parents: 28
diff changeset
   317
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   318
growIsCheap
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   319
    "return true, if this collection can easily grow
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   320
     (i.e. without a need for become:).
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   321
     Since this is the superclass of all indexed fix-size collections,
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   322
     return false here."
68
59faa75185ba *** empty log message ***
claus
parents: 28
diff changeset
   323
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   324
    ^ false
8893
99996b25482e +isAbstract
Claus Gittinger <cg@exept.de>
parents: 7254
diff changeset
   325
!
99996b25482e +isAbstract
Claus Gittinger <cg@exept.de>
parents: 7254
diff changeset
   326
99996b25482e +isAbstract
Claus Gittinger <cg@exept.de>
parents: 7254
diff changeset
   327
isAbstract
11230
b7799c194161 comment
Claus Gittinger <cg@exept.de>
parents: 10797
diff changeset
   328
    "Return if this class is an abstract class.
b7799c194161 comment
Claus Gittinger <cg@exept.de>
parents: 10797
diff changeset
   329
     True is returned for ArrayedCollection here; false for subclasses.
19458
Claus Gittinger <cg@exept.de>
parents: 19100
diff changeset
   330
     Abstract subclasses must redefine this again."
11230
b7799c194161 comment
Claus Gittinger <cg@exept.de>
parents: 10797
diff changeset
   331
8893
99996b25482e +isAbstract
Claus Gittinger <cg@exept.de>
parents: 7254
diff changeset
   332
    ^ self == ArrayedCollection
2
claus
parents: 1
diff changeset
   333
! !
claus
parents: 1
diff changeset
   334
17211
19b94763ad16 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17122
diff changeset
   335
!ArrayedCollection methodsFor:'adding & removing'!
10797
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   336
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   337
addAll:aCollection
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   338
    "add all elements of the argument, aCollection to the receiver.
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   339
     Returns the argument, aCollection (sigh).
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   340
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   341
     Redefined here, to perform only a single slow grow operation"
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   342
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   343
    |mySize|
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   344
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   345
    mySize := self size.
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   346
    self grow:mySize + aCollection size.
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   347
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   348
    aCollection do:[:element |
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   349
        mySize := mySize + 1.
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   350
        self at:mySize put:element
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   351
    ].
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   352
    ^ aCollection
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   353
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   354
    "
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   355
        #(1 2 3 4) addAll:#(5 6 7 8); yourself
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   356
    "
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   357
!
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   358
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   359
removeAll
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   360
    "{ Pragma: +optSpace }"
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   361
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   362
    "remove all elements from the receiver. Returns the receiver.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   363
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   364
     For ArrayedCollections (which are actually fixed-size collections),
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   365
     this is a slow operation, since a #become: is required to update
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   366
     all owners. Better use a collection which is prepared for growing
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   367
     (i.e. an OrderedCollection).
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   368
     We output a warning message here, to remind you about that."
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   369
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   370
    'ArrayedCollection [info]: slow removeAll operation (' infoPrint.
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   371
    self className infoPrint. ')' infoPrintCR.
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   372
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   373
    self become:(self copyEmpty)
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   374
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   375
    "
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   376
     #(1 2 3 4 5) copy removeAll    
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   377
     #(1 2 3 4 5) removeAll    
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   378
    "
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   379
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   380
    "Modified: / 10-01-1997 / 15:14:55 / cg"
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   381
    "Modified: / 28-06-2019 / 08:41:16 / Claus Gittinger"
22670
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   382
!
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   383
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   384
removeAllSuchThat:aBlock
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   385
    "remove all elements that meet a test criteria as specified in aBlock.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   386
     The argument, aBlock is evaluated for successive elements and all those,
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   387
     for which it returns true, are removed.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   388
     Return a collection containing the removed elements.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   389
     Redefined to do a single become operation."
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   390
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   391
    |keptElements removedElements element sz  "{ Class:SmallInteger }"|
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   392
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   393
    sz := self size.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   394
    keptElements := self speciesForAdding new:sz.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   395
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   396
    1 to:sz do:[:index |
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   397
        element := self at:index.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   398
        (aBlock value:element) ifTrue:[
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   399
            removedElements isNil ifTrue:[
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   400
                removedElements := self speciesForAdding new.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   401
            ].
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   402
            removedElements add:element.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   403
        ] ifFalse:[
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   404
            keptElements add:element.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   405
        ].
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   406
    ].
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   407
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   408
    removedElements isNil ifTrue:[
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   409
        ^ #().
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   410
    ].
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   411
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   412
    'ArrayedCollection [info]: slow removeAllSuchThat operation (' infoPrint.
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   413
    self className infoPrint. ')' infoPrintCR.
22670
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   414
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   415
    keptElements := (self species withAll:keptElements) postCopyFrom:self.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   416
    self become:keptElements.
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   417
    ^ removedElements
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   418
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   419
    "
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   420
     |coll|
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   421
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   422
     coll := Array withAll:(1 to:10).
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   423
     Transcript showCR:(coll removeAllSuchThat:[:el | el even]).
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   424
     Transcript showCR:coll
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   425
    "
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   426
f1dd82a47855 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21481
diff changeset
   427
    "Created: / 13-04-2018 / 14:02:24 / stefan"
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   428
    "Modified: / 28-06-2019 / 08:41:21 / Claus Gittinger"
10797
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   429
! !
5408c171f52f speed up #addAll:
Stefan Vogel <sv@exept.de>
parents: 9086
diff changeset
   430
249
claus
parents: 213
diff changeset
   431
!ArrayedCollection methodsFor:'copying'!
claus
parents: 213
diff changeset
   432
claus
parents: 213
diff changeset
   433
copyEmptyAndGrow:size
14615
4e5318533a06 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 14112
diff changeset
   434
    "return a new instance of the receiver's species with size
249
claus
parents: 213
diff changeset
   435
     nilled elements and any named instance variables copied."
claus
parents: 213
diff changeset
   436
14112
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
   437
    "Performance optimization for classes like Array, String, ...,
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
   438
     which have no named instance vars"
249
claus
parents: 213
diff changeset
   439
14112
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
   440
    self class instSize == 0 ifTrue:[
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
   441
        ^ self species new:size
249
claus
parents: 213
diff changeset
   442
    ].
claus
parents: 213
diff changeset
   443
    ^ super copyEmptyAndGrow:size
claus
parents: 213
diff changeset
   444
! !
claus
parents: 213
diff changeset
   445
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   446
!ArrayedCollection methodsFor:'error handling'!
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   447
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   448
fixedSizeError
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   449
    "{ Pragma: +optSpace }"
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   450
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   451
    "report an error that size of the collection cannot be changed.
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   452
     This is not used right now (instead, a warning is sent to stderr
1579
6993e41d4e6f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
   453
     in the #grow method); however, future versions of ST/X may no longer
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   454
     allow fixed size collection to grow.
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   455
     Read the documentation on why things are that way ..."
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   456
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   457
    ^ self error:'cannot change size'
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   458
1579
6993e41d4e6f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
   459
    "Modified: 18.7.1996 / 21:39:09 / cg"
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   460
! !
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   461
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   462
!ArrayedCollection methodsFor:'growing'!
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   463
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   464
grow:newSize
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   465
    "grow the receiver i.e. cut off everything after newSize.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   466
     Warning: this may be a slow operation due to the use of become 
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   467
     - you should write your collection classes to avoid the use of become. 
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   468
     You have been warned."
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   469
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   470
    |newArray oldSize|
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   471
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   472
    oldSize := self size.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   473
    (newSize ~~ oldSize) ifTrue:[
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   474
        InfoPrinting ifTrue:[
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   475
            "/
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   476
            "/ output a warning - you should rewrite your application
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   477
            "/ to use some collection which implements grow: more efficient
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   478
            "/ (i.e. use OrderedCollection instead of Array ..)
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   479
            "/
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   480
            'ArrayedCollection [warning]: slow grow operation (' errorPrint.
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   481
            self className infoPrint. ') ' errorPrintCR.
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   482
            Context showWhereWeCameFrom.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   483
        ].
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   484
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   485
        newArray := self species new:newSize.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   486
        newArray replaceFrom:1 to:(newSize min:oldSize) with:self.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   487
        self become:newArray.
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   488
    ]
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   489
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   490
    "
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   491
     #(1 2 3 4 5 6) add:7
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   492
     #(1 2 3 4 5 6) remove:5 
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   493
     #(1 2 3 4 5 6) copy grow:3  
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   494
     #(1 2 3 4 5 6) copy grow:10  
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   495
     'hello world' copy grow:5   
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   496
     'hello' copy grow:20   
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   497
    "
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   498
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   499
    "Modified: / 10-01-1997 / 15:14:43 / cg"
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   500
    "Modified: / 28-06-2019 / 08:41:11 / Claus Gittinger"
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   501
! !
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   502
14112
9fc40252441e changed: #copyEmptyAndGrow:
Stefan Vogel <sv@exept.de>
parents: 14058
diff changeset
   503
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   504
!ArrayedCollection methodsFor:'printing & storing'!
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   505
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   506
storeOn:aStream
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   507
    "output a printed representation (which can be re-read with readFrom:)
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   508
     onto the argument aStream. Redefined to output index access."
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   509
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   510
    |index "{ Class: SmallInteger }"|
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   511
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   512
    thisContext isRecursive ifTrue:[
15855
02483477abfc class: ArrayedCollection
Stefan Vogel <sv@exept.de>
parents: 14615
diff changeset
   513
        RecursiveStoreError raiseRequestWith:self.
2290
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   514
        'ArrayedCollection [error]: storeOn: of self referencing collection.' errorPrintCR.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   515
        aStream nextPutAll:'#recursive'.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   516
        ^ self
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   517
    ].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   518
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   519
    aStream nextPutAll:'(('; nextPutAll:self className; nextPutAll:' new:'.
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   520
    self size printOn:aStream.
21481
0a3191652c3d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20180
diff changeset
   521
    aStream nextPut:$).
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   522
    index := 1.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   523
    self do:[:element |
2290
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   524
        aStream nextPutAll:' at:'. index printOn:aStream. aStream nextPutAll:' put:('.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   525
        element storeOn:aStream.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   526
        aStream nextPutAll:');'.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   527
        index := index + 1
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   528
    ].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   529
    index > 1 ifTrue:[aStream nextPutAll:' yourself'].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   530
    aStream nextPut:$)
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   531
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   532
    "
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   533
     (Array with:(1@2) with:(1->2)) storeString    
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   534
    "
1414
1bbf1ff2fc31 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
   535
21481
0a3191652c3d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20180
diff changeset
   536
    "Modified: / 28-01-1997 / 00:39:59 / cg"
0a3191652c3d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20180
diff changeset
   537
    "Modified: / 17-02-2017 / 10:51:53 / stefan"
24381
1a1c13d81925 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22670
diff changeset
   538
    "Modified: / 28-06-2019 / 08:41:27 / Claus Gittinger"
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   539
! !
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   540
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   541
!ArrayedCollection methodsFor:'queries'!
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   542
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   543
size
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   544
    "redefined to re-enable size->basicSize forwarding
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   545
     (it is caught in SequencableCollection)"
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   546
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   547
    ^ self basicSize
6548
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   548
!
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   549
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   550
speciesForAdding
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   551
     "redefined here, since grow is not cheap.
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   552
      Used by functions which create a growing collection (see collect:with:, for example)"
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   553
e47779f9bbfa +#speciesForAdding
Claus Gittinger <cg@exept.de>
parents: 5626
diff changeset
   554
    ^ OrderedCollection
5557
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   555
! !
f5f8d236027c category change
Claus Gittinger <cg@exept.de>
parents: 5498
diff changeset
   556
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   557
!ArrayedCollection class methodsFor:'documentation'!
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   558
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   559
version
19100
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
   560
    ^ '$Header$'
17212
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   561
!
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   562
2e02d9d621da class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 17211
diff changeset
   563
version_CVS
19100
c5b67cced033 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 17212
diff changeset
   564
    ^ '$Header$'
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   565
! !
14615
4e5318533a06 class: ArrayedCollection
Claus Gittinger <cg@exept.de>
parents: 14112
diff changeset
   566