Package com.ibm.icu.impl.coll
Class CollationWeights
- java.lang.Object
-
- com.ibm.icu.impl.coll.CollationWeights
-
public final class CollationWeights extends java.lang.Object
Allocates n collation element weights between two exclusive limits. Used only internally by the collation tailoring builder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CollationWeights.WeightRange
-
Field Summary
Fields Modifier and Type Field Description private int[]
maxBytes
private int
middleLength
private int[]
minBytes
private int
rangeCount
private int
rangeIndex
private CollationWeights.WeightRange[]
ranges
-
Constructor Summary
Constructors Constructor Description CollationWeights()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allocWeights(long lowerLimit, long upperLimit, int n)
Determine heuristically what ranges to use for a given number of weights between (excluding) two limits.private boolean
allocWeightsInMinLengthRanges(int n, int minLength)
private boolean
allocWeightsInShortRanges(int n, int minLength)
private int
countBytes(int idx)
private static long
decWeightTrail(long weight, int length)
private static int
getWeightByte(long weight, int idx)
private boolean
getWeightRanges(long lowerLimit, long upperLimit)
Takes two CE weights and calculates the possible ranges of weights between the two limits, excluding them.private static int
getWeightTrail(long weight, int length)
private long
incWeight(long weight, int length)
private long
incWeightByOffset(long weight, int length, int offset)
private static long
incWeightTrail(long weight, int length)
void
initForPrimary(boolean compressible)
void
initForSecondary()
void
initForTertiary()
private void
lengthenRange(CollationWeights.WeightRange range)
static int
lengthOfWeight(long weight)
long
nextWeight()
Given a set of ranges calculated by allocWeights(), iterate through the weights.private static long
setWeightByte(long weight, int idx, int b)
private static long
setWeightTrail(long weight, int length, int trail)
private static long
truncateWeight(long weight, int length)
-
-
-
Field Detail
-
middleLength
private int middleLength
-
minBytes
private int[] minBytes
-
maxBytes
private int[] maxBytes
-
ranges
private CollationWeights.WeightRange[] ranges
-
rangeIndex
private int rangeIndex
-
rangeCount
private int rangeCount
-
-
Method Detail
-
initForPrimary
public void initForPrimary(boolean compressible)
-
initForSecondary
public void initForSecondary()
-
initForTertiary
public void initForTertiary()
-
allocWeights
public boolean allocWeights(long lowerLimit, long upperLimit, int n)
Determine heuristically what ranges to use for a given number of weights between (excluding) two limits.- Parameters:
lowerLimit
- A collation element weight; the ranges will be filled to cover weights greater than this one.upperLimit
- A collation element weight; the ranges will be filled to cover weights less than this one.n
- The number of collation element weights w necessary such that lowerLimit- Returns:
- true if it is possible to fit n elements between the limits
-
nextWeight
public long nextWeight()
Given a set of ranges calculated by allocWeights(), iterate through the weights. The ranges are modified to keep the current iteration state.- Returns:
- The next weight in the ranges, or 0xffffffff if there is none left.
-
lengthOfWeight
public static int lengthOfWeight(long weight)
-
getWeightTrail
private static int getWeightTrail(long weight, int length)
-
setWeightTrail
private static long setWeightTrail(long weight, int length, int trail)
-
getWeightByte
private static int getWeightByte(long weight, int idx)
-
setWeightByte
private static long setWeightByte(long weight, int idx, int b)
-
truncateWeight
private static long truncateWeight(long weight, int length)
-
incWeightTrail
private static long incWeightTrail(long weight, int length)
-
decWeightTrail
private static long decWeightTrail(long weight, int length)
-
countBytes
private int countBytes(int idx)
- Returns:
- number of usable byte values for byte idx
-
incWeight
private long incWeight(long weight, int length)
-
incWeightByOffset
private long incWeightByOffset(long weight, int length, int offset)
-
lengthenRange
private void lengthenRange(CollationWeights.WeightRange range)
-
getWeightRanges
private boolean getWeightRanges(long lowerLimit, long upperLimit)
Takes two CE weights and calculates the possible ranges of weights between the two limits, excluding them. For weights with up to 4 bytes there are up to 2*4-1=7 ranges.
-
allocWeightsInShortRanges
private boolean allocWeightsInShortRanges(int n, int minLength)
-
allocWeightsInMinLengthRanges
private boolean allocWeightsInMinLengthRanges(int n, int minLength)
-
-