author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:20:46 +0200 | |
changeset 1290 | 15ba3221b89b |
parent 1276 | 21649f929b32 |
child 1399 | fd17bde5f3a2 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
155 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
ArrayedCollection variableSubclass:#Array |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
14 |
instanceVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
15 |
classVariableNames:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
16 |
poolDictionaries:'' |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
17 |
category:'Collections-Arrayed' |
1 | 18 |
! |
19 |
||
77 | 20 |
!Array class methodsFor:'documentation'! |
21 |
||
554 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
77 | 36 |
documentation |
37 |
" |
|
155 | 38 |
Instances of Array store general objects; the arrays size is fixed, |
39 |
therefore add:/remove: are not allowed. |
|
399 | 40 |
(actually, #add: is implemented for compatibility with smalltalks which |
1266 | 41 |
provide it, but it is very slow and outputs an annoying warning message ...) |
42 |
||
43 |
Access to the individual elements is via an integer index, |
|
44 |
using the well-known access messages #at: and #at:put:. |
|
399 | 45 |
|
1266 | 46 |
Since Arrays are used very often in the system, some methods have been |
47 |
tuned by reimplementing them as primitives. Also, the compiler inline-codes |
|
48 |
some operations (especially: the above accessing messages). |
|
92 | 49 |
|
1266 | 50 |
Notice that Array is a built-in class |
51 |
(i.e. the VM knows about its representation). |
|
52 |
Therefore it is NOT possible to add named instance variables or change |
|
53 |
Arrays inheritance. |
|
54 |
However, subclassing is allowed of course |
|
55 |
- even with added named instance variables. |
|
92 | 56 |
|
57 |
Literal arrays (i.e. array-constants) are entered in source as: |
|
1266 | 58 |
|
59 |
#( element1 element2 ... element-n) |
|
60 |
||
61 |
where each element must be itself a literal constant. |
|
62 |
Array, symbol and byteArray constants within an array can be written |
|
63 |
without the initial #-character. |
|
64 |
In addition, true, false and nil are also allowed as array-literal. |
|
399 | 65 |
|
92 | 66 |
Examples: |
1266 | 67 |
#(1 2 3) -> 3 elements: 1, 2 and 3 |
68 |
#('foo' 2 (1 2)) -> 3 elements: a String, 2 and anotherArray |
|
69 |
#('foo' #(1 2) #foo) -> 3 elements: a String, another array and a symbol |
|
70 |
#('foo' (1 2) foo) -> same as above |
|
71 |
#(nil true #true) -> 3 elements: nil, true and a symbol (watch out) |
|
72 |
#(two [3 3 3] (4 4 4)) -> 3 elements: a symbol, a byteArray and another array |
|
1276 | 73 |
|
74 |
||
1290 | 75 |
[author:] |
76 |
Claus Gittinger |
|
77 |
||
1276 | 78 |
[see also:] |
79 |
OrderedCollection |
|
80 |
ByteArray FloatArray DoubleArray |
|
81 |
String |
|
77 | 82 |
" |
626 | 83 |
! ! |
3 | 84 |
|
249 | 85 |
!Array class methodsFor:'instance creation'! |
86 |
||
87 |
basicNew:anInteger |
|
88 |
"return an instance of myself with anInteger indexed variables. |
|
89 |
Since Array-creation is so common (all other collections use them), |
|
90 |
it seems worth to have a specially tuned version here." |
|
91 |
||
92 |
%{ /* NOCONTEXT */ |
|
93 |
||
94 |
OBJ newobj; |
|
95 |
unsigned INT instsize, nInstVars; |
|
96 |
INT nindexedinstvars; |
|
97 |
REGISTER OBJ *op; |
|
98 |
||
99 |
if (__isSmallInteger(anInteger)) { |
|
1133 | 100 |
nindexedinstvars = __intVal(anInteger); |
249 | 101 |
if (nindexedinstvars >= 0) { |
1133 | 102 |
nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars); |
249 | 103 |
|
104 |
nInstVars += nindexedinstvars; |
|
105 |
instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
|
835 | 106 |
if (__CanDoQuickAlignedNew(instsize)) { |
357 | 107 |
/* |
108 |
* the most common case |
|
109 |
*/ |
|
835 | 110 |
__qCheckedAlignedNew(newobj, instsize); |
357 | 111 |
ok: ; |
1133 | 112 |
__InstPtr(newobj)->o_class = self; |
369 | 113 |
__qSTORE(newobj, self); |
114 |
||
788
e80f1c42b87b
dont use memset4 if its undefined
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
115 |
#if defined(memset4) && defined(FAST_ARRAY_MEMSET4) |
1133 | 116 |
memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
249 | 117 |
#else |
118 |
# if !defined(NEGATIVE_ADDRESSES) |
|
119 |
/* |
|
120 |
* knowing that nil is 0 |
|
121 |
*/ |
|
360 | 122 |
#ifdef XXmips |
249 | 123 |
# undef FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
124 |
# undef FAST_ARRAY_MEMSET_LONGLONG_UNROLLED |
|
125 |
/* seems to be slightly faster */ |
|
126 |
# define FAST_ARRAY_MEMSET |
|
127 |
#endif |
|
128 |
#ifdef sparc |
|
129 |
# define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED |
|
130 |
#endif |
|
131 |
||
132 |
# if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED) |
|
1133 | 133 |
op = __InstPtr(newobj)->i_instvars; |
249 | 134 |
if (nInstVars > 8) { |
135 |
*op++ = nil; /* for alignment */ |
|
136 |
nInstVars--; |
|
137 |
while (nInstVars >= 8) { |
|
138 |
*(double *)op = 0.0; |
|
139 |
((double *)op)[1] = 0.0; |
|
140 |
((double *)op)[2] = 0.0; |
|
141 |
((double *)op)[3] = 0.0; |
|
142 |
op += 8; |
|
143 |
nInstVars -= 8; |
|
144 |
} |
|
145 |
} |
|
146 |
while (nInstVars) { |
|
147 |
*op++ = 0; |
|
148 |
nInstVars--; |
|
149 |
} |
|
150 |
# else |
|
151 |
# if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED) |
|
1133 | 152 |
op = __InstPtr(newobj)->i_instvars; |
249 | 153 |
if (nInstVars > 8) { |
154 |
*op++ = nil; /* for alignment */ |
|
155 |
nInstVars--; |
|
156 |
while (nInstVars >= 8) { |
|
157 |
*(long long *)op = 0; |
|
158 |
((long long *)op)[1] = 0; |
|
159 |
((long long *)op)[2] = 0; |
|
160 |
((long long *)op)[3] = 0; |
|
161 |
op += 8; |
|
162 |
nInstVars -= 8; |
|
163 |
} |
|
164 |
} |
|
165 |
while (nInstVars) { |
|
166 |
*op++ = 0; |
|
167 |
nInstVars--; |
|
168 |
} |
|
169 |
# else |
|
170 |
# if defined(FAST_ARRAY_MEMSET) |
|
1133 | 171 |
memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
249 | 172 |
# else |
1133 | 173 |
op = __InstPtr(newobj)->i_instvars; |
249 | 174 |
while (nInstVars--) |
175 |
*op++ = nil; |
|
176 |
# endif |
|
177 |
# endif |
|
178 |
# endif |
|
179 |
# else |
|
1133 | 180 |
op = __InstPtr(newobj)->i_instvars; |
249 | 181 |
while (nInstVars--) |
182 |
*op++ = nil; |
|
183 |
# endif |
|
184 |
#endif |
|
185 |
RETURN ( newobj ); |
|
357 | 186 |
} else { |
187 |
/* |
|
188 |
* a GC will happen ... |
|
189 |
* have to protect all context stuff |
|
190 |
* (especially for self, but also for backtrace in case of |
|
191 |
* allocation failure) |
|
192 |
*/ |
|
834 | 193 |
__PROTECT_CONTEXT__ |
951
2dd898849a8a
directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
194 |
newobj = __new(instsize); |
834 | 195 |
__UNPROTECT_CONTEXT__ |
357 | 196 |
if (newobj != nil) { |
197 |
goto ok; |
|
198 |
} |
|
249 | 199 |
} |
200 |
} |
|
201 |
} |
|
202 |
%}. |
|
203 |
" |
|
204 |
arrive here if something went wrong ... |
|
205 |
figure out what it was |
|
206 |
" |
|
207 |
(anInteger isMemberOf:SmallInteger) ifFalse:[ |
|
208 |
" |
|
209 |
the argument is either not an integer, |
|
210 |
or a LargeInteger (which means that its definitely too big) |
|
211 |
" |
|
212 |
self error:'argument to new: must be Integer'. |
|
213 |
^ nil |
|
214 |
]. |
|
215 |
(anInteger < 0) ifTrue:[ |
|
216 |
" |
|
217 |
the argument is negative, |
|
218 |
" |
|
219 |
self error:'bad (negative) argument to new:'. |
|
220 |
^ nil |
|
221 |
]. |
|
222 |
" |
|
223 |
memory allocation failed. |
|
224 |
When we arrive here, there was no memory, even after |
|
225 |
a garbage collect. |
|
226 |
This means, that the VM wanted to get some more memory from the |
|
227 |
Operatingsystem, which was not kind enough to give it. |
|
228 |
Bad luck - you should increase the swap space on your machine. |
|
229 |
" |
|
230 |
^ ObjectMemory allocationFailureSignal raise. |
|
549 | 231 |
! |
232 |
||
233 |
new:anInteger |
|
234 |
"return an instance of myself with anInteger indexed variables. |
|
1266 | 235 |
Redefined here to save a few cycles when executed. |
236 |
(Since this is often called, its worth giving it an extra ilc-slot. |
|
237 |
Future versions of stc will do this automatically.)" |
|
549 | 238 |
|
239 |
^ self basicNew:anInteger |
|
1266 | 240 |
|
241 |
"Modified: 23.4.1996 / 15:52:15 / cg" |
|
360 | 242 |
! ! |
243 |
||
543 | 244 |
!Array class methodsFor:'queries'! |
345 | 245 |
|
543 | 246 |
isBuiltInClass |
1266 | 247 |
"return true if this class is known by the run-time-system. |
248 |
Here, true is returned for myself, false for subclasses." |
|
345 | 249 |
|
543 | 250 |
^ self == Array |
1243 | 251 |
|
1266 | 252 |
"Modified: 23.4.1996 / 15:55:06 / cg" |
249 | 253 |
! ! |
254 |
||
1 | 255 |
!Array methodsFor:'accessing'! |
256 |
||
554 | 257 |
at:index |
258 |
"return the indexed instance variable with index, anInteger. |
|
259 |
Reimplemented here to avoid the additional at:->basicAt: send |
|
260 |
(which we can do here, since at: is obviously not redefined in a subclass). |
|
577 | 261 |
This method is the same as basicAt:." |
543 | 262 |
|
263 |
%{ /* NOCONTEXT */ |
|
264 |
||
554 | 265 |
REGISTER int indx; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
266 |
REGISTER OBJ slf; |
554 | 267 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
268 |
REGISTER OBJ cls; |
554 | 269 |
|
270 |
if (__isSmallInteger(index)) { |
|
1133 | 271 |
indx = __intVal(index) - 1; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
272 |
slf = self; |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
273 |
|
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
274 |
/* |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
275 |
* thanks to Patterson/Hennesey - this can be done with a single |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
276 |
* compare ... |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
277 |
*/ |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
278 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
279 |
if ((cls = __qClass(slf)) != Array) |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
280 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
281 |
if ((unsigned)indx < (unsigned)nIndex) { |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
282 |
RETURN ( __InstPtr(slf)->i_instvars[indx] ); |
554 | 283 |
} |
284 |
} |
|
285 |
%}. |
|
286 |
^ super at:index |
|
543 | 287 |
! |
288 |
||
554 | 289 |
at:index put:anObject |
290 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
1219 | 291 |
Returns anObject (sigh). |
554 | 292 |
Reimplemented here to avoid the additional at:put:->basicAt:put: send |
293 |
(which we can do here, since at: is obviously not redefined in a subclass). |
|
577 | 294 |
This method is the same as basicAt:put:." |
549 | 295 |
|
296 |
%{ /* NOCONTEXT */ |
|
297 |
||
554 | 298 |
REGISTER int indx; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
299 |
REGISTER OBJ slf; |
554 | 300 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
301 |
REGISTER OBJ cls; |
554 | 302 |
|
303 |
if (__isSmallInteger(index)) { |
|
1219 | 304 |
indx = __intVal(index) - 1; |
305 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
306 |
|
1219 | 307 |
/* thanks to Patterson/Hennesey - this can be done with a single |
308 |
* compare ... |
|
309 |
*/ |
|
310 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
|
311 |
if ((cls = __qClass(slf)) != Array) |
|
312 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
313 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
314 |
__InstPtr(slf)->i_instvars[indx] = anObject; |
|
315 |
__STORE(slf, anObject); |
|
316 |
RETURN ( anObject ); |
|
317 |
} |
|
554 | 318 |
} |
319 |
%}. |
|
320 |
^ super at:index put:anObject |
|
1219 | 321 |
|
322 |
"Modified: 19.4.1996 / 11:16:42 / cg" |
|
549 | 323 |
! |
324 |
||
325 |
basicAt:index |
|
326 |
"return the indexed instance variable with index, anInteger |
|
327 |
- added here for speed" |
|
328 |
||
329 |
%{ /* NOCONTEXT */ |
|
330 |
||
331 |
REGISTER int indx; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
332 |
REGISTER OBJ slf; |
549 | 333 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
334 |
REGISTER OBJ cls; |
549 | 335 |
|
336 |
if (__isSmallInteger(index)) { |
|
1133 | 337 |
indx = __intVal(index) - 1; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
338 |
slf = self; |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
339 |
|
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
340 |
/* |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
341 |
* thanks to Patterson/Hennesey - this can be done with a single |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
342 |
* compare ... |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
343 |
*/ |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
344 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
345 |
if ((cls = __qClass(slf)) != Array) |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
346 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
347 |
if ((unsigned)indx < (unsigned)nIndex) { |
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
348 |
RETURN ( __InstPtr(slf)->i_instvars[indx] ); |
549 | 349 |
} |
350 |
} |
|
351 |
%} |
|
352 |
. |
|
353 |
^ super basicAt:index |
|
354 |
! |
|
355 |
||
77 | 356 |
basicAt:index put:anObject |
1 | 357 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
1219 | 358 |
Returns anObject (sigh). |
1 | 359 |
- added here for speed" |
360 |
||
361 |
%{ /* NOCONTEXT */ |
|
362 |
||
363 |
REGISTER int indx; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
364 |
REGISTER OBJ slf; |
92 | 365 |
REGISTER unsigned int nIndex; |
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
366 |
REGISTER OBJ cls; |
1 | 367 |
|
249 | 368 |
if (__isSmallInteger(index)) { |
1219 | 369 |
indx = __intVal(index) - 1; |
370 |
slf = self; |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
371 |
|
1219 | 372 |
/* |
373 |
* thanks to Patterson/Hennesey - this can be done with a single |
|
374 |
* compare ... |
|
375 |
*/ |
|
376 |
nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); |
|
377 |
if ((cls = __qClass(slf)) != Array) |
|
378 |
indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
379 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
380 |
__InstPtr(slf)->i_instvars[indx] = anObject; |
|
381 |
__STORE(slf, anObject); |
|
382 |
RETURN ( anObject ); |
|
383 |
} |
|
1 | 384 |
} |
385 |
%} |
|
386 |
. |
|
77 | 387 |
^ super basicAt:index put:anObject |
1219 | 388 |
|
389 |
"Modified: 19.4.1996 / 11:14:26 / cg" |
|
551 | 390 |
! |
391 |
||
554 | 392 |
basicSize |
393 |
"return the number of indexed elements in the receiver" |
|
551 | 394 |
|
395 |
%{ /* NOCONTEXT */ |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
396 |
REGISTER OBJ slf = self; |
551 | 397 |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
398 |
RETURN ( __MKSMALLINT(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) )); |
554 | 399 |
%} |
551 | 400 |
! |
401 |
||
554 | 402 |
size |
403 |
"return the number of indexed elements in the receiver. |
|
404 |
Reimplemented here to avoid the additional size->basicSize send |
|
405 |
(which we can do here, since size is obviously not redefined in a subclass). |
|
406 |
This method is the same as basicSize." |
|
551 | 407 |
|
408 |
%{ /* NOCONTEXT */ |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
409 |
REGISTER OBJ slf = self; |
551 | 410 |
|
1143
27325100bdf4
can check index against low..hi with a single compare&branch
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
411 |
RETURN ( __MKSMALLINT(__arraySize(slf) - __intVal(__ClassInstPtr(__qClass(slf))->c_ninstvars) )); |
554 | 412 |
%} |
1 | 413 |
! ! |
414 |
||
11 | 415 |
!Array methodsFor:'converting'! |
416 |
||
417 |
asArray |
|
1243 | 418 |
"return the receiver as an array - thats the receiver itself" |
11 | 419 |
|
420 |
"could be an instance of a subclass..." |
|
421 |
self class == Array ifTrue:[ |
|
1243 | 422 |
^ self |
11 | 423 |
]. |
424 |
^ super asArray |
|
1243 | 425 |
|
426 |
"Modified: 22.4.1996 / 12:42:09 / cg" |
|
11 | 427 |
! ! |
428 |
||
1 | 429 |
!Array methodsFor:'copying'! |
430 |
||
431 |
copyWith:something |
|
220 | 432 |
"return a new collection containing the receivers elements |
433 |
and the single new element, newElement. |
|
434 |
This is different from concatentation, which expects another collection |
|
435 |
as argument, but equivalent to copy-and-addLast. |
|
370 | 436 |
Reimplemented for speed if receiver is an Array. |
437 |
(since the inherited copyWith uses replaceFromTo:, which is also |
|
438 |
tuned, it is questionable, if we need this)" |
|
439 |
||
440 |
%{ /* NOCONTEXT */ |
|
11 | 441 |
OBJ nObj, element; |
92 | 442 |
unsigned int sz; |
443 |
unsigned int nIndex; |
|
11 | 444 |
REGISTER OBJ *srcP, *dstP; |
293 | 445 |
REGISTER int spc; |
1 | 446 |
|
328 | 447 |
if (__qClass(self) == Array) { |
448 |
sz = __qSize(self) + sizeof(OBJ); |
|
834 | 449 |
__PROTECT__(something); |
450 |
__PROTECT__(self); |
|
835 | 451 |
__qAlignedNew(nObj, sz, __context); |
834 | 452 |
__UNPROTECT__(self); |
453 |
__UNPROTECT__(something); |
|
92 | 454 |
|
155 | 455 |
if (nObj) { |
1133 | 456 |
__InstPtr(nObj)->o_class = Array; |
1 | 457 |
|
155 | 458 |
nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ)); |
370 | 459 |
/* |
460 |
* sorry: |
|
461 |
* cannot use bcopy, since we must take care of stores ... |
|
462 |
* could check for: notRemembered + inOld + notLifoRem |
|
463 |
* + not incrGCRunning |
|
464 |
* but copyWith: is not heavily used by real programmers ... |
|
465 |
*/ |
|
466 |
spc = __qSpace(nObj); |
|
1133 | 467 |
srcP = __ArrayInstPtr(self)->a_element; |
468 |
dstP = __ArrayInstPtr(nObj)->a_element; |
|
393 | 469 |
#ifdef UNROLL_LOOPS |
470 |
while (nIndex >= 4) { |
|
471 |
element = srcP[0]; |
|
472 |
dstP[0] = element; |
|
473 |
__STORE_SPC(nObj, element, spc); |
|
474 |
element = srcP[1]; |
|
475 |
dstP[1] = element; |
|
476 |
__STORE_SPC(nObj, element, spc); |
|
477 |
element = srcP[2]; |
|
478 |
dstP[2] = element; |
|
479 |
__STORE_SPC(nObj, element, spc); |
|
480 |
element = srcP[3]; |
|
481 |
dstP[3] = element; |
|
482 |
__STORE_SPC(nObj, element, spc); |
|
483 |
srcP += 4; |
|
484 |
dstP += 4; |
|
485 |
nIndex -= 4; |
|
486 |
} |
|
487 |
#endif |
|
155 | 488 |
while (nIndex--) { |
489 |
element = *srcP++; |
|
490 |
*dstP++ = element; |
|
293 | 491 |
__STORE_SPC(nObj, element, spc); |
155 | 492 |
} |
493 |
*dstP = something; |
|
293 | 494 |
__STORE_SPC(nObj, something, spc); |
155 | 495 |
RETURN ( nObj ); |
496 |
} |
|
1 | 497 |
} |
498 |
%} |
|
499 |
. |
|
500 |
^ super copyWith:something |
|
501 |
! ! |
|
502 |
||
216 | 503 |
!Array methodsFor:'enumerating'! |
1 | 504 |
|
554 | 505 |
addAllTo:aCollection |
506 |
"add all elements of the receiver to aCollection. |
|
507 |
return aCollection." |
|
508 |
||
509 |
|stop "{ Class: SmallInteger }"| |
|
510 |
||
511 |
stop := self size. |
|
512 |
1 to:stop do:[:idx | |
|
513 |
aCollection add:(self at:idx) |
|
514 |
]. |
|
515 |
^ aCollection |
|
516 |
! |
|
517 |
||
518 |
do:aBlock |
|
519 |
"evaluate the argument, aBlock for each element in the collection. |
|
520 |
- reimplemented for speed" |
|
521 |
||
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
522 |
|home sz "{ Class: SmallInteger }"| |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
523 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
524 |
sz := self size. |
554 | 525 |
%{ |
526 |
REGISTER OBJFUNC codeVal; |
|
527 |
REGISTER int index; |
|
528 |
unsigned int nIndex; |
|
529 |
static struct inlineCache val = _ILC1; |
|
530 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
531 |
int actualSize; |
554 | 532 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
533 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
534 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
535 |
nIndex = index + __intVal(sz); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
536 |
if (nIndex <= actualSize) { |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
537 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
538 |
if (__isBlockLike(aBlock) |
1133 | 539 |
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
540 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
|
554 | 541 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
542 |
for (; index < nIndex; index++) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
543 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 544 |
|
1133 | 545 |
(*codeVal)(aBlock, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
546 |
} |
554 | 547 |
#else |
1133 | 548 |
home = __BlockInstPtr(aBlock)->b_home; |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
549 |
rHome = home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
550 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
551 |
/* |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
552 |
* home will not move - keep in a fast register |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
553 |
*/ |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
554 |
# if defined(UNROLL_LOOPS) |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
555 |
{ |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
556 |
int i4; |
554 | 557 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
558 |
while ((i4 = index+4) < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
559 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 560 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
561 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 562 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+1]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
563 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 564 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+2]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
565 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 566 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+3]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
567 |
index = i4; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
568 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
569 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
570 |
# endif |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
571 |
for (; index < nIndex; index++) { |
554 | 572 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
573 |
|
1133 | 574 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
575 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
576 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
577 |
for (; index < nIndex; index++) { |
554 | 578 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
579 |
||
1133 | 580 |
(*codeVal)(home, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
581 |
} |
554 | 582 |
} |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
583 |
#endif |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
584 |
} else { |
554 | 585 |
for (; index < nIndex; index++) { |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
586 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 587 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
588 |
(*val.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
589 |
@symbol(value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
590 |
CON_COMMA nil, &val, |
1133 | 591 |
__InstPtr(self)->i_instvars[index]); |
554 | 592 |
} |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
593 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
594 |
RETURN (self ); |
554 | 595 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
596 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
597 |
^ super do:aBlock |
554 | 598 |
! |
599 |
||
1 | 600 |
from:start to:stop do:aBlock |
601 |
"evaluate the argument, aBlock for the elements starting at index start |
|
602 |
up to (and including) stop in the collection. |
|
603 |
- reimplemented for speed" |
|
604 |
||
302 | 605 |
|home| |
1 | 606 |
%{ |
607 |
REGISTER OBJFUNC codeVal; |
|
608 |
REGISTER int index; |
|
2 | 609 |
REGISTER OBJ rHome; |
1 | 610 |
int nIndex, nInsts; |
611 |
static struct inlineCache val = _ILC1; |
|
612 |
int indexLow, indexHigh; |
|
613 |
||
249 | 614 |
if (__bothSmallInteger(start, stop)) { |
1133 | 615 |
indexLow = __intVal(start); |
155 | 616 |
if (indexLow > 0) { |
1133 | 617 |
indexHigh = __intVal(stop); |
618 |
if (__qClass(self) != @global(Array)) { |
|
619 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
|
155 | 620 |
indexLow += nInsts; |
621 |
indexHigh += nInsts; |
|
622 |
} |
|
328 | 623 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
155 | 624 |
if (indexHigh <= nIndex) { |
625 |
indexLow--; |
|
626 |
indexHigh--; |
|
627 |
if (__isBlockLike(aBlock) |
|
1133 | 628 |
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
629 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
|
11 | 630 |
#ifdef NEW_BLOCK_CALL |
155 | 631 |
for (index=indexLow; index <= indexHigh; index++) { |
421 | 632 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 633 |
(*codeVal)(aBlock, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 634 |
} |
11 | 635 |
#else |
1133 | 636 |
home = __BlockInstPtr(aBlock)->b_home; |
155 | 637 |
rHome = home; |
325 | 638 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
370 | 639 |
index = indexLow; |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
640 |
# if defined(UNROLL_LOOPS) |
379 | 641 |
{ |
642 |
int i4; |
|
370 | 643 |
|
379 | 644 |
while ((i4 = index+4) <= indexHigh) { |
421 | 645 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 646 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index]); |
421 | 647 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 648 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+1]); |
421 | 649 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 650 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+2]); |
421 | 651 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 652 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index+3]); |
370 | 653 |
index = i4; |
654 |
} |
|
655 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
656 |
# endif |
370 | 657 |
for (; index <= indexHigh; index++) { |
421 | 658 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 659 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 660 |
} |
661 |
} else { |
|
662 |
for (index=indexLow; index <= indexHigh; index++) { |
|
421 | 663 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 664 |
(*codeVal)(home, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 665 |
} |
666 |
} |
|
11 | 667 |
#endif |
155 | 668 |
} else { |
669 |
for (index=indexLow; index <= indexHigh; index++) { |
|
421 | 670 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 671 |
(*val.ilc_func) (aBlock, |
672 |
@symbol(value:), |
|
673 |
CON_COMMA nil, &val, |
|
1133 | 674 |
__InstPtr(self)->i_instvars[index]); |
155 | 675 |
} |
676 |
} |
|
677 |
} |
|
678 |
RETURN ( self ); |
|
679 |
} |
|
1 | 680 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
681 |
%}. |
1 | 682 |
^ super from:start to:stop do:aBlock |
683 |
! |
|
684 |
||
42 | 685 |
from:start to:stop reverseDo:aBlock |
686 |
"evaluate the argument, aBlock for the elements starting at index start |
|
687 |
up to (and including) stop in the collection. Step in reverse order. |
|
688 |
- reimplemented for speed" |
|
689 |
||
302 | 690 |
|home| |
42 | 691 |
%{ |
692 |
REGISTER OBJFUNC codeVal; |
|
693 |
REGISTER int index; |
|
694 |
REGISTER OBJ rHome; |
|
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
695 |
int nIndex; |
42 | 696 |
static struct inlineCache val = _ILC1; |
697 |
int indexLow, indexHigh; |
|
698 |
||
586
cab695f942a6
weakArray readBarrier for IGC
Claus Gittinger <cg@exept.de>
parents:
577
diff
changeset
|
699 |
if (__bothSmallInteger(start, stop) |
1133 | 700 |
&& (__qClass(self) == @global(Array))) { |
701 |
indexLow = __intVal(start); |
|
155 | 702 |
if (indexLow > 0) { |
1133 | 703 |
indexHigh = __intVal(stop); |
328 | 704 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
155 | 705 |
if (indexHigh <= nIndex) { |
706 |
indexLow--; |
|
707 |
indexHigh--; |
|
708 |
if (__isBlockLike(aBlock) |
|
1133 | 709 |
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
710 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
|
42 | 711 |
#ifdef NEW_BLOCK_CALL |
155 | 712 |
for (index=indexHigh; index >= indexLow; index--) { |
421 | 713 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 714 |
(*codeVal)(aBlock, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 715 |
} |
42 | 716 |
#else |
1133 | 717 |
home = __BlockInstPtr(aBlock)->b_home; |
155 | 718 |
rHome = home; |
325 | 719 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
155 | 720 |
for (index=indexHigh; index >= indexLow; index--) { |
421 | 721 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 722 |
(*codeVal)(rHome, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 723 |
} |
724 |
} else { |
|
725 |
for (index=indexHigh; index >= indexLow; index--) { |
|
421 | 726 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 727 |
(*codeVal)(home, CON_COMMA __InstPtr(self)->i_instvars[index]); |
155 | 728 |
} |
729 |
} |
|
42 | 730 |
#endif |
155 | 731 |
} else { |
732 |
for (index=indexHigh; index >= indexLow; index--) { |
|
421 | 733 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
155 | 734 |
(*val.ilc_func) (aBlock, |
735 |
@symbol(value:), |
|
736 |
CON_COMMA nil, &val, |
|
1133 | 737 |
__InstPtr(self)->i_instvars[index]); |
155 | 738 |
} |
739 |
} |
|
740 |
} |
|
741 |
RETURN ( self ); |
|
742 |
} |
|
42 | 743 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
744 |
%}. |
42 | 745 |
^ super from:start to:stop reverseDo:aBlock |
746 |
! |
|
747 |
||
554 | 748 |
keysAndValuesDo:aBlock |
749 |
"evaluate the argument, aBlock for each element in the collection. |
|
750 |
Pass both index and element to the block. |
|
751 |
- reimplemented for speed" |
|
752 |
||
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
753 |
|home sz "{ Class: SmallInteger }" | |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
754 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
755 |
sz := self size. |
554 | 756 |
%{ |
757 |
REGISTER OBJFUNC codeVal; |
|
758 |
REGISTER int index; |
|
759 |
unsigned int nIndex; |
|
760 |
static struct inlineCache val2 = _ILC2; |
|
761 |
REGISTER OBJ rHome; |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
762 |
int actualSize; |
554 | 763 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
764 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
765 |
|
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
766 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
767 |
nIndex = index + __intVal(sz); |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
768 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
769 |
if (nIndex <= actualSize) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
770 |
if (__isBlockLike(aBlock) |
1133 | 771 |
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
772 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { |
|
554 | 773 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
774 |
for (; index < nIndex; index++) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
775 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 776 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
777 |
(*codeVal)(aBlock, CON_COMMA __MKSMALLINT(index+1), |
1133 | 778 |
__InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
779 |
} |
554 | 780 |
#else |
1133 | 781 |
home = __BlockInstPtr(aBlock)->b_home; |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
782 |
rHome = home; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
783 |
if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
784 |
/* |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
785 |
* home will not move - keep in a fast register |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
786 |
*/ |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
787 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
788 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 789 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
790 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
791 |
(*codeVal)(rHome, CON_COMMA __MKSMALLINT(index), |
1133 | 792 |
__InstPtr(self)->i_instvars[index-1]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
793 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
794 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
795 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
796 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 797 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
798 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
799 |
(*codeVal)(home, CON_COMMA __MKSMALLINT(index), |
1133 | 800 |
__InstPtr(self)->i_instvars[index-1]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
801 |
} |
554 | 802 |
} |
803 |
#endif |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
804 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
805 |
while (index < nIndex) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
806 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
554 | 807 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
808 |
index++; |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
809 |
(*val2.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
810 |
@symbol(value:value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
811 |
CON_COMMA nil, &val2, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
812 |
__MKSMALLINT(index), |
1133 | 813 |
__InstPtr(self)->i_instvars[index-1]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
814 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
815 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
816 |
RETURN (self); |
554 | 817 |
} |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
818 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
819 |
^ super keysAndValuesDo:aBlock |
554 | 820 |
! |
821 |
||
543 | 822 |
reverseDo:aBlock |
823 |
"evaluate the argument, aBlock for each element in the collection in reverse order. |
|
824 |
- reimplemented for speed" |
|
1 | 825 |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
826 |
|home sz "{ Class: SmallInteger }" | |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
827 |
|
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
828 |
sz := self size. |
1 | 829 |
%{ |
830 |
REGISTER OBJFUNC codeVal; |
|
831 |
REGISTER int index; |
|
543 | 832 |
unsigned int nIndex; |
833 |
int endIndex; |
|
1 | 834 |
static struct inlineCache val = _ILC1; |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
835 |
int actualSize; |
1 | 836 |
|
1133 | 837 |
endIndex = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
838 |
actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
839 |
nIndex = endIndex + __intVal(sz); |
543 | 840 |
|
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
841 |
if (nIndex <= actualSize) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
842 |
if (__isBlockLike(aBlock) |
1133 | 843 |
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) |
844 |
&& (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { |
|
11 | 845 |
#ifdef NEW_BLOCK_CALL |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
846 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
847 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 848 |
(*codeVal)(aBlock, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
849 |
} |
11 | 850 |
#else |
1133 | 851 |
home = __BlockInstPtr(aBlock)->b_home; |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
852 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
853 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
1133 | 854 |
(*codeVal)(home, CON_COMMA __InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
855 |
} |
11 | 856 |
#endif |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
857 |
} else { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
858 |
for (index=nIndex-1; index >= endIndex; index--) { |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
859 |
if (InterruptPending != nil) __interruptL(@line COMMA_CON); |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
860 |
(*val.ilc_func)(aBlock, |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
861 |
@symbol(value:), |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
862 |
CON_COMMA nil, &val, |
1133 | 863 |
__InstPtr(self)->i_instvars[index]); |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
864 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
865 |
} |
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
866 |
RETURN (self); |
1 | 867 |
} |
543 | 868 |
%}. |
946
35962f2a169b
be prepared for cheaters, subclassing Array returning invalid sizes ...
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
869 |
^ super reverseDo:aBlock |
11 | 870 |
! |
871 |
||
328 | 872 |
traverse:aBlock |
873 |
"Evaluate aBlock for every element that is not an Array, |
|
1123 | 874 |
and recursively traverse Arrays. |
328 | 875 |
Implemented here to support better search for selectors in |
876 |
literal arrays - might be a good idea to move it up in the collection |
|
877 |
hierarchy, since this may be a useful method for other collections |
|
878 |
as well." |
|
879 |
||
880 |
self do: [:el | |
|
1123 | 881 |
el isArray |
882 |
ifTrue: [el traverse: aBlock] |
|
883 |
ifFalse: [aBlock value: el]] |
|
328 | 884 |
|
885 |
" |
|
886 |
example: flattening an Array: |
|
887 |
||
888 |
|s| |
|
889 |
||
890 |
s := WriteStream on:Array new. |
|
891 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | s nextPut:el]. |
|
892 |
s contents |
|
893 |
" |
|
1123 | 894 |
" |
895 |
example: deep search |
|
896 |
||
897 |
#(1 2 (3 (4 5 (6 7) 8) 9 10) 11 (12 (13)) 14) traverse:[:el | |
|
898 |
el == 10 ifTrue:[Transcript showCr:'found'] |
|
899 |
] |
|
900 |
" |
|
901 |
||
902 |
"Modified: 26.3.1996 / 17:08:10 / cg" |
|
543 | 903 |
! ! |
904 |
||
905 |
!Array methodsFor:'filling & replacing'! |
|
906 |
||
554 | 907 |
from:index1 to:index2 put:anObject |
908 |
"reimplemented for speed if receiver is an Array" |
|
909 |
||
910 |
%{ /* NOCONTEXT */ |
|
911 |
||
912 |
REGISTER int index; |
|
913 |
unsigned int nIndex; |
|
914 |
unsigned int endIndex; |
|
915 |
REGISTER OBJ *dst; |
|
916 |
||
917 |
if ((__qClass(self) == Array) |
|
918 |
&& __bothSmallInteger(index1, index2)) { |
|
1133 | 919 |
index = __intVal(index1) - 1; |
554 | 920 |
if (index >= 0) { |
921 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1133 | 922 |
endIndex = __intVal(index2) - 1; |
951
2dd898849a8a
directly call __new if quick allocation fails;
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
923 |
if ((endIndex >= index) && (endIndex < nIndex)) { |
1133 | 924 |
dst = &(__InstPtr(self)->i_instvars[index]); |
554 | 925 |
#ifdef memset4 |
926 |
memset4(dst, anObject, (endIndex-index+1)); |
|
927 |
__STORE(self, anObject); |
|
928 |
#else |
|
929 |
if ((INT)anObject == 0) { |
|
930 |
memset(dst, 0, __OBJS2BYTES__(endIndex-index+1)); |
|
931 |
} else { |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
932 |
# if defined(UNROLL_LOOPS) |
554 | 933 |
{ |
934 |
int i8; |
|
935 |
||
936 |
while ((i8 = index + 8) <= endIndex) { |
|
937 |
dst[0] = anObject; |
|
938 |
dst[1] = anObject; |
|
939 |
dst[2] = anObject; |
|
940 |
dst[3] = anObject; |
|
941 |
dst[4] = anObject; |
|
942 |
dst[5] = anObject; |
|
943 |
dst[6] = anObject; |
|
944 |
dst[7] = anObject; |
|
945 |
dst += 8; |
|
946 |
index = i8; |
|
947 |
} |
|
948 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
949 |
# endif |
554 | 950 |
for (; index <= endIndex; index++) { |
951 |
*dst++ = anObject; |
|
952 |
} |
|
953 |
__STORE(self, anObject); |
|
954 |
} |
|
955 |
#endif |
|
956 |
RETURN ( self ); |
|
957 |
} |
|
958 |
} |
|
959 |
} |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
960 |
%}. |
554 | 961 |
^ super from:index1 to:index2 put:anObject |
962 |
! |
|
963 |
||
543 | 964 |
replaceFrom:start to:stop with:aCollection startingAt:repStart |
1168 | 965 |
"replace elements in the receiver between index start and stop, |
966 |
with elements taken from replacementCollection starting at repStart. |
|
967 |
Reimplemented for speed if both receiver and aCollection are Arrays" |
|
543 | 968 |
|
969 |
%{ /* NOCONTEXT */ |
|
970 |
||
971 |
unsigned int nIndex; |
|
972 |
unsigned int repNIndex; |
|
973 |
int startIndex, stopIndex; |
|
974 |
REGISTER OBJ *src; |
|
975 |
REGISTER OBJ *dst; |
|
976 |
int repStopIndex; |
|
977 |
REGISTER int repStartIndex; |
|
978 |
REGISTER OBJ t; |
|
979 |
REGISTER int count; |
|
980 |
||
981 |
||
1133 | 982 |
if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) |
543 | 983 |
&& (((t = __Class(aCollection)) == Array) || (t == __qClass(self))) |
984 |
&& __bothSmallInteger(start, stop) |
|
985 |
&& __isSmallInteger(repStart)) { |
|
1168 | 986 |
startIndex = __intVal(start) - 1; |
987 |
if (startIndex >= 0) { |
|
988 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
989 |
stopIndex = __intVal(stop) - 1; |
|
990 |
count = stopIndex - startIndex + 1; |
|
991 |
if (count == 0) { |
|
992 |
RETURN ( self ); |
|
993 |
} |
|
994 |
if ((count > 0) && (stopIndex < nIndex)) { |
|
995 |
repStartIndex = __intVal(repStart) - 1; |
|
996 |
if (repStartIndex >= 0) { |
|
997 |
repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
|
998 |
repStopIndex = repStartIndex + (stopIndex - startIndex); |
|
999 |
if (repStopIndex < repNIndex) { |
|
1000 |
src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
|
1001 |
dst = &(__InstPtr(self)->i_instvars[startIndex]); |
|
1002 |
if (aCollection == self) { |
|
1003 |
/* |
|
1004 |
* no need to check stores if copying |
|
1005 |
* from myself |
|
1006 |
*/ |
|
1007 |
/* |
|
1008 |
* take care of overlapping copy |
|
1009 |
* do not depend on memset being smart enough |
|
1010 |
* (some are not ;-) |
|
1011 |
*/ |
|
1012 |
if (src < dst) { |
|
1013 |
/* must do a reverse copy */ |
|
1014 |
src += count; |
|
1015 |
dst += count; |
|
543 | 1016 |
#if defined(UNROLL_LOOPS) |
1168 | 1017 |
while (count > 8) { |
1018 |
dst[-1] = src[-1]; |
|
1019 |
dst[-2] = src[-2]; |
|
1020 |
dst[-3] = src[-3]; |
|
1021 |
dst[-4] = src[-4]; |
|
1022 |
dst[-5] = src[-5]; |
|
1023 |
dst[-6] = src[-6]; |
|
1024 |
dst[-7] = src[-7]; |
|
1025 |
dst[-8] = src[-8]; |
|
1026 |
dst -= 8; src -= 8; |
|
1027 |
count -= 8; |
|
1028 |
} |
|
543 | 1029 |
#endif |
1168 | 1030 |
while (count-- > 0) { |
1031 |
*--dst = *--src; |
|
1032 |
} |
|
1033 |
RETURN ( self ); |
|
1034 |
} |
|
543 | 1035 |
#ifdef bcopy4 |
1168 | 1036 |
bcopy4(src, dst, count); |
543 | 1037 |
#else |
1038 |
# ifdef FAST_MEMCPY |
|
1168 | 1039 |
bcopy(src, dst, __OBJS2BYTES__(count)); |
543 | 1040 |
# else |
1168 | 1041 |
while (count--) { |
1042 |
*dst++ = *src++; |
|
1043 |
} |
|
543 | 1044 |
# endif |
1045 |
#endif |
|
1168 | 1046 |
} else { |
1047 |
REGISTER int spc; |
|
543 | 1048 |
|
1168 | 1049 |
spc = __qSpace(self); |
543 | 1050 |
#if defined(UNROLL_LOOPS) |
1168 | 1051 |
while (count >= 4) { |
1052 |
t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
|
1053 |
t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
|
1054 |
t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
|
1055 |
t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
|
1056 |
count -= 4; src += 4; dst += 4; |
|
1057 |
} |
|
543 | 1058 |
#endif |
1168 | 1059 |
while (count-- > 0) { |
1060 |
t = *src++; |
|
1061 |
*dst++ = t; |
|
1062 |
__STORE_SPC(self, t, spc); |
|
1063 |
} |
|
1064 |
} |
|
1065 |
RETURN ( self ); |
|
1066 |
} |
|
1067 |
} |
|
1068 |
} |
|
1069 |
} |
|
543 | 1070 |
} |
1071 |
%}. |
|
1072 |
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
|
1168 | 1073 |
|
1074 |
"Modified: 13.4.1996 / 12:17:13 / cg" |
|
543 | 1075 |
! ! |
1076 |
||
1077 |
!Array methodsFor:'printing & storing'! |
|
1078 |
||
1079 |
displayString |
|
1080 |
"return a printed representation of the receiver for displaying" |
|
1081 |
||
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1082 |
|s sz| |
543 | 1083 |
|
1084 |
(self isLiteral) ifTrue:[ |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1085 |
s := WriteStream on:String new. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1086 |
s nextPutAll:'#('. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1087 |
sz := self size. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1088 |
self keysAndValuesDo:[:idx :element | |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1089 |
s nextPutAll:element displayString. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1090 |
idx ~~ sz ifTrue:[s space] |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1091 |
]. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1092 |
s nextPutAll:')'. |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1093 |
^ s contents |
543 | 1094 |
]. |
1095 |
^ super displayString |
|
1083
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1096 |
|
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1097 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1098 |
#(1 2 3 4) displayString |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1099 |
#(1 2 3 4) printString |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1100 |
" |
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1101 |
|
fadaedfa28f8
cosmetic change - no space after last element in displayString
Claus Gittinger <cg@exept.de>
parents:
951
diff
changeset
|
1102 |
"Modified: 7.3.1996 / 15:10:28 / cg" |
543 | 1103 |
! |
1104 |
||
1105 |
storeOn:aStream |
|
1106 |
"append a printed representation of the receiver to aStream, |
|
1107 |
which allows reconstructing it via readFrom:. |
|
1108 |
Redefined to output a somewhat more user friendly string." |
|
1109 |
||
1110 |
self isLiteral ifTrue:[ |
|
588 | 1111 |
aStream nextPutAll:'#('. |
1112 |
self do:[:element | element storeOn:aStream. aStream space]. |
|
1113 |
aStream nextPutAll:')' |
|
543 | 1114 |
] ifFalse:[ |
588 | 1115 |
super storeOn:aStream |
543 | 1116 |
] |
1117 |
||
1118 |
" |
|
1119 |
#(1 2 $a 'hello') storeString |
|
588 | 1120 |
#(1 2 $a [1 2 3]) storeString |
543 | 1121 |
" |
588 | 1122 |
|
1123 |
"Created: 20.11.1995 / 11:16:58 / cg" |
|
543 | 1124 |
! ! |
1125 |
||
1126 |
!Array methodsFor:'queries'! |
|
1127 |
||
1128 |
isArray |
|
1129 |
"return true, if the receiver is some kind of array (or weakArray etc). |
|
1130 |
true is returned here" |
|
1131 |
||
1132 |
^ true |
|
1133 |
! |
|
1134 |
||
1135 |
isLiteral |
|
1136 |
"return true, if the receiver can be used as a literal |
|
1137 |
(i.e. can be used in constant arrays)" |
|
1138 |
||
1244 | 1139 |
"/ no, simply returning true here is a mistake: |
1140 |
"/ it could be a subclass of Array |
|
1141 |
"/ (of which the compiler does not know at all ...) |
|
1142 |
||
543 | 1143 |
self class == Array ifFalse:[^ false]. |
1144 |
||
1244 | 1145 |
"/ |
1146 |
"/ care for recursive arrays ... |
|
1147 |
"/ |
|
543 | 1148 |
thisContext isRecursive ifTrue:[^ false]. |
1149 |
self do:[:element | |
|
1244 | 1150 |
element isLiteral ifFalse:[^ false] |
543 | 1151 |
]. |
1152 |
^ true |
|
1244 | 1153 |
|
1154 |
"Modified: 22.4.1996 / 12:55:19 / cg" |
|
328 | 1155 |
! |
1156 |
||
1243 | 1157 |
refersToLiteral:aLiteral |
1158 |
"return true if the receiver or recursively any array element in the |
|
1159 |
receiver referes to aLiteral" |
|
1160 |
||
543 | 1161 |
self do: [ :el | |
1243 | 1162 |
el == aLiteral ifTrue:[^true]. |
1163 |
el class == Array ifTrue:[ |
|
1164 |
(el refersToLiteral: aLiteral) ifTrue: [^true] |
|
1165 |
] |
|
543 | 1166 |
]. |
1167 |
^ false |
|
1168 |
||
1169 |
" |
|
1170 |
#(1 2 3) refersToLiteral:#foo |
|
1171 |
#(1 2 3 foo bar baz) refersToLiteral:#foo |
|
1172 |
#(1 2 3 (((bar foo))) bar baz) refersToLiteral:#foo |
|
1173 |
" |
|
1243 | 1174 |
|
1175 |
"Modified: 22.4.1996 / 12:41:46 / cg" |
|
543 | 1176 |
! ! |
1177 |
||
1178 |
!Array methodsFor:'testing'! |
|
1179 |
||
554 | 1180 |
identityIndexOf:anElement or:alternative |
1181 |
"search the array for anElement or alternative; |
|
1182 |
return the index of anElement if found, or the index of anAlternative, |
|
1183 |
if not found. If anAlternative is also not found, return 0. |
|
1184 |
This is a special interface for high-speed searching in an array |
|
1185 |
and at the same time searching for an empty slot. |
|
1186 |
Do not use this method for your application classes, since it is |
|
1187 |
not portable (i.e. other smalltalks do not offer this)" |
|
1188 |
||
1189 |
%{ /* NOCONTEXT */ |
|
1190 |
||
1191 |
REGISTER int index; |
|
1192 |
REGISTER OBJ o, el1, el2; |
|
1193 |
REGISTER OBJ *op; |
|
1194 |
REGISTER unsigned int nIndex; |
|
1195 |
int altIndex = 0; |
|
1196 |
int nInsts; |
|
1197 |
||
1198 |
index = 0; |
|
1133 | 1199 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
554 | 1200 |
index += nInsts; |
1201 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1202 |
el1 = anElement; el2 = alternative; |
|
1133 | 1203 |
op = & (__InstPtr(self)->i_instvars[index]); |
554 | 1204 |
while (index++ < nIndex) { |
1205 |
if ((o = *op++) == el1) { |
|
1206 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
|
1207 |
} |
|
1208 |
if (o == el2) { |
|
1209 |
if (altIndex == 0) { |
|
1210 |
altIndex = index; |
|
1211 |
} |
|
1212 |
} |
|
1213 |
} |
|
1214 |
RETURN ( __MKSMALLINT(altIndex) ); |
|
1215 |
%} |
|
1216 |
||
1217 |
" |
|
1218 |
#(1 2 3 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1219 |
#(1 2 0 4 5 6 7 8 9) identityIndexOf:3 or:5 |
|
1220 |
#(1 2 0 4 5 6 7 3 9) identityIndexOf:3 or:5 |
|
1221 |
#(1 2 3 4 5 nil 7 3 9) identityIndexOf:3 or:nil |
|
1222 |
#(1 2 nil 4 5 6 7 3 9) identityIndexOf:3 or:nil |
|
1223 |
#(1 2 nil 4 5 6 7 8 9) identityIndexOf:3 or:nil |
|
1224 |
#() identityIndexOf:3 or:nil |
|
1225 |
#(1 2) identityIndexOf:3 or:nil |
|
1226 |
" |
|
1227 |
! |
|
1228 |
||
543 | 1229 |
identityIndexOf:anElement startingAt:start |
1230 |
"search the array for anElement; return index if found, 0 otherwise |
|
1231 |
- reimplemented for speed" |
|
1232 |
||
1233 |
%{ /* NOCONTEXT */ |
|
1234 |
||
1235 |
REGISTER int index; |
|
1236 |
REGISTER OBJ el; |
|
1237 |
REGISTER OBJ *op; |
|
1238 |
REGISTER unsigned int nIndex; |
|
1239 |
int nInsts; |
|
1240 |
||
1241 |
if (__isSmallInteger(start)) { |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1242 |
index = __intVal(start) - 1; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1243 |
if (index >= 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1244 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1245 |
index += nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1246 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1247 |
el = anElement; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1248 |
op = & (__InstPtr(self)->i_instvars[index]); |
543 | 1249 |
#if defined(UNROLL_LOOPS) |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1250 |
{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1251 |
unsigned int i8; |
11 | 1252 |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1253 |
while ((i8 = index + 8) < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1254 |
if (op[0] == el) { RETURN ( __MKSMALLINT(index + 1 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1255 |
if (op[1] == el) { RETURN ( __MKSMALLINT(index + 2 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1256 |
if (op[2] == el) { RETURN ( __MKSMALLINT(index + 3 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1257 |
if (op[3] == el) { RETURN ( __MKSMALLINT(index + 4 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1258 |
if (op[4] == el) { RETURN ( __MKSMALLINT(index + 5 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1259 |
if (op[5] == el) { RETURN ( __MKSMALLINT(index + 6 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1260 |
if (op[6] == el) { RETURN ( __MKSMALLINT(index + 7 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1261 |
if (op[7] == el) { RETURN ( __MKSMALLINT(index + 8 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1262 |
index = i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1263 |
op += 8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1264 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1265 |
} |
543 | 1266 |
#endif |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1267 |
while (index++ < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1268 |
if (*op++ == el) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1269 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1270 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1271 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1272 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1273 |
RETURN ( __MKSMALLINT(0) ); |
543 | 1274 |
} |
1275 |
%}. |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1276 |
^ self indexNotInteger |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1277 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1278 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1279 |
! |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1280 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1281 |
identityIndexOf:anElement startingAt:start endingAt:stop |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1282 |
"search the array for anElement in the range start..stop; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1283 |
return the index if found, 0 otherwise. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1284 |
- reimplemented for speed when searching in OrderedCollections" |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1285 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1286 |
%{ /* NOCONTEXT */ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1287 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1288 |
REGISTER int index; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1289 |
REGISTER OBJ el; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1290 |
REGISTER OBJ *op; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1291 |
REGISTER unsigned int lastIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1292 |
unsigned int nIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1293 |
int nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1294 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1295 |
if (__bothSmallInteger(start, stop)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1296 |
index = __intVal(start) - 1; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1297 |
if (index >= 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1298 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1299 |
index += nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1300 |
lastIndex = nInsts + __intVal(stop); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1301 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1302 |
if (nIndex < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1303 |
lastIndex = nIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1304 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1305 |
el = anElement; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1306 |
op = & (__InstPtr(self)->i_instvars[index]); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1307 |
#if defined(UNROLL_LOOPS) |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1308 |
{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1309 |
unsigned int i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1310 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1311 |
while ((i8 = index + 8) < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1312 |
if (op[0] == el) { RETURN ( __MKSMALLINT(index + 1 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1313 |
if (op[1] == el) { RETURN ( __MKSMALLINT(index + 2 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1314 |
if (op[2] == el) { RETURN ( __MKSMALLINT(index + 3 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1315 |
if (op[3] == el) { RETURN ( __MKSMALLINT(index + 4 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1316 |
if (op[4] == el) { RETURN ( __MKSMALLINT(index + 5 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1317 |
if (op[5] == el) { RETURN ( __MKSMALLINT(index + 6 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1318 |
if (op[6] == el) { RETURN ( __MKSMALLINT(index + 7 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1319 |
if (op[7] == el) { RETURN ( __MKSMALLINT(index + 8 - nInsts) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1320 |
index = i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1321 |
op += 8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1322 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1323 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1324 |
#endif |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1325 |
while (index++ < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1326 |
if (*op++ == el) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1327 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1328 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1329 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1330 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1331 |
RETURN ( __MKSMALLINT(0) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1332 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1333 |
%}. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1334 |
^ self indexNotInteger |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1335 |
|
543 | 1336 |
! |
1337 |
||
1338 |
includes:anObject |
|
1339 |
"return true, if the argument, anObject is contained in the array |
|
1340 |
- reimplemented for speed" |
|
1341 |
||
1342 |
|element| |
|
1343 |
||
1344 |
%{ /* NOCONTEXT */ |
|
1345 |
||
1346 |
/* |
|
1347 |
* first, do a quick check using == |
|
1348 |
* this does not need a context or message send. |
|
1349 |
* In many cases this will already find a match. |
|
1350 |
*/ |
|
1351 |
REGISTER int index; |
|
1352 |
REGISTER OBJ o; |
|
1353 |
unsigned int nIndex; |
|
1354 |
||
1355 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1133 | 1356 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
543 | 1357 |
|
1358 |
/* |
|
1359 |
* however, the search is limited to the first 1000 |
|
1360 |
* elements, since otherwise, we may spend too much time |
|
1361 |
* searching for identity if an equal value is found early |
|
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1362 |
* (except if searching for nil - there is no need for equal compare ...) |
543 | 1363 |
*/ |
945
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1364 |
if (nIndex > 1000) { |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1365 |
if (o != nil) |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1366 |
nIndex = 1000; |
b2a1dc200c42
allow redefinition of #size in subclasses (optimized methods did not work in this case)
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
1367 |
} |
543 | 1368 |
|
1369 |
o = anObject; |
|
1370 |
#if defined(UNROLL_LOOPS) |
|
1371 |
{ |
|
1372 |
unsigned int i8; |
|
1373 |
||
1374 |
while ((i8 = index + 8) < nIndex) { |
|
1133 | 1375 |
if (__InstPtr(self)->i_instvars[index] == o) { RETURN ( true ); } |
1376 |
if (__InstPtr(self)->i_instvars[index+1] == o) { RETURN ( true ); } |
|
1377 |
if (__InstPtr(self)->i_instvars[index+2] == o) { RETURN ( true ); } |
|
1378 |
if (__InstPtr(self)->i_instvars[index+3] == o) { RETURN ( true ); } |
|
1379 |
if (__InstPtr(self)->i_instvars[index+4] == o) { RETURN ( true ); } |
|
1380 |
if (__InstPtr(self)->i_instvars[index+5] == o) { RETURN ( true ); } |
|
1381 |
if (__InstPtr(self)->i_instvars[index+6] == o) { RETURN ( true ); } |
|
1382 |
if (__InstPtr(self)->i_instvars[index+7] == o) { RETURN ( true ); } |
|
543 | 1383 |
index = i8; |
1384 |
} |
|
1385 |
} |
|
1386 |
#endif |
|
1387 |
while (index < nIndex) { |
|
1133 | 1388 |
if (__InstPtr(self)->i_instvars[index++] == o) { |
543 | 1389 |
RETURN ( true ); |
1390 |
} |
|
1391 |
} |
|
1392 |
if (o == nil) { |
|
1393 |
RETURN ( false ); |
|
1394 |
} |
|
1395 |
%} |
|
1396 |
. |
|
1397 |
%{ |
|
1398 |
/* |
|
1399 |
* then do a slow(er) check using = |
|
1400 |
*/ |
|
1401 |
REGISTER int index; |
|
1402 |
unsigned int nIndex; |
|
1403 |
static struct inlineCache eq = _ILC1; |
|
11 | 1404 |
|
543 | 1405 |
/* |
1406 |
* sorry: cannot access the stuff from above ... |
|
1407 |
*/ |
|
1408 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
1133 | 1409 |
index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
543 | 1410 |
|
1411 |
while (index < nIndex) { |
|
1133 | 1412 |
element = __InstPtr(self)->i_instvars[index++]; |
543 | 1413 |
if (element != nil) { |
1414 |
if ((*eq.ilc_func)(anObject, |
|
1415 |
@symbol(=), |
|
1416 |
CON_COMMA nil,&eq, |
|
1417 |
element)==true) { |
|
1418 |
RETURN ( true ); |
|
1419 |
} |
|
1420 |
} |
|
1421 |
} |
|
1422 |
%}. |
|
1423 |
^ false |
|
1424 |
! |
|
1425 |
||
554 | 1426 |
indexOf:anElement startingAt:start |
1427 |
"search the array for anElement; return index if found, 0 otherwise |
|
1428 |
- reimplemented for speed" |
|
543 | 1429 |
|
554 | 1430 |
|element| |
1431 |
%{ |
|
543 | 1432 |
REGISTER int index; |
554 | 1433 |
unsigned int nIndex, nInsts; |
1434 |
static struct inlineCache eq = _ILC1; |
|
543 | 1435 |
|
554 | 1436 |
if (__isSmallInteger(start)) { |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1437 |
index = __intVal(start) - 1; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1438 |
if (index >= 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1439 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1440 |
index += nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1441 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1442 |
if (anElement != nil) { |
825
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1443 |
#define SPECIAL_STRING_OPT |
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1444 |
#ifdef SPECIAL_STRING_OPT |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1445 |
if (__isString(anElement)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1446 |
while (index < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1447 |
element = __InstPtr(self)->i_instvars[index++]; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1448 |
if (__isNonNilObject(element)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1449 |
if (element == anElement) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1450 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1451 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1452 |
if (__qClass(element) == @global(String)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1453 |
if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1454 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1455 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1456 |
} else { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1457 |
if ((*eq.ilc_func)(anElement, @symbol(=), CON_COMMA nil,&eq, element) == true) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1458 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1459 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1460 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1461 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1462 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1463 |
RETURN (__MKSMALLINT(0)); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1464 |
} |
825
f7b73d83b9d4
optimized search for strings (dont know if its worth it ...)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
1465 |
#endif |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1466 |
while (index < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1467 |
element = __InstPtr(self)->i_instvars[index++]; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1468 |
if (element != nil) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1469 |
if ((element == anElement) |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1470 |
|| ((*eq.ilc_func)(anElement, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1471 |
@symbol(=), |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1472 |
CON_COMMA nil,&eq, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1473 |
element) == true)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1474 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1475 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1476 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1477 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1478 |
} else { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1479 |
/* search for nil */ |
554 | 1480 |
#if defined(UNROLL_LOOPS) |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1481 |
{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1482 |
unsigned int i8; |
554 | 1483 |
|
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1484 |
while ((i8 = index + 8) < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1485 |
if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1486 |
if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1487 |
if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1488 |
if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1489 |
if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1490 |
if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1491 |
if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1492 |
if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1493 |
index = i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1494 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1495 |
} |
554 | 1496 |
#endif |
1497 |
||
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1498 |
while (index < nIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1499 |
if (__InstPtr(self)->i_instvars[index++] == nil) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1500 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1501 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1502 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1503 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1504 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1505 |
RETURN (__MKSMALLINT(0)); |
543 | 1506 |
} |
554 | 1507 |
%}. |
1158
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1508 |
^ self indexNotInteger |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1509 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1510 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1511 |
! |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1512 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1513 |
indexOf:anElement startingAt:start endingAt:stop |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1514 |
"search the array for anElement in the range start..stop; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1515 |
Return the index if found, 0 otherwise. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1516 |
- reimplemented for speed when searching in OrderedCollections" |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1517 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1518 |
|element| |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1519 |
%{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1520 |
REGISTER int index; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1521 |
unsigned int lastIndex, nIndex, nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1522 |
static struct inlineCache eq = _ILC1; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1523 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1524 |
if (__bothSmallInteger(start, stop)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1525 |
index = __intVal(start) - 1; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1526 |
if (index >= 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1527 |
nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1528 |
index += nInsts; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1529 |
lastIndex = nInsts + __intVal(stop); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1530 |
nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1531 |
if (nIndex < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1532 |
lastIndex = nIndex; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1533 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1534 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1535 |
if (anElement != nil) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1536 |
#ifdef SPECIAL_STRING_OPT |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1537 |
if (__isString(anElement)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1538 |
while (index < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1539 |
element = __InstPtr(self)->i_instvars[index++]; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1540 |
if (__isNonNilObject(element)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1541 |
if (element == anElement) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1542 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1543 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1544 |
if (__qClass(element) == @global(String)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1545 |
if (strcmp(__stringVal(anElement), __stringVal(element)) == 0) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1546 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1547 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1548 |
} else { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1549 |
if ((*eq.ilc_func)(anElement, @symbol(=), CON_COMMA nil,&eq, element) == true) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1550 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1551 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1552 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1553 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1554 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1555 |
RETURN (__MKSMALLINT(0)); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1556 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1557 |
#endif |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1558 |
while (index < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1559 |
element = __InstPtr(self)->i_instvars[index++]; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1560 |
if (element != nil) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1561 |
if ((element == anElement) |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1562 |
|| ((*eq.ilc_func)(anElement, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1563 |
@symbol(=), |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1564 |
CON_COMMA nil,&eq, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1565 |
element) == true)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1566 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1567 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1568 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1569 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1570 |
} else { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1571 |
if (__isSmallInteger(anElement)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1572 |
/* search for a small number */ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1573 |
while (index < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1574 |
element = __InstPtr(self)->i_instvars[index++]; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1575 |
if (element == anElement) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1576 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1577 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1578 |
if (!__isSmallInteger(element)) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1579 |
if ((*eq.ilc_func)(anElement, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1580 |
@symbol(=), |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1581 |
CON_COMMA nil,&eq, |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1582 |
element) == true) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1583 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1584 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1585 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1586 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1587 |
} else { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1588 |
/* search for nil */ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1589 |
#if defined(UNROLL_LOOPS) |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1590 |
{ |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1591 |
unsigned int i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1592 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1593 |
while ((i8 = index + 8) < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1594 |
if (__InstPtr(self)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1595 |
if (__InstPtr(self)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1596 |
if (__InstPtr(self)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1597 |
if (__InstPtr(self)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1598 |
if (__InstPtr(self)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1599 |
if (__InstPtr(self)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1600 |
if (__InstPtr(self)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1601 |
if (__InstPtr(self)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1602 |
index = i8; |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1603 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1604 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1605 |
#endif |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1606 |
|
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1607 |
while (index < lastIndex) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1608 |
if (__InstPtr(self)->i_instvars[index++] == nil) { |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1609 |
RETURN ( __MKSMALLINT(index - nInsts) ); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1610 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1611 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1612 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1613 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1614 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1615 |
RETURN (__MKSMALLINT(0)); |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1616 |
} |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1617 |
%}. |
bf9aec9e892c
added range search (mostly for big orderedCollections)
Claus Gittinger <cg@exept.de>
parents:
1143
diff
changeset
|
1618 |
^ self indexNotInteger |
1 | 1619 |
! ! |
543 | 1620 |
|
626 | 1621 |
!Array class methodsFor:'documentation'! |
1622 |
||
1623 |
version |
|
1290 | 1624 |
^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.68 1996-04-25 16:13:49 cg Exp $' |
1244 | 1625 |
! ! |