CharacterArray.st
changeset 16887 8e30e6a52a64
parent 16875 32e61bb3a742
child 16898 0663e6b0d177
equal deleted inserted replaced
16886:247352d5de0f 16887:8e30e6a52a64
   281 
   281 
   282     "Modified: 28.6.1997 / 20:09:35 / cg"
   282     "Modified: 28.6.1997 / 20:09:35 / cg"
   283     "Created: 3.8.1997 / 18:16:40 / cg"
   283     "Created: 3.8.1997 / 18:16:40 / cg"
   284 ! !
   284 ! !
   285 
   285 
   286 
       
   287 !CharacterArray class methodsFor:'cleanup'!
   286 !CharacterArray class methodsFor:'cleanup'!
   288 
   287 
   289 lowSpaceCleanup
   288 lowSpaceCleanup
   290     "cleanup in low-memory situations"
   289     "cleanup in low-memory situations"
   291 
   290 
   324    invalid:
   323    invalid:
   325      CharacterArray fromUTF8Bytes:#[ 16rC0 16r80 ]
   324      CharacterArray fromUTF8Bytes:#[ 16rC0 16r80 ]
   326      CharacterArray fromUTF8Bytes:#[ 16rE0 16r80 16r80 ]
   325      CharacterArray fromUTF8Bytes:#[ 16rE0 16r80 16r80 ]
   327     "
   326     "
   328 ! !
   327 ! !
   329 
       
   330 
   328 
   331 !CharacterArray class methodsFor:'pattern matching'!
   329 !CharacterArray class methodsFor:'pattern matching'!
   332 
   330 
   333 matchEscapeCharacter
   331 matchEscapeCharacter
   334     "return the character used to escape a matchCharacter
   332     "return the character used to escape a matchCharacter
   723      Abstract subclasses must redefine again."
   721      Abstract subclasses must redefine again."
   724 
   722 
   725     ^ self == CharacterArray
   723     ^ self == CharacterArray
   726 ! !
   724 ! !
   727 
   725 
   728 
       
   729 !CharacterArray methodsFor:'Compatibility-ANSI'!
   726 !CharacterArray methodsFor:'Compatibility-ANSI'!
   730 
   727 
   731 addLineDelimiters
   728 addLineDelimiters
   732     "Ansi compatibility - same as withCRs"
   729     "Ansi compatibility - same as withCRs"
   733 
   730 
  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.
  4810 
  4848 
  4811     ^ aPatternString match:self caseSensitive:ignoreCase not
  4849     ^ aPatternString match:self caseSensitive:ignoreCase not
  4812 
  4850 
  4813     "Created: / 08-03-2012 / 03:11:11 / cg"
  4851     "Created: / 08-03-2012 / 03:11:11 / cg"
  4814 ! !
  4852 ! !
  4815 
       
  4816 
  4853 
  4817 
  4854 
  4818 !CharacterArray methodsFor:'padded copying'!
  4855 !CharacterArray methodsFor:'padded copying'!
  4819 
  4856 
  4820 centerPaddedTo:newSize
  4857 centerPaddedTo:newSize
  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!