Lines Matching refs:ranges
121 /* for uprv_sortArray: sort ranges in weight order */
139 * possible ranges of weights between the two limits, excluding them
140 * for weights with up to 4 bytes there are up to 2*4-1=7 ranges
145 WeightRange ranges[7]) {
185 * With the limit lengths of 1..4, there are up to 7 ranges for allocation:
195 * We are now going to calculate up to 7 ranges.
196 * Some of them will typically overlap, so we will then have to merge and eliminate ranges.
235 /* reduce or remove the lower ranges that go beyond upperLimit */
242 /* lower and upper ranges collide or are directly adjacent: merge these two and remove all shorter ranges */
246 * merging directly adjacent ranges needs to subtract the 0/1 gaps in between;
263 /* print ranges */
279 /* copy the ranges, shortest first, into the result array */
282 uprv_memcpy(ranges, &middle, sizeof(WeightRange));
288 uprv_memcpy(ranges+rangeCount, upper+length, sizeof(WeightRange));
292 uprv_memcpy(ranges+rangeCount, lower+length, sizeof(WeightRange));
301 * which ranges to use for a given number of weights between (excluding)
308 WeightRange ranges[7]) {
329 rangeCount=getWeightRanges(lowerLimit, upperLimit, maxByte, countBytes, ranges);
332 printf("error: unable to get Weight ranges\n");
337 /* what is the maximum number of weights with these ranges? */
340 maxCount+=(uint32_t)ranges[i].count*powers[4-ranges[i].length];
355 ranges[i].length2=ranges[i].length;
356 ranges[i].count2=(uint32_t)ranges[i].count;
359 /* try until we find suitably large ranges */
362 minLength=ranges[0].length2;
364 /* sum up the number of elements that fit into ranges of each byte length */
367 lengthCounts[ranges[i].length2]+=ranges[i].count2;
370 /* now try to allocate n elements in the available short ranges */
372 /* trivial cases, use the first few ranges */
376 maxCount+=ranges[rangeCount].count2;
380 printf("take first %ld ranges\n", rangeCount);
383 } else if(n<=ranges[0].count2*countBytes) {
390 power_1=powers[minLength-ranges[0].length];
393 count1=ranges[0].count-count2;
403 lengthenRange(ranges, maxByte, countBytes);
410 ranges[1].end=ranges[0].end;
411 ranges[1].length=ranges[0].length;
412 ranges[1].length2=minLength;
415 i=ranges[0].length;
416 byte=getWeightByte(ranges[0].start, i)+count1-1;
419 * ranges[0].count and count1 may be >countBytes
420 * from merging adjacent ranges;
424 ranges[0].end=setWeightByte(ranges[0].start, i, byte);
426 ranges[0].end=setWeightByte(incWeight(ranges[0].start, i-1, maxByte), i, byte-countBytes);
431 ranges[0].end=truncateWeight(ranges[0].end, i)|
435 ranges[1].start=incWeight(ranges[0].end, minLength, maxByte);
438 ranges[0].count=count1;
439 ranges[1].count=count2;
441 ranges[0].count2=count1*power_1;
442 ranges[1].count2=count2*power_1; /* will be *countBytes when lengthened */
445 lengthenRange(ranges+1, maxByte, countBytes);
450 /* no good match, lengthen all minLength ranges and iterate */
452 printf("lengthen the short ranges from %ld bytes to %ld and iterate\n", minLength, minLength+1);
454 for(i=0; ranges[i].length2==minLength; ++i) {
455 lengthenRange(ranges+i, maxByte, countBytes);
460 /* sort the ranges by weight values */
462 uprv_sortArray(ranges, rangeCount, sizeof(WeightRange), compareRanges, NULL, FALSE, &errorCode);
467 puts("final ranges:");
469 printf("ranges[%ld] .start=0x%08lx .end=0x%08lx .length=%ld .length2=%ld .count=%ld .count2=%lu\n",
470 i, ranges[i].start, ranges[i].end, ranges[i].length, ranges[i].length2, ranges[i].count, ranges[i].count2);
474 /* set maxByte in ranges[0] for ucol_nextWeight() */
475 ranges[0].count=maxByte;
481 * given a set of ranges calculated by ucol_allocWeights(),
485 ranges[], int32_t *pRangeCount) {
492 maxByte=ranges[0].count;
495 weight=ranges[0].start;
496 if(weight==ranges[0].end) {
499 uprv_memmove(ranges, ranges+1, *pRangeCount*sizeof(WeightRange));
500 ranges[0].count=maxByte; /* keep maxByte in ranges[0] */
504 ranges[0].start=incWeight(weight, ranges[0].length2, maxByte);
515 WeightRange ranges[8];
518 rangeCount=ucol_allocWeights(lowerLimit, upperLimit, n, ranges);
523 weight=ucol_nextWeight(ranges, &rangeCount);