• Home
  • Raw
  • Download

Lines Matching +full:set +full:- +full:array

6 *   Copyright (C) 2002-2011, International Business Machines
11 * encoding: UTF-8
18 * There are functions to efficiently serialize a USet into an array of uint16_t
44 uset_close(USet* set) { in uset_close() argument
45 delete (UnicodeSet*) set; in uset_close()
49 uset_clone(const USet *set) { in uset_clone() argument
50 return (USet*) (((UnicodeSet*) set)->UnicodeSet::clone()); in uset_clone()
54 uset_isFrozen(const USet *set) { in uset_isFrozen() argument
55 return ((UnicodeSet*) set)->UnicodeSet::isFrozen(); in uset_isFrozen()
59 uset_freeze(USet *set) { in uset_freeze() argument
60 ((UnicodeSet*) set)->UnicodeSet::freeze(); in uset_freeze()
64 uset_cloneAsThawed(const USet *set) { in uset_cloneAsThawed() argument
65 return (USet*) (((UnicodeSet*) set)->UnicodeSet::cloneAsThawed()); in uset_cloneAsThawed()
69 uset_set(USet* set, in uset_set() argument
71 ((UnicodeSet*) set)->UnicodeSet::set(start, end); in uset_set()
75 uset_addAll(USet* set, const USet *additionalSet) { in uset_addAll() argument
76 ((UnicodeSet*) set)->UnicodeSet::addAll(*((const UnicodeSet*)additionalSet)); in uset_addAll()
80 uset_add(USet* set, UChar32 c) { in uset_add() argument
81 ((UnicodeSet*) set)->UnicodeSet::add(c); in uset_add()
85 uset_addRange(USet* set, UChar32 start, UChar32 end) { in uset_addRange() argument
86 ((UnicodeSet*) set)->UnicodeSet::add(start, end); in uset_addRange()
90 uset_addString(USet* set, const char16_t* str, int32_t strLen) { in uset_addString() argument
91 // UnicodeString handles -1 for strLen in uset_addString()
93 ((UnicodeSet*) set)->UnicodeSet::add(s); in uset_addString()
97 uset_addAllCodePoints(USet* set, const char16_t *str, int32_t strLen) { in uset_addAllCodePoints() argument
98 // UnicodeString handles -1 for strLen in uset_addAllCodePoints()
100 ((UnicodeSet*) set)->UnicodeSet::addAll(s); in uset_addAllCodePoints()
104 uset_remove(USet* set, UChar32 c) { in uset_remove() argument
105 ((UnicodeSet*) set)->UnicodeSet::remove(c); in uset_remove()
109 uset_removeRange(USet* set, UChar32 start, UChar32 end) { in uset_removeRange() argument
110 ((UnicodeSet*) set)->UnicodeSet::remove(start, end); in uset_removeRange()
114 uset_removeString(USet* set, const char16_t* str, int32_t strLen) { in uset_removeString() argument
115 UnicodeString s(strLen==-1, str, strLen); in uset_removeString()
116 ((UnicodeSet*) set)->UnicodeSet::remove(s); in uset_removeString()
120 uset_removeAllCodePoints(USet *set, const char16_t *str, int32_t length) { in uset_removeAllCodePoints() argument
121 UnicodeString s(length==-1, str, length); in uset_removeAllCodePoints()
122 ((UnicodeSet*) set)->UnicodeSet::removeAll(s); in uset_removeAllCodePoints()
126 uset_removeAll(USet* set, const USet* remove) { in uset_removeAll() argument
127 ((UnicodeSet*) set)->UnicodeSet::removeAll(*(const UnicodeSet*)remove); in uset_removeAll()
131 uset_retain(USet* set, UChar32 start, UChar32 end) { in uset_retain() argument
132 ((UnicodeSet*) set)->UnicodeSet::retain(start, end); in uset_retain()
136 uset_retainString(USet *set, const char16_t *str, int32_t length) { in uset_retainString() argument
137 UnicodeString s(length==-1, str, length); in uset_retainString()
138 ((UnicodeSet*) set)->UnicodeSet::retain(s); in uset_retainString()
142 uset_retainAllCodePoints(USet *set, const char16_t *str, int32_t length) { in uset_retainAllCodePoints() argument
143 UnicodeString s(length==-1, str, length); in uset_retainAllCodePoints()
144 ((UnicodeSet*) set)->UnicodeSet::retainAll(s); in uset_retainAllCodePoints()
148 uset_retainAll(USet* set, const USet* retain) { in uset_retainAll() argument
149 ((UnicodeSet*) set)->UnicodeSet::retainAll(*(const UnicodeSet*)retain); in uset_retainAll()
153 uset_compact(USet* set) { in uset_compact() argument
154 ((UnicodeSet*) set)->UnicodeSet::compact(); in uset_compact()
158 uset_complement(USet* set) { in uset_complement() argument
159 ((UnicodeSet*) set)->UnicodeSet::complement(); in uset_complement()
163 uset_complementRange(USet *set, UChar32 start, UChar32 end) { in uset_complementRange() argument
164 ((UnicodeSet*) set)->UnicodeSet::complement(start, end); in uset_complementRange()
168 uset_complementString(USet *set, const char16_t *str, int32_t length) { in uset_complementString() argument
169 UnicodeString s(length==-1, str, length); in uset_complementString()
170 ((UnicodeSet*) set)->UnicodeSet::complement(s); in uset_complementString()
174 uset_complementAllCodePoints(USet *set, const char16_t *str, int32_t length) { in uset_complementAllCodePoints() argument
175 UnicodeString s(length==-1, str, length); in uset_complementAllCodePoints()
176 ((UnicodeSet*) set)->UnicodeSet::complementAll(s); in uset_complementAllCodePoints()
180 uset_complementAll(USet* set, const USet* complement) { in uset_complementAll() argument
181 ((UnicodeSet*) set)->UnicodeSet::complementAll(*(const UnicodeSet*)complement); in uset_complementAll()
185 uset_clear(USet* set) { in uset_clear() argument
186 ((UnicodeSet*) set)->UnicodeSet::clear(); in uset_clear()
190 uset_removeAllStrings(USet* set) { in uset_removeAllStrings() argument
191 ((UnicodeSet*) set)->UnicodeSet::removeAllStrings(); in uset_removeAllStrings()
195 uset_isEmpty(const USet* set) { in uset_isEmpty() argument
196 return ((const UnicodeSet*) set)->UnicodeSet::isEmpty(); in uset_isEmpty()
200 uset_hasStrings(const USet* set) { in uset_hasStrings() argument
201 return ((const UnicodeSet*) set)->UnicodeSet::hasStrings(); in uset_hasStrings()
205 uset_contains(const USet* set, UChar32 c) { in uset_contains() argument
206 return ((const UnicodeSet*) set)->UnicodeSet::contains(c); in uset_contains()
210 uset_containsRange(const USet* set, UChar32 start, UChar32 end) { in uset_containsRange() argument
211 return ((const UnicodeSet*) set)->UnicodeSet::contains(start, end); in uset_containsRange()
215 uset_containsString(const USet* set, const char16_t* str, int32_t strLen) { in uset_containsString() argument
216 UnicodeString s(strLen==-1, str, strLen); in uset_containsString()
217 return ((const UnicodeSet*) set)->UnicodeSet::contains(s); in uset_containsString()
222 return ((const UnicodeSet*) set1)->UnicodeSet::containsAll(* (const UnicodeSet*) set2); in uset_containsAll()
226 uset_containsAllCodePoints(const USet* set, const char16_t *str, int32_t strLen) { in uset_containsAllCodePoints() argument
227 // Create a string alias, since nothing is being added to the set. in uset_containsAllCodePoints()
228 UnicodeString s(strLen==-1, str, strLen); in uset_containsAllCodePoints()
229 return ((const UnicodeSet*) set)->UnicodeSet::containsAll(s); in uset_containsAllCodePoints()
234 return ((const UnicodeSet*) set1)->UnicodeSet::containsNone(* (const UnicodeSet*) set2); in uset_containsNone()
239 return ((const UnicodeSet*) set1)->UnicodeSet::containsSome(* (const UnicodeSet*) set2); in uset_containsSome()
243 uset_span(const USet *set, const char16_t *s, int32_t length, USetSpanCondition spanCondition) { in uset_span() argument
244 return ((UnicodeSet*) set)->UnicodeSet::span(s, length, spanCondition); in uset_span()
248 uset_spanBack(const USet *set, const char16_t *s, int32_t length, USetSpanCondition spanCondition) { in uset_spanBack() argument
249 return ((UnicodeSet*) set)->UnicodeSet::spanBack(s, length, spanCondition); in uset_spanBack()
253 uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition) { in uset_spanUTF8() argument
254 return ((UnicodeSet*) set)->UnicodeSet::spanUTF8(s, length, spanCondition); in uset_spanUTF8()
258 uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition) { in uset_spanBackUTF8() argument
259 return ((UnicodeSet*) set)->UnicodeSet::spanBackUTF8(s, length, spanCondition); in uset_spanBackUTF8()
268 uset_indexOf(const USet* set, UChar32 c) { in uset_indexOf() argument
269 return ((UnicodeSet*) set)->UnicodeSet::indexOf(c); in uset_indexOf()
273 uset_charAt(const USet* set, int32_t index) { in uset_charAt() argument
274 return ((UnicodeSet*) set)->UnicodeSet::charAt(index); in uset_charAt()
278 uset_size(const USet* set) { in uset_size() argument
279 return ((const UnicodeSet*) set)->UnicodeSet::size(); in uset_size()
291 inline static int32_t getStringCount(const UnicodeSet& set) { in getStringCount() argument
292 return set.stringsSize(); in getStringCount()
294 inline static const UnicodeString* getString(const UnicodeSet& set, in getString() argument
296 return set.getString(i); in getString()
305 uset_getRangeCount(const USet *set) { in uset_getRangeCount() argument
306 return ((const UnicodeSet *)set)->UnicodeSet::getRangeCount(); in uset_getRangeCount()
311 const UnicodeSet& set = *(const UnicodeSet*)uset; in uset_getItemCount() local
312 return set.getRangeCount() + USetAccess::getStringCount(set); in uset_getItemCount()
321 const UnicodeSet& set = *(const UnicodeSet*)uset; in uset_getItem() local
326 return -1; in uset_getItem()
327 } else if (itemIndex < (rangeCount = set.getRangeCount())) { in uset_getItem()
328 *start = set.getRangeStart(itemIndex); in uset_getItem()
329 *end = set.getRangeEnd(itemIndex); in uset_getItem()
332 itemIndex -= rangeCount; in uset_getItem()
333 if (itemIndex < USetAccess::getStringCount(set)) { in uset_getItem()
334 const UnicodeString* s = USetAccess::getString(set, itemIndex); in uset_getItem()
335 return s->extract(str, strCapacity, *ec); in uset_getItem()
338 return -1; in uset_getItem()
344 //uset_getRange(const USet* set, int32_t rangeIndex,
346 // if ((uint32_t) rangeIndex >= (uint32_t) uset_getRangeCount(set)) {
349 // const UnicodeSet* us = (const UnicodeSet*) set;
350 // *pStart = us->getRangeStart(rangeIndex);
351 // *pEnd = us->getRangeEnd(rangeIndex);
356 * Serialize a USet into 16-bit units.
357 * Store BMP code points as themselves with one 16-bit unit each.
359 * Important: the code points in the array are in ascending order,
362 * Store each supplementary code point in 2 16-bit units,
363 * simply with higher-then-lower 16-bit halves.
366 * If there are supplementary code points, then set bit 15 in the length
367 * and add the bmpLength between it and the array.
370 * - all BMP: (length=bmpLength) BMP, .., BMP
371 * - some supplementary: (length|0x8000) (bmpLength<length) BMP, .., BMP, supp-high, supp-low, ..
374 uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* ec) { in uset_serialize() argument
379 return ((const UnicodeSet*) set)->UnicodeSet::serialize(dest, destCapacity,* ec); in uset_serialize()
390 fillSet->length=fillSet->bmpLength=0; in uset_getSerializedSet()
399 fillSet->length=fillSet->bmpLength=0; in uset_getSerializedSet()
402 fillSet->bmpLength=*src++; in uset_getSerializedSet()
406 fillSet->length=fillSet->bmpLength=0; in uset_getSerializedSet()
409 fillSet->bmpLength=length; in uset_getSerializedSet()
411 fillSet->array=src; in uset_getSerializedSet()
412 fillSet->length=length; in uset_getSerializedSet()
422 fillSet->array=fillSet->staticArray; in uset_setSerializedToOne()
424 fillSet->bmpLength=fillSet->length=2; in uset_setSerializedToOne()
425 fillSet->staticArray[0]=(uint16_t)c; in uset_setSerializedToOne()
426 fillSet->staticArray[1]=(uint16_t)c+1; in uset_setSerializedToOne()
428 fillSet->bmpLength=1; in uset_setSerializedToOne()
429 fillSet->length=3; in uset_setSerializedToOne()
430 fillSet->staticArray[0]=0xffff; in uset_setSerializedToOne()
431 fillSet->staticArray[1]=1; in uset_setSerializedToOne()
432 fillSet->staticArray[2]=0; in uset_setSerializedToOne()
434 fillSet->bmpLength=0; in uset_setSerializedToOne()
435 fillSet->length=4; in uset_setSerializedToOne()
436 fillSet->staticArray[0]=(uint16_t)(c>>16); in uset_setSerializedToOne()
437 fillSet->staticArray[1]=(uint16_t)c; in uset_setSerializedToOne()
439 fillSet->staticArray[2]=(uint16_t)(c>>16); in uset_setSerializedToOne()
440 fillSet->staticArray[3]=(uint16_t)c; in uset_setSerializedToOne()
442 fillSet->bmpLength=0; in uset_setSerializedToOne()
443 fillSet->length=2; in uset_setSerializedToOne()
444 fillSet->staticArray[0]=0x10; in uset_setSerializedToOne()
445 fillSet->staticArray[1]=0xffff; in uset_setSerializedToOne()
450 uset_serializedContains(const USerializedSet* set, UChar32 c) { in uset_serializedContains() argument
451 const uint16_t* array; in uset_serializedContains() local
453 if(set==nullptr || (uint32_t)c>0x10ffff) { in uset_serializedContains()
457 array=set->array; in uset_serializedContains()
461 int32_t hi = set->bmpLength-1; in uset_serializedContains()
462 if (c < array[0]) { in uset_serializedContains()
464 } else if (c < array[hi]) { in uset_serializedContains()
469 } else if (c < array[i]) { in uset_serializedContains()
482 int32_t base = set->bmpLength; in uset_serializedContains()
484 int32_t hi = set->length - 2 - base; in uset_serializedContains()
485 if (high < array[base] || (high==array[base] && low<array[base+1])) { in uset_serializedContains()
487 } else if (high < array[base+hi] || (high==array[base+hi] && low<array[base+hi+1])) { in uset_serializedContains()
493 } else if (high < array[iabs] || (high==array[iabs] && low<array[iabs+1])) { in uset_serializedContains()
502 /* count pairs of 16-bit units even per BMP and check if the number of pairs is odd */ in uset_serializedContains()
508 uset_getSerializedRangeCount(const USerializedSet* set) { in uset_getSerializedRangeCount() argument
509 if(set==nullptr) { in uset_getSerializedRangeCount()
513 return (set->bmpLength+(set->length-set->bmpLength)/2+1)/2; in uset_getSerializedRangeCount()
517 uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, in uset_getSerializedRange() argument
519 const uint16_t* array; in uset_getSerializedRange() local
522 if(set==nullptr || rangeIndex<0 || pStart==nullptr || pEnd==nullptr) { in uset_getSerializedRange()
526 array=set->array; in uset_getSerializedRange()
527 length=set->length; in uset_getSerializedRange()
528 bmpLength=set->bmpLength; in uset_getSerializedRange()
532 *pStart=array[rangeIndex++]; in uset_getSerializedRange()
534 *pEnd=array[rangeIndex]-1; in uset_getSerializedRange()
536 *pEnd=((((int32_t)array[rangeIndex])<<16)|array[rangeIndex+1])-1; in uset_getSerializedRange()
542 rangeIndex-=bmpLength; in uset_getSerializedRange()
544 length-=bmpLength; in uset_getSerializedRange()
546 array+=bmpLength; in uset_getSerializedRange()
547 *pStart=(((int32_t)array[rangeIndex])<<16)|array[rangeIndex+1]; in uset_getSerializedRange()
550 *pEnd=((((int32_t)array[rangeIndex])<<16)|array[rangeIndex+1])-1; in uset_getSerializedRange()
562 // Returned the one and only code point, or else -1 or something.
568 // ---
572 // findChar(const UChar32* array, int32_t length, UChar32 c) {
577 // if(c>=array[length-1]) {
582 // --length;
585 // for(i=0; i<length && c>=array[i]; ++i) {}
590 // addRemove(USet* set, UChar32 c, int32_t doRemove) {
593 // if(set==nullptr || (uint32_t)c>0x10ffff) {
597 // length=set->length;
598 // i=findChar(set->array, length, c);
600 // /* c is already in the set */
604 // /* how many more array items do we need? */
605 // if(i<length && (c+1)==set->array[i]) {
606 // /* c is just before the following range, extend that in-place by one */
607 // set->array[i]=c;
609 // --i;
610 // if(c==set->array[i]) {
612 // set->length=length-=2;
614 // uprv_memmove(set->array+i, set->array+i+2, (length-i)*4);
619 // } else if(i>0 && c==set->array[i-1]) {
620 // /* c is just after the previous range, extend that in-place by one */
622 // set->array[i-1]=c;
623 // if(i<length && c==set->array[i]) {
625 // --i;
626 // set->length=length-=2;
628 // uprv_memmove(set->array+i, set->array+i+2, (length-i)*4);
633 // set->length=i-1;
645 // if(length+more>set->capacity) {
647 // int32_t newCapacity=set->capacity+set->capacity/2+USET_GROW_DELTA;
652 // set->capacity=newCapacity;
653 // uprv_memcpy(newArray, set->array, length*4);
655 // if(set->array!=set->staticBuffer) {
656 // uprv_free(set->array);
658 // set->array=newArray;
662 // uprv_memmove(set->array+i+more, set->array+i, (length-i)*4);
664 // set->array[i]=c;
666 // set->array[i+1]=c+1;
668 // set->length+=more;
674 // uset_add(USet* set, UChar32 c) {
675 // return addRemove(set, c, 0);
679 // uset_remove(USet* set, UChar32 c) {
680 // addRemove(set, c, 1);