ArrColl.st
author Claus Gittinger <cg@exept.de>
Thu, 15 Jul 1999 21:45:54 +0200
changeset 4392 26fb48f04e1b
parent 2689 ada9b102abcf
permissions -rw-r--r--
comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
155
edd7fc34e104 *** empty log message ***
claus
parents: 125
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
SequenceableCollection subclass:#ArrayedCollection
1111
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
    14
	instanceVariableNames:''
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
    15
	classVariableNames:''
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
    16
	poolDictionaries:''
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
    17
	category:'Collections-Abstract'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    20
!ArrayedCollection class methodsFor:'documentation'!
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    21
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    22
copyright
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    23
"
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
155
edd7fc34e104 *** empty log message ***
claus
parents: 125
diff changeset
    25
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    27
 This software is furnished under a license and may be used
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    28
 only in accordance with the terms of that license and with the
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    30
 be provided or otherwise made available to, or used by, any
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    31
 other person.  No title to or ownership of the software is
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    32
 hereby transferred.
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    33
"
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    34
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    35
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    36
documentation
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    37
"
249
claus
parents: 213
diff changeset
    38
    ArrayedCollection is an abstract superclass for all collections where 
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    39
    the elements can be accessed via an integer index,
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    40
    AND the collection is a fixed size collection. 
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    41
    Those fixed size collections cannot easily grow, since they store the 
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    42
    elements directly within the object and a grow operation can only be done 
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
    43
    by #becoming another object.
360
claus
parents: 359
diff changeset
    44
    (other collections keep a reference to the physical container, which
claus
parents: 359
diff changeset
    45
     can be easily replaced)
claus
parents: 359
diff changeset
    46
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    47
    [Warning:] 
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    48
        currently, ST/X supports growing fix-size collections
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    49
        (such as Arrays, ByteArrays and Strings). However, this
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    50
        is done in a very slow way (using #become).
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    51
        Become is a very slow operation in a direct-pointer smalltalk
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    52
        system.
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    53
                                                                                \
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    54
        Therefore, you SHOULD rewrite any application that does this,
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    55
        to make use of OrderedCollections or any other collection which
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    56
        can grow faster.
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    57
        To remind you of that, a warning message is sent to the
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    58
        standard error whenever such an operation is performed (see #grow).
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    59
                                                                                \
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    60
        Also note, that some other smalltalk systems do NOT allow
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    61
        fix size collection to change their size, and that future
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    62
        ST/X versions may be changed to trigger an error (instead of a
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    63
        warning) in those situations.
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1171
diff changeset
    64
1289
3abde2c376de checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    65
    [author:]
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    66
        Claus Gittinger
1289
3abde2c376de checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1283
diff changeset
    67
1283
2c533653efa3 commentary
Claus Gittinger <cg@exept.de>
parents: 1171
diff changeset
    68
    [see also:]
2146
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
    69
        OrderedCollection Array
82
0147b4f725ae *** empty log message ***
claus
parents: 68
diff changeset
    70
"
92
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    71
! !
0c73b48551ac *** empty log message ***
claus
parents: 82
diff changeset
    72
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    73
!ArrayedCollection class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    74
a27a279701f8 Initial revision
claus
parents:
diff changeset
    75
with:element
a27a279701f8 Initial revision
claus
parents:
diff changeset
    76
    "return a new SequenceableCollection with one element:anObject"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    77
a27a279701f8 Initial revision
claus
parents:
diff changeset
    78
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
    79
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
    newCollection := self new:1.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    81
    newCollection at:1 put:element.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
    ^newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    83
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    84
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    85
     OrderedCollection with:1
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    86
     SortedCollection with:99 
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    87
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    88
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    89
a27a279701f8 Initial revision
claus
parents:
diff changeset
    90
with:first with:second
a27a279701f8 Initial revision
claus
parents:
diff changeset
    91
    "return a new SequenceableCollection with two elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
a27a279701f8 Initial revision
claus
parents:
diff changeset
    95
    newCollection := self new:2.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
    96
    newCollection at:1 put:first; at:2 put:second.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    97
    ^newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    98
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
    99
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   100
     OrderedCollection with:1 with:2
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   101
     SortedCollection with:99 with:3
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   102
     Array with:1 with:2
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   103
    "
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   104
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   105
    "Modified: 22.1.1997 / 19:35:43 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   106
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   107
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   108
with:a1 with:a2 with:a3
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   109
    "return a new SequenceableCollection with three elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   110
a27a279701f8 Initial revision
claus
parents:
diff changeset
   111
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   112
a27a279701f8 Initial revision
claus
parents:
diff changeset
   113
    newCollection := self new:3.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   114
    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
   115
    ^ newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   116
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   117
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   118
     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
   119
     Array with:1 with:2 with:3
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   120
    "
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   121
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   122
    "Modified: 22.1.1997 / 19:35:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   124
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   125
with:a1 with:a2 with:a3 with:a4
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
    "return a new SequenceableCollection with four elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   129
a27a279701f8 Initial revision
claus
parents:
diff changeset
   130
    newCollection := self new:4.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   131
    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
   132
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   133
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   134
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   135
     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
   136
     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
   137
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   138
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   139
    "Modified: 22.1.1997 / 19:35:52 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   142
with:a1 with:a2 with:a3 with:a4 with:a5
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
    "return a new SequenceableCollection with five elements"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
    |newCollection|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   146
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
    newCollection := self new:5.
2225
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   148
    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
   149
                  at:5 put:a5.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   150
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   151
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
     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
   154
     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
   155
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   156
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   157
    "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
   158
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   159
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   160
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
   161
    "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
   162
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   163
    |newCollection|
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   164
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   165
    newCollection := self new:6.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   166
    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
   167
                  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
   168
    ^ newCollection
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
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   171
     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
   172
     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
   173
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   174
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   175
    "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
   176
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   177
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   178
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
   179
    "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
   180
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   181
    |newCollection|
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
    newCollection := self new:7.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   184
    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
   185
                  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
   186
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   187
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   188
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   189
     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
   190
     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
   191
    "
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   192
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   193
    "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
   194
!
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   195
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   196
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
   197
    "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
   198
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   199
    |newCollection|
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
    newCollection := self new:8.
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   202
    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
   203
                  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
   204
    ^ newCollection
53313e47007a added with:with: type of instance creation messages
Claus Gittinger <cg@exept.de>
parents: 2146
diff changeset
   205
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
     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
   208
     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
   209
    "
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
    "Modified: 22.1.1997 / 19:35:21 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   212
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   213
a27a279701f8 Initial revision
claus
parents:
diff changeset
   214
withAll:aCollection
a27a279701f8 Initial revision
claus
parents:
diff changeset
   215
    "return a new Collection with all elements taken from the argument,
a27a279701f8 Initial revision
claus
parents:
diff changeset
   216
     aCollection"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   217
a27a279701f8 Initial revision
claus
parents:
diff changeset
   218
    |newCollection newSize
a27a279701f8 Initial revision
claus
parents:
diff changeset
   219
     index "{ Class: SmallInteger }" |
a27a279701f8 Initial revision
claus
parents:
diff changeset
   220
a27a279701f8 Initial revision
claus
parents:
diff changeset
   221
    newSize := aCollection size.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   222
    newCollection := self new:newSize.
359
claus
parents: 356
diff changeset
   223
    aCollection isSequenceable ifTrue:[
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   224
	"/
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   225
	"/ aCollection has indexed elements
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   226
	"/ a block-replace may be faster
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   227
	"/
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   228
	newCollection replaceFrom:1 to:newSize with:aCollection startingAt:1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   229
    ] ifFalse:[
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   230
	"/
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   231
	"/ must enumerate the elements individually
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   232
	"/
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   233
	index := 1.
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   234
	aCollection do:[:element |
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   235
	    newCollection at:index put:element.
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   236
	    index := index + 1
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   237
	]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   238
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   239
    ^ newCollection
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   240
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   241
    "
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   242
     OrderedCollection withAll:#(1 2 3 4 5)
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   243
     SortedCollection withAll:#(99 17 53 1 101) 
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   244
    "
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   245
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   246
    "Modified: 13.4.1996 / 12:14:38 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   247
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   248
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   249
!ArrayedCollection class methodsFor:'queries'!
68
59faa75185ba *** empty log message ***
claus
parents: 28
diff changeset
   250
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   251
growIsCheap
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   252
    "return true, if this collection can easily grow
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   253
     (i.e. without a need for become:).
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   254
     Since this is the superclass of all indexed fix-size collections,
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   255
     return false here."
68
59faa75185ba *** empty log message ***
claus
parents: 28
diff changeset
   256
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   257
    ^ false
2
claus
parents: 1
diff changeset
   258
! !
claus
parents: 1
diff changeset
   259
249
claus
parents: 213
diff changeset
   260
!ArrayedCollection methodsFor:'copying'!
claus
parents: 213
diff changeset
   261
claus
parents: 213
diff changeset
   262
copyEmptyAndGrow:size
claus
parents: 213
diff changeset
   263
    "return a new instance of the receivers species with size
claus
parents: 213
diff changeset
   264
     nilled elements and any named instance variables copied."
claus
parents: 213
diff changeset
   265
claus
parents: 213
diff changeset
   266
    "special case for Array, which has no named instance vars"
claus
parents: 213
diff changeset
   267
356
claus
parents: 333
diff changeset
   268
    |cls|
claus
parents: 333
diff changeset
   269
claus
parents: 333
diff changeset
   270
    (cls := self class) instSize == 0 ifTrue:[
claus
parents: 333
diff changeset
   271
	^ cls new:size
249
claus
parents: 213
diff changeset
   272
    ].
claus
parents: 213
diff changeset
   273
    ^ super copyEmptyAndGrow:size
claus
parents: 213
diff changeset
   274
! !
claus
parents: 213
diff changeset
   275
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   276
!ArrayedCollection methodsFor:'error handling'!
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   277
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   278
fixedSizeError
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   279
    "{ Pragma: +optSpace }"
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   280
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   281
    "report an error that size of the collection cannot be changed.
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   282
     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
   283
     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
   284
     allow fixed size collection to grow.
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   285
     Read the documentation on why things are that way ..."
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   286
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   287
    ^ self error:'cannot change size'
1171
7b8924ce3424 commentary
Claus Gittinger <cg@exept.de>
parents: 1164
diff changeset
   288
1579
6993e41d4e6f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
   289
    "Modified: 18.7.1996 / 21:39:09 / cg"
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   290
! !
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   291
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   292
!ArrayedCollection methodsFor:'printing & storing'!
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   293
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   294
storeOn:aStream
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   295
    "output a printed representation (which can be re-read with readFrom:)
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   296
     onto the argument aStream. Redefined to output index access."
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   297
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   298
    |index "{ Class: SmallInteger }"|
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   299
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   300
    thisContext isRecursive ifTrue:[
2290
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   301
        'ArrayedCollection [error]: storeOn: of self referencing collection.' errorPrintCR.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   302
        aStream nextPutAll:'#recursive'.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   303
        ^ self
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   304
    ].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   305
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   306
    aStream nextPutAll:'(('; nextPutAll:self class name; nextPutAll:' new:'.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   307
    self size printOn:aStream.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   308
    aStream nextPutAll:')'.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   309
    index := 1.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   310
    self do:[:element |
2290
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   311
        aStream nextPutAll:' at:'. index printOn:aStream. aStream nextPutAll:' put:('.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   312
        element storeOn:aStream.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   313
        aStream nextPutAll:');'.
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   314
        index := index + 1
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   315
    ].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   316
    index > 1 ifTrue:[aStream nextPutAll:' yourself'].
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   317
    aStream nextPut:$)
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   318
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   319
    "
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   320
     (Array with:(1@2) with:(1->2)) storeString    
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   321
    "
1414
1bbf1ff2fc31 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
   322
2290
80404098824a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   323
    "Modified: 28.1.1997 / 00:39:59 / cg"
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   324
! !
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   325
2
claus
parents: 1
diff changeset
   326
!ArrayedCollection methodsFor:'resizing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   327
2
claus
parents: 1
diff changeset
   328
grow:newSize
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   329
    "grow the receiver i.e. cut off everything after newSize.
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   330
     Warning: this may be a slow operation due to the use of become 
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   331
     - you should write your collection classes to avoid the use of become. 
155
edd7fc34e104 *** empty log message ***
claus
parents: 125
diff changeset
   332
     You have been warned."
2
claus
parents: 1
diff changeset
   333
599
8a0fefb0a725 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 590
diff changeset
   334
    |newArray oldSize sender|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   335
27
d98f9dd437f7 *** empty log message ***
claus
parents: 5
diff changeset
   336
    oldSize := self size.
d98f9dd437f7 *** empty log message ***
claus
parents: 5
diff changeset
   337
    (newSize ~~ oldSize) ifTrue:[
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   338
        InfoPrinting ifTrue:[
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   339
            "/
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   340
            "/ output a warning - you should rewrite your application
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   341
            "/ to use some collection which implements grow: more efficient
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   342
            "/ (i.e. use OrderedCollection instead of Array ..)
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   343
            "/
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   344
            'ArrayedCollection [info]: slow grow operation (' infoPrint.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   345
            self class name infoPrint. ') via ' infoPrint.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   346
            sender := thisContext sender.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   347
            sender methodPrintString infoPrint. 
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   348
            ' from ' infoPrint. sender sender methodPrintString infoPrintCR.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   349
        ].
360
claus
parents: 359
diff changeset
   350
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   351
        newArray := self species new:newSize.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   352
        newArray replaceFrom:1 to:(newSize min:oldSize) with:self.
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   353
        self become:newArray.
2
claus
parents: 1
diff changeset
   354
    ]
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   355
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   356
    "
590
3ffb78fb2716 report sender in slow grow warning
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   357
     #(1 2 3 4 5 6) add:7
3ffb78fb2716 report sender in slow grow warning
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   358
     #(1 2 3 4 5 6) remove:5 
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   359
     #(1 2 3 4 5 6) copy grow:3  
155
edd7fc34e104 *** empty log message ***
claus
parents: 125
diff changeset
   360
     #(1 2 3 4 5 6) copy grow:10  
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   361
     'hello world' copy grow:5   
155
edd7fc34e104 *** empty log message ***
claus
parents: 125
diff changeset
   362
     'hello' copy grow:20   
125
5fdcb4b2567f *** empty log message ***
claus
parents: 92
diff changeset
   363
    "
1428
2c3e439f08cc printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1414
diff changeset
   364
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   365
    "Modified: 10.1.1997 / 15:14:43 / cg"
360
claus
parents: 359
diff changeset
   366
!
claus
parents: 359
diff changeset
   367
claus
parents: 359
diff changeset
   368
removeAll
1998
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   369
    "{ Pragma: +optSpace }"
9749a5f87238 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   370
1164
38c54a4f1273 commentary
Claus Gittinger <cg@exept.de>
parents: 1111
diff changeset
   371
    "remove all elements from the receiver. Returns the receiver.
38c54a4f1273 commentary
Claus Gittinger <cg@exept.de>
parents: 1111
diff changeset
   372
1111
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   373
     For ArrayedCollections (which are actually fixed-size collections),
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   374
     this is a slow operation, since a #become: is required to update
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   375
     all owners. Better use a collection which is prepared for growing
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   376
     (i.e. an OrderedCollection).
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   377
     We output a warning message here, to remind you about that."
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   378
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   379
    'ArrayedCollection [info]: slow removeAll operation (' infoPrint.
1428
2c3e439f08cc printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1414
diff changeset
   380
    self class name infoPrint. ')' infoPrintCR.
360
claus
parents: 359
diff changeset
   381
claus
parents: 359
diff changeset
   382
    self become:(self copyEmpty)
claus
parents: 359
diff changeset
   383
claus
parents: 359
diff changeset
   384
    "
claus
parents: 359
diff changeset
   385
     #(1 2 3 4 5) copy removeAll    
claus
parents: 359
diff changeset
   386
     #(1 2 3 4 5) removeAll    
claus
parents: 359
diff changeset
   387
    "
1111
d8e423b7d5a1 commentary
Claus Gittinger <cg@exept.de>
parents: 990
diff changeset
   388
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   389
    "Modified: 10.1.1997 / 15:14:55 / cg"
2
claus
parents: 1
diff changeset
   390
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   391
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   392
!ArrayedCollection methodsFor:'testing'!
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   393
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   394
includesKey:anIndex
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   395
    "return true, if anIndex is a valid key.
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   396
     NOTICE: in ST-80, this message is only defined for Dictionaries,
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   397
	     however, having a common protocol with indexed collections
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   398
	     often simplifies things."
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   399
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   400
    ^ (anIndex >= 1) and:[anIndex <= self size]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   401
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   402
    "
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   403
     #(1 2 3) includesKey:4 
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   404
     #(1 2 3) includesKey:3  
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   405
    "
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   406
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   407
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   408
size
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   409
    "redefined to re-enable size->basicSize forwarding
2689
ada9b102abcf typo fix
Claus Gittinger <cg@exept.de>
parents: 2290
diff changeset
   410
     (it is caught in SequencableCollection)"
602
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   411
771ab7a8c4bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   412
    ^ self basicSize
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   413
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   414
2125
b438ee11118f new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   415
!ArrayedCollection class methodsFor:'documentation'!
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   416
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   417
version
2689
ada9b102abcf typo fix
Claus Gittinger <cg@exept.de>
parents: 2290
diff changeset
   418
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ArrColl.st,v 1.44 1997-06-16 18:20:15 cg Exp $'
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   419
! !