equal
deleted
inserted
replaced
19 |
19 |
20 Set comment:' |
20 Set comment:' |
21 COPYRIGHT (c) 1991 by Claus Gittinger |
21 COPYRIGHT (c) 1991 by Claus Gittinger |
22 All Rights Reserved |
22 All Rights Reserved |
23 |
23 |
24 $Header: /cvs/stx/stx/libbasic/Set.st,v 1.14 1995-02-15 10:24:56 claus Exp $ |
24 $Header: /cvs/stx/stx/libbasic/Set.st,v 1.15 1995-03-08 23:39:52 claus Exp $ |
25 '! |
25 '! |
26 |
26 |
27 !Set class methodsFor:'documentation'! |
27 !Set class methodsFor:'documentation'! |
28 |
28 |
29 copyright |
29 copyright |
40 " |
40 " |
41 ! |
41 ! |
42 |
42 |
43 version |
43 version |
44 " |
44 " |
45 $Header: /cvs/stx/stx/libbasic/Set.st,v 1.14 1995-02-15 10:24:56 claus Exp $ |
45 $Header: /cvs/stx/stx/libbasic/Set.st,v 1.15 1995-03-08 23:39:52 claus Exp $ |
46 " |
46 " |
47 ! |
47 ! |
48 |
48 |
49 documentation |
49 documentation |
50 " |
50 " |
110 |
110 |
111 goodSizeFrom:arg |
111 goodSizeFrom:arg |
112 "return a good array size for the given argument. |
112 "return a good array size for the given argument. |
113 Returns the next prime after arg, since prime sizes are good for hashing." |
113 Returns the next prime after arg, since prime sizes are good for hashing." |
114 |
114 |
|
115 |n| |
|
116 |
115 arg <= 11 ifTrue:[^ 11]. |
117 arg <= 11 ifTrue:[^ 11]. |
|
118 |
|
119 n := arg * 3 // 2. |
116 |
120 |
117 " |
121 " |
118 mhmh - this returns good numbers for collections with up-to about |
122 mhmh - this returns good numbers for collections with up-to about |
119 500k elements; if you have bigger ones, add some more primes here ... |
123 500k elements; if you have bigger ones, add some more primes here ... |
120 " |
124 " |
121 arg <= 524288 ifTrue:[ |
125 n <= 524288 ifTrue:[ |
122 "2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288" |
126 "2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288" |
123 ^ #(11 11 11 17 37 67 131 257 521 1031 2053 4099 8209 16411 32771 65537 131101 262147 524309) at:(arg highBit) |
127 ^ #(11 11 11 17 37 67 131 257 521 1031 2053 4099 8209 16411 32771 65537 131101 262147 524309) at:(n highBit) |
124 ]. |
128 ]. |
125 " |
129 " |
126 make it odd - at least |
130 make it odd - at least |
127 " |
131 " |
128 ^ arg bitOr:1 |
132 ^ n bitOr:1 |
129 ! ! |
133 ! ! |
130 |
134 |
131 !Set methodsFor:'copying'! |
135 !Set methodsFor:'copying'! |
132 |
136 |
133 postCopy |
137 postCopy |