Changeset 8242 for trunk/mgpp/text/UCArray.cpp
- Timestamp:
- 2004-10-08T13:03:36+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mgpp/text/UCArray.cpp
r7944 r8242 244 244 } 245 245 246 // does the first string start with the second? 247 bool StartsWith (const UCArray &a1, const UCArray &a2) { 248 unsigned int l1 = a1.size(); 249 unsigned int l2 = a2.size(); 250 if (l2 > l1) { 251 // if the prefix is longer than the string, it can't start with it 252 return false; 253 } 254 unsigned int l =l2; 255 UCArray::const_iterator a1Here = a1.begin(); 256 UCArray::const_iterator a2Here = a2.begin(); 257 258 while (l--) { 259 if ((*a1Here != *a2Here)) 260 return false; 261 ++a1Here; 262 ++a2Here; 263 } 264 return true; // we have successfully matched the whole way 265 266 } 267 268 // does the first string start with the second, ignoring case? 269 bool StartsWithCasefold(const UCArray &a1, const UCArray &a2) { 270 unsigned int l1 = a1.size(); 271 unsigned int l2 = a2.size(); 272 if (l2 > l1) { 273 // if the prefix is longer than the string, it can't start with it 274 return false; 275 } 276 unsigned int l =l2; 277 UCArray::const_iterator a1Here = a1.begin(); 278 UCArray::const_iterator a2Here = a2.begin(); 279 280 while (l--) { 281 if (casecharmap[*a1Here] != casecharmap[*a2Here]) 282 return false; 283 ++a1Here; 284 ++a2Here; 285 } 286 return true; // we have successfully matched the whole way 287 288 } 289 290 246 291 unsigned long PrefixLen (const UCArray &a1, const UCArray &a2) { 247 292 unsigned long l = (a1.size() < a2.size()) ? a1.size() : a2.size();
Note:
See TracChangeset
for help on using the changeset viewer.