equal
deleted
inserted
replaced
36 ! |
36 ! |
37 |
37 |
38 documentation |
38 documentation |
39 " |
39 " |
40 Instances of MethodDictionary store selector/method associations |
40 Instances of MethodDictionary store selector/method associations |
41 in classes. Conceptionally, they behave like Dictionaries, but are |
41 in classes. Conceptionally, they behave like IdentityDictionaries, but are |
42 implemented using a single array (instead of dictionary, which uses |
42 implemented using a single array (instead of Dictionary, which uses |
43 two arrays to store keys and values separately). |
43 two arrays to store keys and values separately). |
44 Also, they do not use hashing, since due to caching in the VM, hashing |
44 Also, they do not use hashing, since due to caching in the VM, hashing |
45 does not make too much of a difference in speed, but complicates the |
45 does not make too much of a difference in speed, but complicates the |
46 VM implementations. |
46 VM implementation. |
47 |
47 |
48 [author:] |
48 [author:] |
49 Stefan Vogel |
49 Stefan Vogel |
50 |
50 |
51 [see also:] |
51 [see also:] |
52 Dictionary |
52 Dictionary |
|
53 IdentityDictionary |
53 Behavior Class |
54 Behavior Class |
54 Method Symbol |
55 Method |
|
56 Symbol |
55 " |
57 " |
56 ! ! |
58 ! ! |
57 |
59 |
58 !MethodDictionary class methodsFor:'instance creation'! |
60 !MethodDictionary class methodsFor:'instance creation'! |
59 |
61 |
442 ! ! |
444 ! ! |
443 |
445 |
444 !MethodDictionary methodsFor:'private'! |
446 !MethodDictionary methodsFor:'private'! |
445 |
447 |
446 compressed |
448 compressed |
447 "compress - return either the receiver or myself" |
449 "compress - return either the myself or a new, compressed MethodDictionary" |
448 |
450 |
449 |newDict tally dstIndex "{ Class: SmallInteger }" sz "{ Class: SmallInteger }" |
451 |newDict tally key mySize |
450 key mySize| |
452 dstIndex "{ Class: SmallInteger }" |
|
453 sz "{ Class: SmallInteger }" | |
451 |
454 |
452 sz := self basicSize. |
455 sz := self basicSize. |
453 mySize := sz // 2. |
456 mySize := sz // 2. |
454 tally := 0. |
457 tally := 0. |
455 1 to:sz by:2 do:[:i | |
458 1 to:sz by:2 do:[:i | |
458 ] |
461 ] |
459 ]. |
462 ]. |
460 |
463 |
461 tally == mySize ifTrue:[^ self]. |
464 tally == mySize ifTrue:[^ self]. |
462 |
465 |
463 newDict := self class new:tally. |
466 newDict := self species new:tally. |
464 dstIndex := 1. |
467 dstIndex := 1. |
465 1 to:sz by:2 do:[:i | |
468 1 to:sz by:2 do:[:i | |
466 key := self basicAt:i. |
469 key := self basicAt:i. |
467 key notNil ifTrue:[ |
470 key notNil ifTrue:[ |
468 newDict basicAt:dstIndex put:key. |
471 newDict basicAt:dstIndex put:key. |
470 dstIndex := dstIndex + 2. |
473 dstIndex := dstIndex + 2. |
471 ] |
474 ] |
472 ]. |
475 ]. |
473 ^ newDict |
476 ^ newDict |
474 |
477 |
|
478 "Modified: / 05-08-2004 / 20:05:44 / stefan" |
475 ! ! |
479 ! ! |
476 |
480 |
477 !MethodDictionary methodsFor:'queries'! |
481 !MethodDictionary methodsFor:'queries'! |
478 |
482 |
479 includesKey:key |
483 includesKey:key |
547 ! ! |
551 ! ! |
548 |
552 |
549 !MethodDictionary class methodsFor:'documentation'! |
553 !MethodDictionary class methodsFor:'documentation'! |
550 |
554 |
551 version |
555 version |
552 ^ '$Header: /cvs/stx/stx/libbasic/MethodDictionary.st,v 1.22 2000-08-22 13:57:14 cg Exp $' |
556 ^ '$Header: /cvs/stx/stx/libbasic/MethodDictionary.st,v 1.23 2004-08-07 18:47:18 stefan Exp $' |
553 ! ! |
557 ! ! |