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