Lines Matching +full:- +full:- +full:length
6 * Copyright (C) 1999-2015, International Business Machines
11 * encoding: UTF-8
39 /* collation element weight allocation -------------------------------------- */
44 getWeightTrail(uint32_t weight, int32_t length) { in getWeightTrail() argument
45 return (weight >> (8 * (4 - length))) & 0xff; in getWeightTrail()
49 setWeightTrail(uint32_t weight, int32_t length, uint32_t trail) { in setWeightTrail() argument
50 length=8*(4-length); in setWeightTrail()
51 return static_cast<uint32_t>((weight & (0xffffff00 << length)) | (trail << length)); in setWeightTrail()
61 uint32_t mask; /* 0xffffffff except a 00 "hole" for the index-th byte */ in setWeightByte()
78 idx=32-idx; in setWeightByte()
84 truncateWeight(uint32_t weight, int32_t length) { in truncateWeight() argument
85 return static_cast<uint32_t>(weight & (0xffffffff << (8 * (4 - length)))); in truncateWeight()
89 incWeightTrail(uint32_t weight, int32_t length) { in incWeightTrail() argument
90 return static_cast<uint32_t>(weight + (1UL << (8 * (4 - length)))); in incWeightTrail()
94 decWeightTrail(uint32_t weight, int32_t length) { in decWeightTrail() argument
95 return static_cast<uint32_t>(weight - (1UL << (8 * (4 - length)))); in decWeightTrail()
112 maxBytes[2] = Collation::PRIMARY_COMPRESSION_HIGH_BYTE - 1; in initForPrimary()
154 CollationWeights::incWeight(uint32_t weight, int32_t length) const { in incWeight()
156 uint32_t byte=getWeightByte(weight, length); in incWeight()
157 if(byte<maxBytes[length]) { in incWeight()
158 return setWeightByte(weight, length, byte+1); in incWeight()
161 weight=setWeightByte(weight, length, minBytes[length]); in incWeight()
162 --length; in incWeight()
163 U_ASSERT(length > 0); in incWeight()
169 CollationWeights::incWeightByOffset(uint32_t weight, int32_t length, int32_t offset) const { in incWeightByOffset() argument
171 offset += getWeightByte(weight, length); in incWeightByOffset()
172 if (static_cast<uint32_t>(offset) <= maxBytes[length]) { in incWeightByOffset()
173 return setWeightByte(weight, length, offset); in incWeightByOffset()
176 offset -= minBytes[length]; in incWeightByOffset()
177 weight = setWeightByte(weight, length, minBytes[length] + offset % countBytes(length)); in incWeightByOffset()
178 offset /= countBytes(length); in incWeightByOffset()
179 --length; in incWeightByOffset()
180 U_ASSERT(length > 0); in incWeightByOffset()
187 int32_t length=range.length+1; in lengthenRange() local
188 range.start=setWeightTrail(range.start, length, minBytes[length]); in lengthenRange()
189 range.end=setWeightTrail(range.end, length, maxBytes[length]); in lengthenRange()
190 range.count*=countBytes(length); in lengthenRange()
191 range.length=length; in lengthenRange()
199 l = static_cast<const CollationWeights::WeightRange*>(left)->start; in compareRanges()
200 r = static_cast<const CollationWeights::WeightRange*>(right)->start; in compareRanges()
202 return -1; in compareRanges()
220 printf("length of lower limit 0x%08lx is %ld\n", lowerLimit, lowerLength); in getWeightRanges()
221 printf("length of upper limit 0x%08lx is %ld\n", upperLimit, upperLength); in getWeightRanges()
244 … WeightRange lower[5], middle, upper[5]; /* [0] and [1] are not used - this simplifies indexing */ in getWeightRanges()
251 * range minimum length in getWeightRanges()
264 for(int32_t length=lowerLength; length>middleLength; --length) { in getWeightRanges() local
265 uint32_t trail=getWeightTrail(weight, length); in getWeightRanges()
266 if(trail<maxBytes[length]) { in getWeightRanges()
267 lower[length].start=incWeightTrail(weight, length); in getWeightRanges()
268 lower[length].end=setWeightTrail(weight, length, maxBytes[length]); in getWeightRanges()
269 lower[length].length=length; in getWeightRanges()
270 lower[length].count=maxBytes[length]-trail; in getWeightRanges()
272 weight=truncateWeight(weight, length-1); in getWeightRanges()
283 for(int32_t length=upperLength; length>middleLength; --length) { in getWeightRanges() local
284 uint32_t trail=getWeightTrail(weight, length); in getWeightRanges()
285 if(trail>minBytes[length]) { in getWeightRanges()
286 upper[length].start=setWeightTrail(weight, length, minBytes[length]); in getWeightRanges()
287 upper[length].end=decWeightTrail(weight, length); in getWeightRanges()
288 upper[length].length=length; in getWeightRanges()
289 upper[length].count=trail-minBytes[length]; in getWeightRanges()
291 weight=truncateWeight(weight, length-1); in getWeightRanges()
296 middle.length=middleLength; in getWeightRanges()
298 … middle.count = static_cast<int32_t>((middle.end - middle.start) >> (8 * (4 - middleLength))) + 1; in getWeightRanges()
301 for(int32_t length=4; length>middleLength; --length) { in getWeightRanges() local
302 if(lower[length].count>0 && upper[length].count>0) { in getWeightRanges()
305 // truncated (still less-or-equal) in getWeightRanges()
308 const uint32_t lowerEnd=lower[length].end; in getWeightRanges()
309 const uint32_t upperStart=upper[length].start; in getWeightRanges()
320 U_ASSERT(truncateWeight(lowerEnd, length-1)== in getWeightRanges()
321 truncateWeight(upperStart, length-1)); in getWeightRanges()
323 lower[length].end=upper[length].end; in getWeightRanges()
324 lower[length].count= in getWeightRanges()
325 static_cast<int32_t>(getWeightTrail(lower[length].end, length)) - in getWeightRanges()
326 static_cast<int32_t>(getWeightTrail(lower[length].start, length)) + 1; in getWeightRanges()
328 // and the range-collecting code below will ignore this range. in getWeightRanges()
332 U_ASSERT(minBytes[length]<maxBytes[length]); in getWeightRanges()
334 if(incWeight(lowerEnd, length)==upperStart) { in getWeightRanges()
336 lower[length].end=upper[length].end; in getWeightRanges()
337 lower[length].count+=upper[length].count; // might be >countBytes in getWeightRanges()
344 upper[length].count=0; in getWeightRanges()
345 while(--length>middleLength) { in getWeightRanges()
346 lower[length].count=upper[length].count=0; in getWeightRanges()
356 for(int32_t length=4; length>=2; --length) { in getWeightRanges() local
357 if(lower[length].count>0) { in getWeightRanges()
358 …d] .start=0x%08lx .end=0x%08lx .count=%ld\n", length, lower[length].start, lower[length].end, lowe… in getWeightRanges()
364 for(int32_t length=2; length<=4; ++length) { in getWeightRanges() local
365 if(upper[length].count>0) { in getWeightRanges()
366 …d] .start=0x%08lx .end=0x%08lx .count=%ld\n", length, upper[length].start, upper[length].end, uppe… in getWeightRanges()
377 for(int32_t length=middleLength+1; length<=4; ++length) { in getWeightRanges() local
379 if(upper[length].count>0) { in getWeightRanges()
380 uprv_memcpy(ranges+rangeCount, upper+length, sizeof(WeightRange)); in getWeightRanges()
383 if(lower[length].count>0) { in getWeightRanges()
384 uprv_memcpy(ranges+rangeCount, lower+length, sizeof(WeightRange)); in getWeightRanges()
394 for(int32_t i = 0; i < rangeCount && ranges[i].length <= (minLength + 1); ++i) { in allocWeightsInShortRanges()
397 if(ranges[i].length > minLength) { in allocWeightsInShortRanges()
417 n -= ranges[i].count; // still >0 in allocWeightsInShortRanges()
430 ranges[minLengthRangeCount].length == minLength; in allocWeightsInMinLengthRanges()
451 // (count - count2) + count2 * nextCountBytes = n in allocWeightsInMinLengthRanges()
453 int32_t count2 = (n - count) / (nextCountBytes - 1); // number of weights to be lengthened in allocWeightsInMinLengthRanges()
454 int32_t count1 = count - count2; // number of minLength weights in allocWeightsInMinLengthRanges()
458 --count1; in allocWeightsInMinLengthRanges()
478 ranges[0].end = incWeightByOffset(start, minLength, count1 - 1); in allocWeightsInMinLengthRanges()
483 ranges[1].length = minLength; // +1 when lengthened in allocWeightsInMinLengthRanges()
512 int32_t minLength=ranges[0].length; in allocWeights()
530 for(int32_t i=0; i<rangeCount && ranges[i].length==minLength; ++i) { in allocWeights()
538 printf("ranges[%ld] .start=0x%08lx .end=0x%08lx .length=%ld .count=%ld\n", in allocWeights()
539 i, ranges[i].start, ranges[i].end, ranges[i].length, ranges[i].count); in allocWeights()
555 if(--range.count == 0) { in nextWeight()
560 range.start = incWeight(weight, range.length); in nextWeight()