2240 " |
2237 " |
2241 |
2238 |
2242 "Created: / 26-12-2011 / 13:46:06 / cg" |
2239 "Created: / 26-12-2011 / 13:46:06 / cg" |
2243 ! |
2240 ! |
2244 |
2241 |
|
2242 hash_fnv1a |
|
2243 "return an integer useful as a hash-key. |
|
2244 This method uses the fnv-1a algorithm |
|
2245 (which is actually a very good one)" |
|
2246 |
|
2247 |h| |
|
2248 |
|
2249 h := 2166136261. |
|
2250 self do:[:eachChar | |
|
2251 h := h bitXor:(eachChar codePoint). |
|
2252 h := (h * 16777619) bitAnd:16rFFFFFFFF. |
|
2253 ]. |
|
2254 ^ h |
|
2255 |
|
2256 " |
|
2257 'abc' hash_fnv1a |
|
2258 'foofooHelloWorld' hash_fnv1a |
|
2259 'blablaHelloWorld' hash_fnv1a |
|
2260 " |
|
2261 ! |
|
2262 |
|
2263 hash_java |
|
2264 "return an integer useful as a hash-key. |
|
2265 This method uses the same algorithm as used in |
|
2266 the java virtual machine |
|
2267 (which is actually not a very good one)." |
|
2268 |
|
2269 |h| |
|
2270 |
|
2271 h := 0. |
|
2272 self do:[:eachChar | |
|
2273 h := (h * 31) + (eachChar codePoint). |
|
2274 h := h bitAnd:16rFFFFFFFF. |
|
2275 ]. |
|
2276 ^ h |
|
2277 |
|
2278 " |
|
2279 'abc' hash_java |
|
2280 'foofooHelloWorld' hash_java |
|
2281 'blablaHelloWorld' hash_java |
|
2282 " |
|
2283 ! |
|
2284 |
2245 levenshteinTo:aString |
2285 levenshteinTo:aString |
2246 "return the levenshtein distance to the argument, aString; |
2286 "return the levenshtein distance to the argument, aString; |
2247 this value corresponds to the number of replacements that have to be |
2287 this value corresponds to the number of replacements that have to be |
2248 made to get aString from the receiver. |
2288 made to get aString from the receiver. |
2249 See IEEE transactions on Computers 1976 Pg 172 ff." |
2289 See IEEE transactions on Computers 1976 Pg 172 ff." |
4127 |
4167 |
4128 "Modified: / 11-05-2010 / 19:12:37 / cg" |
4168 "Modified: / 11-05-2010 / 19:12:37 / cg" |
4129 ! ! |
4169 ! ! |
4130 |
4170 |
4131 |
4171 |
4132 |
|
4133 |
|
4134 !CharacterArray methodsFor:'matching - glob expressions'! |
4172 !CharacterArray methodsFor:'matching - glob expressions'! |
4135 |
4173 |
4136 compoundMatch:aString |
4174 compoundMatch:aString |
4137 "like match, but the receiver may be a compound match pattern, |
4175 "like match, but the receiver may be a compound match pattern, |
4138 consisting of multiple simple GLOB patterns, separated by semicolons. |
4176 consisting of multiple simple GLOB patterns, separated by semicolons. |
7002 "dispatch for visitor pattern; send #visitString:with: to aVisitor" |
7039 "dispatch for visitor pattern; send #visitString:with: to aVisitor" |
7003 |
7040 |
7004 ^ aVisitor visitString:self with:aParameter |
7041 ^ aVisitor visitString:self with:aParameter |
7005 ! ! |
7042 ! ! |
7006 |
7043 |
7007 |
|
7008 !CharacterArray class methodsFor:'documentation'! |
7044 !CharacterArray class methodsFor:'documentation'! |
7009 |
7045 |
7010 version |
7046 version |
7011 ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.543 2014-10-03 01:48:38 vrany Exp $' |
7047 ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.544 2014-10-08 08:49:47 cg Exp $' |
7012 ! |
7048 ! |
7013 |
7049 |
7014 version_CVS |
7050 version_CVS |
7015 ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.543 2014-10-03 01:48:38 vrany Exp $' |
7051 ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.544 2014-10-08 08:49:47 cg Exp $' |
7016 ! ! |
7052 ! ! |
7017 |
7053 |
7018 |
7054 |
7019 CharacterArray initialize! |
7055 CharacterArray initialize! |