author | Claus Gittinger <cg@exept.de> |
Mon, 25 Jan 2016 19:49:59 +0100 | |
changeset 19099 | 3b1589b9e193 |
parent 18465 | e9e4bb62235f |
child 19106 | cfeb2d0d1ee4 |
permissions | -rw-r--r-- |
15133 | 1 |
" |
2 |
COPYRIGHT. |
|
3 |
This is a Manchester Goodie protected by copyright. |
|
4 |
These conditions are imposed on the whole Goodie, and on any significant |
|
5 |
part of it which is separately transmitted or stored: |
|
6 |
* You must ensure that every copy includes this notice, and that |
|
7 |
source and author(s) of the material are acknowledged. |
|
8 |
* These conditions must be imposed on anyone who receives a copy. |
|
9 |
* The material shall not be used for commercial gain without the prior |
|
10 |
written consent of the author(s). |
|
11 |
Further information on the copyright conditions may be obtained by |
|
12 |
sending electronic mail: |
|
13 |
To: goodies-lib@cs.man.ac.uk |
|
14 |
Subject: copyright |
|
15 |
or by writing to The Smalltalk Goodies Library Manager, Dept of |
|
16 |
Computer Science, The University, Manchester M13 9PL, UK |
|
17 |
||
18 |
(C) Copyright 1992 University of Manchester |
|
19 |
For more information about the Manchester Goodies Library (from which |
|
20 |
this file was distributed) send e-mail: |
|
21 |
To: goodies-lib@cs.man.ac.uk |
|
22 |
Subject: help |
|
23 |
" |
|
15134
84e886ef6b5f
Packet change libbasic2 -> libbasic
Stefan Vogel <sv@exept.de>
parents:
15133
diff
changeset
|
24 |
"{ Package: 'stx:libbasic' }" |
15133 | 25 |
|
18465 | 26 |
"{ NameSpace: Smalltalk }" |
27 |
||
15133 | 28 |
Dictionary subclass:#OrderedDictionary |
29 |
instanceVariableNames:'order' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Collections-Sequenceable' |
|
33 |
! |
|
34 |
||
35 |
!OrderedDictionary class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
39 |
COPYRIGHT. |
|
40 |
This is a Manchester Goodie protected by copyright. |
|
41 |
These conditions are imposed on the whole Goodie, and on any significant |
|
42 |
part of it which is separately transmitted or stored: |
|
43 |
* You must ensure that every copy includes this notice, and that |
|
44 |
source and author(s) of the material are acknowledged. |
|
45 |
* These conditions must be imposed on anyone who receives a copy. |
|
46 |
* The material shall not be used for commercial gain without the prior |
|
47 |
written consent of the author(s). |
|
48 |
Further information on the copyright conditions may be obtained by |
|
49 |
sending electronic mail: |
|
50 |
To: goodies-lib@cs.man.ac.uk |
|
51 |
Subject: copyright |
|
52 |
or by writing to The Smalltalk Goodies Library Manager, Dept of |
|
53 |
Computer Science, The University, Manchester M13 9PL, UK |
|
54 |
||
55 |
(C) Copyright 1992 University of Manchester |
|
56 |
For more information about the Manchester Goodies Library (from which |
|
57 |
this file was distributed) send e-mail: |
|
58 |
To: goodies-lib@cs.man.ac.uk |
|
59 |
Subject: help |
|
60 |
" |
|
61 |
! |
|
62 |
||
63 |
documentation |
|
64 |
" |
|
65 |
I am a subclass of Dictionary whose elements (associations) are ordered in a |
|
66 |
similar fashion to OrderedCollection. |
|
67 |
That is, while being filled via #at:put: messages (or similar Dictionary protocol), |
|
19099 | 68 |
the order in which associations are added, is remembered and accessable via the #atIndex: |
15133 | 69 |
or #order messages. |
70 |
||
71 |
I have one instance variable: |
|
72 |
||
73 |
order <OrderedCollection> Ordered collection of keys reflecting the order of |
|
74 |
associations in the dictionary. |
|
75 |
||
19099 | 76 |
[complexity:] |
77 |
access by index: O(1) |
|
78 |
access by key: O(1) |
|
79 |
searching: O(n) |
|
80 |
insertion: mostly O(1) |
|
81 |
removal: mostly O(N) (because order will have O(n) behavior) |
|
82 |
||
15133 | 83 |
[author:] |
84 |
Ifor Wyn Williams <ifor@uk.ac.man.cs> |
|
15801 | 85 |
Changed by: exept |
15133 | 86 |
|
87 |
[see also:] |
|
88 |
OrderedCollection Dictionary |
|
89 |
OrderedSet |
|
90 |
" |
|
91 |
! |
|
92 |
||
93 |
examples |
|
94 |
" |
|
95 |
|o| |
|
96 |
||
97 |
o := OrderedDictionary new. |
|
98 |
||
99 |
o at:'one' put:1. |
|
100 |
o at:'two' put:2. |
|
101 |
o at:'three' put:3. |
|
102 |
o at:'four' put:4. |
|
103 |
o at:'five' put:5. |
|
104 |
o at:'six' put:6. |
|
105 |
o at:'seven' put:7. |
|
106 |
o at:'eight' put:8. |
|
107 |
o at:'nine' put:9. |
|
108 |
o at:'zero' put:0. |
|
109 |
||
110 |
o at:'eight'. |
|
111 |
o atIndex:1. |
|
112 |
o atIndex:5. |
|
113 |
o atIndex:10. |
|
114 |
||
115 |
o from:3 to:6 do:[:each | Transcript showCR:each ]. |
|
116 |
||
117 |
o collect:[:eachAssoc | eachAssoc key -> eachAssoc value squared]. |
|
118 |
o associations. |
|
119 |
o order. |
|
120 |
o reverse. |
|
121 |
||
122 |
o atIndex:1. |
|
123 |
o atIndex:5. |
|
124 |
o atIndex:10. |
|
125 |
" |
|
126 |
! |
|
127 |
||
128 |
info |
|
129 |
" |
|
130 |
NAME OrderedDictionary |
|
131 |
AUTHOR Ifor Wyn Williams <ifor@uk.ac.man.cs> |
|
132 |
CONTRIBUTOR Ifor Wyn Williams <ifor@uk.ac.man.cs> |
|
133 |
FUNCTION An ordered dictionary |
|
134 |
ST-VERSIONS 2.3-5, 4.0 |
|
135 |
PREREQUISITES |
|
136 |
CONFLICTS |
|
137 |
DISTRIBUTION global |
|
138 |
VERSION 1.2 |
|
139 |
DATE 28.3.90 |
|
140 |
SUMMARY A dictionary that behaves like a SequencableCollection |
|
141 |
(except that associations cannot be removed). |
|
142 |
" |
|
143 |
! ! |
|
144 |
||
145 |
!OrderedDictionary class methodsFor:'instance creation'! |
|
146 |
||
147 |
new |
|
148 |
^ super new initializeOrder |
|
149 |
! |
|
150 |
||
151 |
new: anInteger |
|
152 |
^(super new: anInteger) initializeOrder |
|
153 |
! ! |
|
154 |
||
155 |
!OrderedDictionary methodsFor:'accessing'! |
|
156 |
||
15801 | 157 |
after:anAssociation |
15133 | 158 |
"Return the association after anAssociation in the order. |
15801 | 159 |
If anAssociation is the last association in the order, return nil. |
15133 | 160 |
If anAssociation is not found, invoke an error notifier" |
161 |
||
15801 | 162 |
|sz "{ Class:SmallInteger }"| |
163 |
||
164 |
sz := order size. |
|
165 |
1 to:sz do:[:index | |
|
166 |
(self associationAt:(order at:index)) = anAssociation ifTrue:[ |
|
167 |
index == sz ifTrue:[^ nil]. |
|
168 |
^ self associationAt:(order at:index + 1) |
|
169 |
] |
|
170 |
]. |
|
171 |
^ self errorNotFound:anAssociation. |
|
15133 | 172 |
! |
173 |
||
174 |
associations |
|
175 |
"Return an OrderedCollection containing the receiver's associations." |
|
176 |
||
177 |
^ order collect: [:key | self associationAt: key ]. |
|
178 |
! |
|
179 |
||
180 |
at:aKey ifAbsentPut:valueBlock |
|
15801 | 181 |
^ self at:aKey ifAbsent:[self at:aKey put:valueBlock value] |
15133 | 182 |
! |
183 |
||
15801 | 184 |
at:key put:anObject |
15133 | 185 |
"Set the value at key to be anObject. |
15759 | 186 |
If key is not found, create a new entry for key and set its value to anObject. |
15133 | 187 |
If key is already present, the order remains unchanged. |
188 |
Return anObject." |
|
189 |
||
15801 | 190 |
(self includesKey: key) ifFalse:[order add: key]. |
191 |
^ super at:key put:anObject |
|
15133 | 192 |
! |
193 |
||
194 |
atAll:indexCollection put: anObject |
|
195 |
"Put anObject into the value field of every association specified by indexCollection, |
|
196 |
which is typically an interval." |
|
197 |
||
198 |
indexCollection do:[:index | self at:(order at: index) put:anObject] |
|
199 |
! |
|
200 |
||
201 |
atAllPut: anObject |
|
202 |
"Put anObject into the value field of every association in the dictionary" |
|
203 |
||
15801 | 204 |
order do:[:key | super at: key put:anObject] |
15133 | 205 |
! |
206 |
||
207 |
atIndex:index |
|
208 |
"return an element at a given index" |
|
209 |
||
210 |
^ self at:(order at:index) |
|
211 |
||
212 |
"Created: 28.9.1995 / 13:49:39 / stefan" |
|
213 |
! |
|
214 |
||
15534 | 215 |
atIndex:index ifAbsent:aBlock |
216 |
"return an element at a given index" |
|
217 |
||
218 |
^ self at:(order at:index ifAbsent:[^ aBlock value]) |
|
219 |
! |
|
220 |
||
15133 | 221 |
atIndex:index put:anAssociation |
15801 | 222 |
"put an association to a given index. remove the old association at this index" |
15133 | 223 |
|key| |
224 |
||
225 |
key := anAssociation key. |
|
226 |
(super includesKey:key) ifTrue:[ |
|
227 |
^ self error:'duplicate key'. |
|
228 |
]. |
|
229 |
super removeKey:(order at:index) ifAbsent:[]. |
|
230 |
order at:index put:key. |
|
15801 | 231 |
super at:key put:anAssociation value. |
232 |
^ anAssociation. |
|
15133 | 233 |
|
234 |
"Created: 28.9.1995 / 16:30:15 / stefan" |
|
235 |
! |
|
236 |
||
15801 | 237 |
before:anAssociation |
15133 | 238 |
"Return the association before anAssociation in the order. |
15801 | 239 |
If anAssociation is the first association in the order, return nil. |
15133 | 240 |
If anAssociation is not found, invoke an error notifier" |
15801 | 241 |
|
242 |
|sz "{ Class:SmallInteger }"| |
|
15133 | 243 |
|
15801 | 244 |
sz := order size. |
245 |
1 to:sz do:[:index | |
|
246 |
(self associationAt:(order at:index)) = anAssociation ifTrue:[ |
|
247 |
index == 1 ifTrue:[^ nil]. |
|
248 |
^ self associationAt:(order at:index - 1) |
|
249 |
] |
|
15133 | 250 |
]. |
15801 | 251 |
^ self errorNotFound:anAssociation. |
15133 | 252 |
! |
253 |
||
254 |
first |
|
255 |
"Return the first association of the receiver. |
|
256 |
Provide an error notification if the receiver contains no elements." |
|
257 |
||
258 |
^ self associationAt: (order first) |
|
259 |
||
260 |
" |
|
261 |
OrderedDictionary new first |
|
262 |
" |
|
263 |
! |
|
264 |
||
265 |
keyAt:index |
|
266 |
"get the key at the given index" |
|
267 |
||
268 |
^ order at:index. |
|
269 |
||
270 |
" |
|
271 |
|s| |
|
272 |
||
273 |
s := OrderedDictionary new. |
|
274 |
s at:#a put:'aaa'; at:#b put:'bbb'; at:#c put:'ccc'; at:#d put:'ddd'; at:#a put:'aaaa'. |
|
275 |
s keyAt:2 |
|
276 |
" |
|
277 |
||
278 |
"Created: 29.9.1995 / 11:32:07 / stefan" |
|
279 |
! |
|
280 |
||
281 |
keys |
|
282 |
"Return a OrderedCollection containing the receiver's keys." |
|
283 |
||
284 |
^ order copy. |
|
285 |
||
286 |
" |
|
287 |
|s| |
|
288 |
||
289 |
s := OrderedDictionary new. |
|
290 |
s at:#a put:'aaa'; at:#b put:'bbb'; at:#c put:'ccc'; at:#d put:'ddd'; at:#a put:'aaaa'. |
|
291 |
s keys |
|
292 |
" |
|
293 |
! |
|
294 |
||
295 |
last |
|
296 |
"Return the last association of the receiver. |
|
297 |
Provide an error notification if the receiver contains no elements." |
|
298 |
||
299 |
^ self associationAt: (order last) |
|
300 |
||
301 |
" |
|
302 |
OrderedDictionary new last |
|
303 |
" |
|
304 |
! |
|
305 |
||
306 |
order |
|
307 |
"returns the keys in the order of their appearance" |
|
308 |
||
309 |
^ order |
|
310 |
||
311 |
" |
|
312 |
|s| |
|
313 |
||
314 |
s := OrderedDictionary new. |
|
315 |
s at:#a put:'aaa'; at:#b put:'bbb'; at:#c put:'ccc'; at:#d put:'ddd'; at:#a put:'aaaa'. |
|
316 |
s order |
|
317 |
" |
|
318 |
! |
|
319 |
||
320 |
valueAt:index |
|
321 |
"get the value at the given index" |
|
322 |
||
15801 | 323 |
^ self at:(order at:index). |
15133 | 324 |
|
325 |
" |
|
326 |
|s| |
|
327 |
||
328 |
s := OrderedDictionary new. |
|
329 |
s at:#a put:'aaa'; at:#b put:'bbb'; at:#c put:'ccc'; at:#d put:'ddd'; at:#a put:'aaaa'. |
|
330 |
s valueAt:2 |
|
331 |
" |
|
332 |
! |
|
333 |
||
334 |
values |
|
335 |
"Return a OrderedCollection containing the receiver's values." |
|
336 |
||
15801 | 337 |
^ order collect:[:key | self at:key]. |
15133 | 338 |
! ! |
339 |
||
340 |
!OrderedDictionary methodsFor:'adding'! |
|
341 |
||
342 |
add: anAssociation after: oldAssociation |
|
343 |
"Add the argument, anAssociation, as an element of the dictionary. Put it |
|
344 |
in the position just succeeding oldAssociation. Return anAssociation." |
|
345 |
||
15801 | 346 |
| index key | |
15133 | 347 |
|
348 |
index := self indexOfAssociation: oldAssociation |
|
15801 | 349 |
ifAbsent: [^ self errorNotFound:anAssociation]. |
350 |
key := anAssociation key. |
|
351 |
order remove:key ifAbsent:[]. |
|
352 |
order add:key after:(order at: index). |
|
353 |
super at:key put:anAssociation value. |
|
15133 | 354 |
^ anAssociation |
355 |
! |
|
356 |
||
15801 | 357 |
add:anAssociation before:oldAssociation |
15133 | 358 |
"Add the argument, anAssociation, as an element of the dictionary. Put it |
359 |
in the position just preceding oldAssociation. Return anAssociation." |
|
360 |
||
15801 | 361 |
| index key | |
15133 | 362 |
|
363 |
index := self indexOfAssociation: oldAssociation |
|
15801 | 364 |
ifAbsent: [^ self errorNotFound:anAssociation]. |
365 |
key := anAssociation key. |
|
366 |
order remove:key ifAbsent:[]. |
|
367 |
order add:key before:(order at: index). |
|
368 |
super at:key put:anAssociation value. |
|
15133 | 369 |
^ anAssociation |
370 |
! |
|
371 |
||
15801 | 372 |
add:anAssociation beforeIndex:spot |
15133 | 373 |
"Add the argument, anAssociation, as an element of the receiver. Put it |
374 |
in the position just preceding the indexed position spot. Return newObject." |
|
375 |
||
15801 | 376 |
|key| |
377 |
||
378 |
key := anAssociation key. |
|
379 |
order remove:key ifAbsent:[]. |
|
380 |
order add:key beforeIndex:spot. |
|
381 |
super at:key put:anAssociation value. |
|
382 |
^ anAssociation |
|
15133 | 383 |
|
384 |
"Modified: 28.9.1995 / 14:06:53 / stefan" |
|
385 |
! |
|
386 |
||
387 |
addAll:aCollectionOfAssociations |
|
388 |
"Add each element of anOrderedCollectionOfAssociations at my end. |
|
389 |
We expect the argument to enumerate associations with #reverseDo:; |
|
390 |
if it does not (i.e. it is another OD or a dictionary), use #addAllAssociationsFirst:. |
|
391 |
Returns the argument, aCollectionOfAssociations (sigh)." |
|
392 |
||
15801 | 393 |
^ self addAllLast:aCollectionOfAssociations. |
15133 | 394 |
|
395 |
"Modified: 28.2.1997 / 15:51:23 / cg" |
|
396 |
! |
|
397 |
||
398 |
addAllAssociations:aDictionaryOrOrderedDictionary |
|
399 |
"Add each association of aDictionaryOrOrderedDictionary to my end. |
|
400 |
We expect the argument to respond to #associationsDo:." |
|
401 |
||
15801 | 402 |
^ self addAllAssociationsLast:aDictionaryOrOrderedDictionary. |
15133 | 403 |
|
404 |
"Created: 28.2.1997 / 15:52:02 / cg" |
|
405 |
! |
|
406 |
||
407 |
addAllAssociationsFirst:aDictionaryOrOrderedDictionary |
|
408 |
"Add each association of aDictionaryOrOrderedDictionary at the beginning of the |
|
409 |
receiver. We expect the argument to respond to #associationsReverseDo:." |
|
410 |
||
411 |
aDictionaryOrOrderedDictionary associationsReverseDo:[:each | self addFirst:each]. |
|
412 |
^ aDictionaryOrOrderedDictionary |
|
413 |
||
414 |
"Created: 28.2.1997 / 15:50:14 / cg" |
|
415 |
! |
|
416 |
||
417 |
addAllAssociationsLast:aDictionaryOrOrderedDictionary |
|
418 |
"Add each association of aDictionaryOrOrderedDictionary at the end of the |
|
419 |
receiver. We expect the argument to respond to #associationsDo:." |
|
420 |
||
421 |
aDictionaryOrOrderedDictionary associationsDo:[:each | self addLast:each]. |
|
422 |
^ aDictionaryOrOrderedDictionary |
|
423 |
||
424 |
"Created: 28.2.1997 / 15:48:37 / cg" |
|
425 |
! |
|
426 |
||
15801 | 427 |
addFirst:anAssociation |
15133 | 428 |
"Add anAssociation to the beginning of the receiver." |
429 |
||
15801 | 430 |
|key| |
431 |
||
432 |
key := anAssociation key. |
|
433 |
order remove:key ifAbsent:[]. |
|
434 |
order addFirst:key. |
|
435 |
super at:key put:anAssociation value. |
|
436 |
^ anAssociation |
|
15133 | 437 |
! |
438 |
||
15801 | 439 |
addLast:anAssociation |
15133 | 440 |
"Add anAssociation to the end of the receiver. |
441 |
If anAssociation is already present in the dictionary, |
|
442 |
it will be moved to the end. (See also: #add:)" |
|
443 |
||
15801 | 444 |
|key| |
445 |
||
446 |
key := anAssociation key. |
|
447 |
order remove:key ifAbsent:[]. |
|
448 |
order add:key. |
|
449 |
super at:key put:anAssociation value. |
|
450 |
^ anAssociation |
|
15133 | 451 |
! ! |
452 |
||
453 |
!OrderedDictionary methodsFor:'copying'! |
|
454 |
||
455 |
copyEmpty |
|
456 |
"Return a copy of the receiver that contains no elements." |
|
457 |
||
15801 | 458 |
^ self species new: 10 |
15133 | 459 |
! |
460 |
||
15801 | 461 |
copyFrom:startIndex to:endIndex |
15133 | 462 |
"Return a copy of the receiver that contains elements from |
463 |
position startIndex to endIndex." |
|
15801 | 464 |
|
465 |
|newDict| |
|
15133 | 466 |
|
15801 | 467 |
endIndex < startIndex ifTrue:[ |
468 |
^ self copyEmpty |
|
469 |
]. |
|
470 |
(startIndex < 1 or:[ endIndex > order size ]) ifTrue:[ |
|
471 |
^ self errorNotFound |
|
472 |
]. |
|
473 |
newDict := self copyEmpty:endIndex - startIndex + 1. |
|
474 |
startIndex to:endIndex do:[:index | |
|
475 |
newDict add:(self associationAt:(order at:index)) |
|
476 |
]. |
|
15133 | 477 |
^ newDict |
478 |
! |
|
479 |
||
480 |
copyWithout: anAssociation |
|
481 |
"Return a copy of the dictionary that is 1 smaller than the receiver and |
|
482 |
does not include the argument, anAssociation |
|
483 |
No error is reported, if elementToSkip is not in the collection." |
|
484 |
||
16765 | 485 |
| newDict keyToIgnore valueToIgnore| |
486 |
||
15801 | 487 |
newDict := self species new:order size - 1. |
16765 | 488 |
"/ self associationsDo:[:assoc | anAssociation = assoc ifFalse:[newDict add:assoc]]. |
489 |
||
490 |
keyToIgnore := anAssociation key. |
|
491 |
valueToIgnore := anAssociation value. |
|
492 |
self keysAndValuesDo:[:k :v | |
|
493 |
(keyToIgnore = k and:[valueToIgnore = v]) ifFalse:[ |
|
494 |
newDict at:k put:v |
|
495 |
] |
|
496 |
]. |
|
497 |
^ newDict. |
|
498 |
||
499 |
" |
|
500 |
|d d2| |
|
501 |
||
502 |
d := OrderedDictionary new |
|
503 |
at:1 put:'1'; |
|
504 |
at:2 put:'2'; |
|
505 |
at:3 put:'3'; |
|
506 |
at:4 put:'4'; |
|
507 |
at:5 put:'5'; |
|
508 |
yourself. |
|
509 |
d2 := d copyWithout:(4->'4'). |
|
510 |
d2 |
|
511 |
" |
|
15133 | 512 |
! |
513 |
||
514 |
postCopy |
|
515 |
"have to copy the order too" |
|
516 |
||
517 |
super postCopy. |
|
518 |
order := order copy |
|
519 |
! ! |
|
520 |
||
521 |
!OrderedDictionary methodsFor:'enumerating'! |
|
522 |
||
523 |
associationsCollect: aBlock |
|
524 |
"Evaluate aBlock with each of the associations of the dictionary as argument, |
|
525 |
and return a new (ordered) collection with the results" |
|
526 |
||
527 |
^ order collect:[:key | (aBlock value: (self associationAt:key))]. |
|
528 |
! |
|
529 |
||
530 |
associationsDo: aBlock |
|
16765 | 531 |
"Evaluate aBlock for each of the dictionary's associations. |
532 |
Enumerate them in the order by which they were added. |
|
533 |
||
534 |
See also: |
|
535 |
#keysAndValuesDo: (which passes keys & values separately) |
|
536 |
#keysDo: (which passes keys only) |
|
537 |
#do: (which passes values only)" |
|
15133 | 538 |
|
539 |
order do: [:key | aBlock value: (self associationAt: key)] |
|
540 |
! |
|
541 |
||
542 |
associationsDo: aBlock from: firstIndex to: secondIndex |
|
543 |
"Evaluate aBlock with each of the dictionary's associations from index |
|
544 |
firstIndex to index secondIndex as the argument." |
|
545 |
||
546 |
firstIndex to: secondIndex do: [:index | |
|
547 |
aBlock value: (self associationAt: (order at: index)) |
|
548 |
] |
|
549 |
! |
|
550 |
||
551 |
associationsReverseDo: aBlock |
|
552 |
"Evaluate aBlock for each of the dictionary's associations in reverse order." |
|
553 |
||
554 |
order reverseDo:[:key | aBlock value:(self associationAt:key)] |
|
555 |
||
556 |
"Created: 28.2.1997 / 15:52:31 / cg" |
|
557 |
! |
|
558 |
||
559 |
associationsSelect:aBlock |
|
560 |
"Evaluate aBlock with each of the dictionary's associations as the argument. |
|
561 |
Collect into a new OrderedDictionary only those associations for which |
|
562 |
aBlock evaluates to true. Return the new OrderedDictionary." |
|
563 |
||
564 |
|newDict| |
|
565 |
||
15801 | 566 |
newDict := self species new. |
15133 | 567 |
order do:[:key | |
568 |
|assoc| |
|
569 |
||
570 |
assoc := self associationAt:key. |
|
571 |
(aBlock value:assoc) ifTrue: [ |
|
15801 | 572 |
newDict at:key put:assoc value. |
15133 | 573 |
] |
574 |
]. |
|
575 |
^ newDict |
|
576 |
! |
|
577 |
||
578 |
collect: aBlock |
|
579 |
"Evaluate aBlock with each of the values of the dictionary as argument, |
|
580 |
and return a new (ordered) collection with the results" |
|
581 |
||
582 |
^ order collect:[:key | (aBlock value: (self at:key))]. |
|
583 |
! |
|
584 |
||
16216 | 585 |
detect: aBlock ifNone:anExceptionValue |
15759 | 586 |
"evaluate the argument, aBlock for each element in the receiver until |
587 |
the block returns true; in this case return the element which caused |
|
588 |
the true evaluation. |
|
16216 | 589 |
If none of the evaluations returns true, return the value of anExceptionValue" |
15759 | 590 |
|
591 |
order do:[:key | |
|
592 |
|el| |
|
15801 | 593 |
el := self at:key. |
594 |
(aBlock value:el) ifTrue:[^ el] |
|
15759 | 595 |
]. |
16216 | 596 |
^ anExceptionValue value |
15759 | 597 |
! |
598 |
||
15133 | 599 |
do: aBlock |
16765 | 600 |
"Evaluate aBlock for each of the dictionary's values. |
601 |
Enumerate them in the order by which they were added." |
|
15133 | 602 |
|
603 |
order do: [:key | aBlock value: (self at: key)] |
|
604 |
! |
|
605 |
||
15801 | 606 |
do: aBlock from: firstIndex to: lastIndex |
607 |
<resource: #obsolete> |
|
608 |
||
609 |
self obsoleteMethodWarning:'use #from:to:do:'. |
|
15133 | 610 |
|
611 |
self from:firstIndex to:lastIndex do:aBlock. |
|
612 |
! |
|
613 |
||
614 |
findFirst:aBlock ifNone:exceptionalValue |
|
615 |
"Return the index of the first association in the dictionary for which aBlock |
|
616 |
evaluates as true. If the block does not evaluate to true, return exceptionalValue" |
|
617 |
||
15801 | 618 |
|stop "{ Class: SmallInteger }" | |
619 |
||
620 |
stop := order size. |
|
621 |
1 to:stop do:[:index | |
|
15133 | 622 |
(aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index] |
623 |
]. |
|
624 |
^ exceptionalValue value |
|
625 |
! |
|
626 |
||
627 |
findLast:aBlock |
|
628 |
"Return the index of the last association in the dictionary for which aBlock |
|
629 |
evaluates as true. If the block does not evaluate to true, return 0" |
|
630 |
||
15801 | 631 |
|start "{ Class: SmallInteger }"| |
632 |
||
633 |
start := order size. |
|
634 |
start to:1 by:-1 do: [:index | |
|
15133 | 635 |
(aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index] |
636 |
]. |
|
637 |
^ 0 |
|
638 |
! |
|
639 |
||
640 |
findLast:aBlock startingAt:startIndex |
|
641 |
"Return the index of the last association in the dictionary for which aBlock |
|
15662 | 642 |
evaluates as true. Start the backward search at startIndex. |
15133 | 643 |
If the block does not evaluate to true, return 0" |
644 |
||
15801 | 645 |
|start "{ Class: SmallInteger }"| |
646 |
||
647 |
start := startIndex. |
|
648 |
start to:1 by:-1 do: [:index | |
|
15133 | 649 |
(aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index] |
650 |
]. |
|
651 |
^ 0 |
|
652 |
! |
|
653 |
||
654 |
findLast:aBlock startingAt:startIndex endingAt:endIndex |
|
655 |
"Return the index of the last association in the dictionary for which aBlock |
|
656 |
evaluates as true. Start the search at startIndex. |
|
657 |
End the search at endIndex or when an element is found. |
|
658 |
If the block does not evaluate to true, return 0" |
|
659 |
||
15801 | 660 |
|start "{ Class: SmallInteger }" |
661 |
end "{ Class: SmallInteger }"| |
|
662 |
||
663 |
start := startIndex. |
|
664 |
end := endIndex. |
|
665 |
start to:end by:-1 do: [:index | |
|
15133 | 666 |
(aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index] |
667 |
]. |
|
668 |
^ 0 |
|
669 |
! |
|
670 |
||
671 |
from:firstIndex to:lastIndex do: aBlock |
|
672 |
"Evaluate aBlock with each of the dictionary's associations from index |
|
673 |
firstIndex to index secondIndex as the argument." |
|
674 |
||
15801 | 675 |
|start "{ Class:SmallInteger }" |
676 |
stop "{ Class:SmallInteger }" | |
|
677 |
||
678 |
start := firstIndex. "/ these assignments force type checking... |
|
679 |
stop := lastIndex. "/ and guarantee inline loop code below. |
|
680 |
order from:start to:stop do:[:key | |
|
15133 | 681 |
aBlock value: (self at:key) |
682 |
]. |
|
683 |
! |
|
684 |
||
15759 | 685 |
keysAndValuesDetect: aBlock ifNone:exceptionBlock |
686 |
"evaluate the argument, aBlock for each element in the receiver until |
|
687 |
the block returns true; in this case return the element which caused |
|
688 |
the true evaluation. |
|
689 |
If none of the evaluations returns true, return the result of the |
|
690 |
evaluation of the exceptionBlock" |
|
691 |
||
692 |
order do:[:key | |
|
693 |
|el| |
|
15801 | 694 |
el := self at:key. |
695 |
(aBlock value:key value:el) ifTrue:[^ el] |
|
15759 | 696 |
]. |
697 |
^ exceptionBlock value |
|
698 |
! |
|
699 |
||
15133 | 700 |
keysAndValuesDo:aBlock |
15451 | 701 |
"perform the block for all keys and values in the collection. |
702 |
Enumerate them in the order by which they were added. |
|
15133 | 703 |
|
704 |
See also: |
|
705 |
#associationsDo: (which passes key-value associations) |
|
16765 | 706 |
#keysDo: (which passes keys only) |
15133 | 707 |
#do: (which passes values only) |
708 |
||
709 |
WARNING: do not add/remove elements while iterating over the receiver. |
|
710 |
Iterate over a copy to do this." |
|
711 |
||
15801 | 712 |
order do:[:key | aBlock value:key value:(self at: key)]. |
15133 | 713 |
|
714 |
"Modified: / 26.6.1999 / 10:55:30 / ps" |
|
715 |
"Created: / 15.10.1999 / 16:49:31 / cg" |
|
716 |
"Modified: / 15.10.1999 / 16:53:50 / cg" |
|
717 |
! |
|
718 |
||
15451 | 719 |
keysAndValuesReverseDo:aBlock |
720 |
"perform the block for all keys and values in the collection. |
|
721 |
Enumerate them in the reverse order from which they were added. |
|
722 |
||
723 |
See also: |
|
724 |
#associationsDo: (which passes key-value associations) |
|
725 |
#keysAndValuesDo: (which passes keys & values separately) |
|
726 |
#do: (which passes values only) |
|
727 |
||
728 |
WARNING: do not add/remove elements while iterating over the receiver. |
|
729 |
Iterate over a copy to do this." |
|
730 |
||
731 |
order reverseDo: [:key | aBlock value:key value:(self at: key)]. |
|
732 |
||
733 |
"Modified: / 26.6.1999 / 10:55:30 / ps" |
|
734 |
"Created: / 15.10.1999 / 16:49:31 / cg" |
|
735 |
"Modified: / 15.10.1999 / 16:53:50 / cg" |
|
736 |
! |
|
737 |
||
15133 | 738 |
keysDo:aBlock |
739 |
"evaluate the argument, aBlock for every key in the collection. |
|
16765 | 740 |
Enumerate them in the order by which they were added. |
15133 | 741 |
|
742 |
See also: |
|
743 |
#associationsDo: (which passes key-value associations) |
|
744 |
#keysAndValuesDo: (which passes keys & values separately) |
|
745 |
#do: (which passes values only) |
|
746 |
||
747 |
WARNING: do not add/remove elements while iterating over the receiver. |
|
748 |
Iterate over a copy to do this." |
|
749 |
||
750 |
order do:[:key | aBlock value:key]. |
|
751 |
||
752 |
"Created: / 26-06-1999 / 10:53:00 / ps" |
|
753 |
"Modified: / 24-08-2010 / 10:14:06 / cg" |
|
754 |
! |
|
755 |
||
756 |
reverseDo: aBlock |
|
757 |
"Evaluate aBlock with each of the dictionary's associations as the argument, |
|
16765 | 758 |
starting with the last added element and taking each in sequence up to the first." |
15133 | 759 |
|
15801 | 760 |
|sz "{ Class:SmallInteger }"| |
761 |
||
762 |
sz := order size. |
|
763 |
sz to:1 by:-1 do: [:index | |
|
15133 | 764 |
aBlock value:(self associationAt:(order at:index)) |
765 |
] |
|
766 |
! |
|
767 |
||
768 |
reversed |
|
769 |
"Return with a new OrderedDictionary with its associations in reverse order." |
|
770 |
||
15801 | 771 |
^ self copy reverse. |
15133 | 772 |
! |
773 |
||
774 |
select:aBlock |
|
775 |
"Evaluate aBlock with each of the dictionary's values as the argument. |
|
776 |
Collect into a new OrderedDictionary only those associations for which |
|
777 |
aBlock evaluated to true. Return the new OrderedDictionary." |
|
778 |
||
779 |
|newColl| |
|
780 |
||
781 |
newColl := self species new. |
|
782 |
order do:[:key | |
|
15801 | 783 |
|val| |
15133 | 784 |
|
15801 | 785 |
val := self at:key. |
786 |
(aBlock value:val) ifTrue:[ |
|
787 |
newColl at:key put:val. |
|
15133 | 788 |
] |
789 |
]. |
|
790 |
^ newColl |
|
791 |
! ! |
|
792 |
||
793 |
!OrderedDictionary methodsFor:'initialization'! |
|
794 |
||
795 |
initializeOrder |
|
796 |
order := OrderedCollection new |
|
797 |
! ! |
|
798 |
||
799 |
!OrderedDictionary methodsFor:'private'! |
|
800 |
||
15801 | 801 |
removeFromOrder: aKey |
802 |
<resource: #obsolete> |
|
803 |
||
804 |
order remove: aKey ifAbsent: [] |
|
15133 | 805 |
! ! |
806 |
||
807 |
!OrderedDictionary methodsFor:'queries'! |
|
808 |
||
809 |
occurrencesOfKey: aKey |
|
810 |
"Return how many of the dictionary's keys are equal to aKey." |
|
811 |
||
812 |
^ order count:[:eachKey | aKey = eachKey] |
|
813 |
||
814 |
"/ cg: the original code was not very smalltalkish: |
|
815 |
"/ |
|
816 |
"/ | count | |
|
817 |
"/ |
|
818 |
"/ count := 0. |
|
819 |
"/ 1 to: self size do: [:index | aKey = (order at: index) ifTrue: [count := count + 1]]. |
|
820 |
"/ ^count |
|
821 |
! |
|
822 |
||
823 |
occurrencesOfValue: aValue |
|
824 |
"Return how many of the dictionary's values are equal to aValue." |
|
825 |
||
826 |
^ order count:[:eachKey | aValue = (self at:eachKey)] |
|
827 |
||
828 |
"/ cg: the original code was not very smalltalkish: |
|
829 |
"/ |
|
830 |
"/ | count | |
|
831 |
"/ |
|
832 |
"/ count := 0. |
|
833 |
"/ 1 to: self size do: [:index | |
|
834 |
"/ aValue = (self at: (order at: index)) ifTrue: [count := count + 1]]. |
|
835 |
"/ ^count |
|
836 |
! ! |
|
837 |
||
838 |
!OrderedDictionary methodsFor:'removing'! |
|
839 |
||
840 |
removeFirst |
|
841 |
|key| |
|
842 |
||
843 |
order size == 0 ifTrue:[ |
|
15801 | 844 |
"error if collection is empty" |
845 |
^ self emptyCollectionError. |
|
15133 | 846 |
]. |
847 |
key := order removeFirst. |
|
848 |
^ super removeKey:key. |
|
849 |
! |
|
850 |
||
851 |
removeFromIndex:fromIndex toIndex:toIndex |
|
852 |
"Returns the receiver." |
|
853 |
||
15801 | 854 |
|start "{ Class:SmallInteger }" |
855 |
stop "{ Class:SmallInteger }" | |
|
15133 | 856 |
|
15801 | 857 |
start := fromIndex. |
858 |
stop := toIndex. |
|
859 |
||
860 |
order from:start to:stop do:[:key | |
|
15133 | 861 |
super removeKey:key. |
862 |
]. |
|
15801 | 863 |
order removeFromIndex:fromIndex toIndex:toIndex. |
15133 | 864 |
|
865 |
"Created: 28.9.1995 / 12:04:33 / stefan" |
|
866 |
! |
|
867 |
||
15801 | 868 |
removeIndex:anInteger |
869 |
self removeFromIndex:anInteger toIndex:anInteger. |
|
870 |
! |
|
871 |
||
15133 | 872 |
removeKey:aKey |
873 |
order remove:aKey. |
|
874 |
^ super removeKey:aKey. |
|
875 |
! |
|
876 |
||
877 |
removeKey:aKey ifAbsent:aBlock |
|
15801 | 878 |
|oldValue| |
879 |
||
880 |
oldValue := super removeKey:aKey ifAbsent:aBlock. |
|
15133 | 881 |
order remove:aKey ifAbsent:[]. |
15801 | 882 |
^ oldValue. |
15133 | 883 |
|
884 |
"Created: / 31-01-2011 / 22:04:01 / cg" |
|
885 |
! |
|
886 |
||
887 |
removeLast |
|
888 |
|key| |
|
889 |
||
890 |
order size == 0 ifTrue:[ |
|
891 |
"error if collection is empty" |
|
892 |
||
893 |
^ self emptyCollectionError. |
|
894 |
]. |
|
895 |
key := order removeLast. |
|
896 |
^ super removeKey:key. |
|
897 |
! ! |
|
898 |
||
899 |
!OrderedDictionary methodsFor:'searching'! |
|
900 |
||
901 |
identityIndexOfAssociation: anAssociation |
|
902 |
"Return the identity index of anAssociation within the receiver. If the receiver |
|
903 |
does not contain anAssociation, return 0." |
|
904 |
||
905 |
^ self identityIndexOfAssociation: anAssociation ifAbsent: [0] |
|
906 |
! |
|
907 |
||
908 |
identityIndexOfAssociation: anAssociation ifAbsent: exceptionBlock |
|
909 |
"Return the identity index of anAssociation within the receiver. |
|
910 |
If the receiver does not contain anAssociation, |
|
911 |
return the result of evaluating the exceptionBlock." |
|
912 |
||
913 |
"/ as ST/X's dictionaries do not store the associations |
|
914 |
"/ (instead, they store the keys and values in separate collections) |
|
915 |
"/ this will not work. You have to think about it and rewrite your code. |
|
916 |
self error:'this does not work in Smalltalk/X'. |
|
917 |
||
918 |
order keysAndValuesDo:[:i :key | |
|
919 |
(self associationAt:key) == anAssociation ifTrue: [^i] |
|
920 |
]. |
|
921 |
^exceptionBlock value |
|
922 |
! |
|
923 |
||
924 |
identityIndexOfKey: aKey |
|
925 |
"Return the identity index of aKey within the receiver. If the receiver |
|
926 |
does not contain aKey, return 0." |
|
927 |
||
928 |
^self identityIndexOfKey: aKey ifAbsent: [0] |
|
929 |
! |
|
930 |
||
931 |
identityIndexOfKey: aKey ifAbsent: exceptionBlock |
|
932 |
"Return the identity index of aKey within the receiver. If the receiver does |
|
933 |
not contain aKey, return the result of evaluating the exceptionBlock." |
|
934 |
||
935 |
^ order identityIndexOf:aKey ifAbsent:exceptionBlock |
|
936 |
! |
|
937 |
||
938 |
identityIndexOfValue: aValue |
|
939 |
"Return the identity index of aValue within the receiver. If the receiver |
|
940 |
does not contain aValue, return 0." |
|
941 |
||
942 |
^self identityIndexOfValue: aValue ifAbsent: [0] |
|
943 |
! |
|
944 |
||
945 |
identityIndexOfValue: aValue ifAbsent: exceptionBlock |
|
946 |
"Return the identity index of aValue within the receiver. If the receiver |
|
947 |
does not contain aValue, return the result of evaluating the exceptionBlock." |
|
948 |
||
949 |
order keysAndValuesDo:[:i :key | (self at:key) == aValue ifTrue: [^i]]. |
|
950 |
^exceptionBlock value |
|
951 |
! |
|
952 |
||
953 |
indexOfAssociation: anAssociation |
|
954 |
"Return the index of anAssociation within the receiver. If the receiver does |
|
955 |
not contain anAssociation, return 0." |
|
956 |
||
957 |
^self indexOfAssociation: anAssociation ifAbsent: [0] |
|
958 |
! |
|
959 |
||
960 |
indexOfAssociation: anAssociation ifAbsent: exceptionBlock |
|
961 |
"Return the identity index of anAssociation within the receiver. If the receiver |
|
962 |
does not contain anAssociation, return the result of evaluating the exceptionBlock." |
|
963 |
||
964 |
order keysAndValuesDo:[:i :key | |
|
965 |
(self associationAt:key) = anAssociation ifTrue: [^i] |
|
966 |
]. |
|
967 |
^exceptionBlock value |
|
968 |
! |
|
969 |
||
970 |
indexOfKey: aKey |
|
971 |
"Return the index of aKey within the receiver. If the receiver does |
|
972 |
not contain aKey, return 0." |
|
973 |
||
974 |
^self indexOfKey: aKey ifAbsent: [0] |
|
975 |
! |
|
976 |
||
977 |
indexOfKey: aKey ifAbsent: exceptionBlock |
|
978 |
"Return the identity index of aKey within the receiver. If the receiver does |
|
979 |
not contain aKey, return the result of evaluating the exceptionBlock." |
|
980 |
||
981 |
^ order indexOf:aKey ifAbsent:exceptionBlock |
|
982 |
! |
|
983 |
||
984 |
indexOfValue: aValue |
|
985 |
"Return the index of aValue within the receiver. |
|
986 |
If the receiver does not contain aValue, return 0." |
|
987 |
||
988 |
^self indexOfValue: aValue ifAbsent: [0] |
|
989 |
! |
|
990 |
||
991 |
indexOfValue: aValue ifAbsent: exceptionBlock |
|
992 |
"Return the identity index of aValue within the receiver. |
|
993 |
If the receiver does not contain aValue, return the result of evaluating the exceptionBlock." |
|
994 |
||
995 |
order keysAndValuesDo:[:i :key | (self at:key) = aValue ifTrue: [^i]]. |
|
996 |
^ exceptionBlock value |
|
997 |
! |
|
998 |
||
999 |
nextIndexOfAssociation: aAssociation from: startIndex to: stopIndex |
|
1000 |
"Return the next index of aAssociation within the receiver between startIndex |
|
1001 |
and stopIndex. If the receiver does not contain aAssociation, return nil" |
|
1002 |
||
15801 | 1003 |
|start "{ Class:SmallInteger }" |
1004 |
stop "{ Class:SmallInteger }"| |
|
1005 |
||
1006 |
start := startIndex. |
|
1007 |
stop := stopIndex. |
|
1008 |
start to: stop do: [:i | |
|
15133 | 1009 |
(self associationAt: (order at: i)) = aAssociation ifTrue: [^i]]. |
1010 |
^nil |
|
1011 |
! |
|
1012 |
||
1013 |
nextIndexOfKey: aKey from: startIndex to: stopIndex |
|
1014 |
"Return the next index of aKey within the receiver between startIndex and |
|
1015 |
stopIndex. If the receiver does not contain aKey, return nil" |
|
1016 |
||
15801 | 1017 |
|start "{ Class:SmallInteger }" |
1018 |
stop "{ Class:SmallInteger }"| |
|
1019 |
||
1020 |
start := startIndex. |
|
1021 |
stop := stopIndex. |
|
1022 |
start to: stop do: [:i | |
|
15133 | 1023 |
(order at: i) = aKey ifTrue: [^i]]. |
1024 |
^nil |
|
1025 |
! |
|
1026 |
||
1027 |
nextIndexOfValue: aValue from: startIndex to: stopIndex |
|
1028 |
"Return the next index of aValue within the receiver between startIndex and |
|
1029 |
stopIndex. If the receiver does not contain aValue, return nil" |
|
1030 |
||
15801 | 1031 |
|start "{ Class:SmallInteger }" |
1032 |
stop "{ Class:SmallInteger }" | |
|
1033 |
||
1034 |
start := startIndex. |
|
1035 |
stop := stopIndex. |
|
1036 |
start to: stop do: [:i | |
|
15133 | 1037 |
(self at: (order at: i)) = aValue ifTrue: [^i]]. |
1038 |
^nil |
|
1039 |
! |
|
1040 |
||
1041 |
prevIndexOfAssociation: aAssociation from: startIndex to: stopIndex |
|
1042 |
"Return the previous index of aAssociation within the receiver between |
|
1043 |
startIndex and stopIndex working backwards through the receiver. |
|
1044 |
If the receiver does not contain aAssociation, return nil" |
|
1045 |
||
15801 | 1046 |
|start "{ Class:SmallInteger }" |
1047 |
stop "{ Class:SmallInteger }"| |
|
1048 |
||
1049 |
start := startIndex. |
|
1050 |
stop := stopIndex. |
|
1051 |
start to: stop by: -1 |
|
15133 | 1052 |
do: [:i | (self associationAt: (order at: i)) = aAssociation ifTrue: [^i]]. |
1053 |
^nil |
|
1054 |
! |
|
1055 |
||
1056 |
prevIndexOfKey: aKey from: startIndex to: stopIndex |
|
1057 |
"Return the previous index of aKey within the receiver between startIndex and |
|
1058 |
stopIndex working backwards through the receiver. |
|
1059 |
If the receiver does not contain aKey, return nil" |
|
1060 |
||
15801 | 1061 |
|start "{ Class:SmallInteger }" |
1062 |
stop "{ Class:SmallInteger }"| |
|
1063 |
||
1064 |
start := startIndex. |
|
1065 |
stop := stopIndex. |
|
1066 |
start to: stop by: -1 |
|
15133 | 1067 |
do: [:i | (order at: i) = aKey ifTrue: [^i]]. |
1068 |
^nil |
|
1069 |
! |
|
1070 |
||
15801 | 1071 |
prevIndexOfValue:aValue from:startIndex to:stopIndex |
15133 | 1072 |
"Return the previous index of aValue within the receiver between startIndex |
15801 | 1073 |
and stopIndex working backwards through the receiver. |
15133 | 1074 |
If the receiver does not contain aValue, return nil" |
15801 | 1075 |
|
1076 |
|start "{ Class:SmallInteger }" |
|
1077 |
stop "{ Class:SmallInteger }"| |
|
15133 | 1078 |
|
15801 | 1079 |
start := startIndex. |
1080 |
stop := stopIndex. |
|
1081 |
start to:stop by:-1 do:[:i | |
|
1082 |
(self at:(order at:i)) = aValue ifTrue:[ |
|
1083 |
^ i |
|
1084 |
] |
|
1085 |
]. |
|
1086 |
^ nil |
|
15133 | 1087 |
! ! |
1088 |
||
1089 |
!OrderedDictionary methodsFor:'sorting & reordering'! |
|
1090 |
||
1091 |
reverse |
|
1092 |
"Destructively reverse my order. |
|
1093 |
WARNING: this is a destructive operation, which modifies the receiver. |
|
1094 |
Please use reversed (with a d) for a functional version." |
|
1095 |
||
1096 |
order reverse |
|
1097 |
! |
|
1098 |
||
1099 |
sort |
|
1100 |
"Destructively sort my order. |
|
1101 |
WARNING: this is a destructive operation, which modifies the receiver" |
|
1102 |
||
1103 |
order sort |
|
1104 |
! |
|
1105 |
||
1106 |
sort:aSortBlock |
|
1107 |
"Destructively sort my order. |
|
1108 |
WARNING: this is a destructive operation, which modifies the receiver" |
|
1109 |
||
1110 |
order sort:aSortBlock |
|
1111 |
! ! |
|
1112 |
||
18465 | 1113 |
!OrderedDictionary methodsFor:'testing'! |
1114 |
||
1115 |
isOrdered |
|
1116 |
"return true, if the receiver's elements are ordered. |
|
1117 |
Re-redefined to true here, as I do have an order" |
|
1118 |
||
1119 |
^ true |
|
1120 |
! ! |
|
1121 |
||
15133 | 1122 |
!OrderedDictionary class methodsFor:'documentation'! |
1123 |
||
1124 |
version |
|
19099 | 1125 |
^ '$Header$' |
15133 | 1126 |
! |
1127 |
||
1128 |
version_CVS |
|
19099 | 1129 |
^ '$Header$' |
15133 | 1130 |
! ! |
1131 |