Class CodePointTrie
java.lang.Object
org.graalvm.shadowed.com.ibm.icu.util.CodePointMap
org.graalvm.shadowed.com.ibm.icu.util.CodePointTrie
- All Implemented Interfaces:
Iterable<CodePointMap.Range>
- Direct Known Subclasses:
CodePointTrie.Fast,CodePointTrie.Small
Immutable Unicode code point trie.
Fast, reasonably compact, map from Unicode code points (U+0000..U+10FFFF) to integer values.
For details see https://icu.unicode.org/design/struct/utrie
This class is not intended for public subclassing.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA CodePointTrie withCodePointTrie.Type.FAST.static final classA CodePointTrie withCodePointTrie.Type.FASTandCodePointTrie.ValueWidth.BITS_16.static final classA CodePointTrie withCodePointTrie.Type.FASTandCodePointTrie.ValueWidth.BITS_32.static final classA CodePointTrie withCodePointTrie.Type.FASTandCodePointTrie.ValueWidth.BITS_8.static classA CodePointTrie withCodePointTrie.Type.SMALL.static final classA CodePointTrie withCodePointTrie.Type.SMALLandCodePointTrie.ValueWidth.BITS_16.static final classA CodePointTrie withCodePointTrie.Type.SMALLandCodePointTrie.ValueWidth.BITS_32.static final classA CodePointTrie withCodePointTrie.Type.SMALLandCodePointTrie.ValueWidth.BITS_8.static enumSelectors for the type of a CodePointTrie.static enumSelectors for the number of bits in a CodePointTrie data value.Nested classes/interfaces inherited from class org.graalvm.shadowed.com.ibm.icu.util.CodePointMap
CodePointMap.Range, CodePointMap.RangeOption, CodePointMap.StringIterator, CodePointMap.ValueFilter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.graalvm.shadowed.com.ibm.icu.util.CodePointTrie.DataDeprecated.This API is ICU internal only.protected final intDeprecated.This API is ICU internal only.protected final intDeprecated.This API is ICU internal only. -
Method Summary
Modifier and TypeMethodDescriptionfinal intasciiGet(int c) Returns a trie value for an ASCII code point, without range checking.protected abstract intcpIndex(int c) Deprecated.This API is ICU internal only.protected final intfastIndex(int c) Deprecated.This API is ICU internal only.static CodePointTriefromBinary(CodePointTrie.Type type, CodePointTrie.ValueWidth valueWidth, ByteBuffer bytes) Creates a trie from its binary form, stored in the ByteBuffer starting at the current position.intget(int c) Returns the value for a code point as stored in the map, with range checking.final booleangetRange(int start, CodePointMap.ValueFilter filter, CodePointMap.Range range) Sets the range object to a range of code points beginning with the start parameter.abstract CodePointTrie.TypegetType()Returns the trie type.final CodePointTrie.ValueWidthReturns the number of bits in a trie data value.protected final intsmallIndex(CodePointTrie.Type type, int c) Deprecated.This API is ICU internal only.final inttoBinary(OutputStream os) Writes a representation of the trie to the output stream.Methods inherited from class org.graalvm.shadowed.com.ibm.icu.util.CodePointMap
getRange, iterator, stringIteratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
data
Deprecated.This API is ICU internal only. -
dataLength
Deprecated.This API is ICU internal only. -
highStart
Deprecated.This API is ICU internal only.Start of the last range which ends at U+10FFFF.
-
-
Method Details
-
fromBinary
public static CodePointTrie fromBinary(CodePointTrie.Type type, CodePointTrie.ValueWidth valueWidth, ByteBuffer bytes) Creates a trie from its binary form, stored in the ByteBuffer starting at the current position. Advances the buffer position to just after the trie data. Inverse oftoBinary(OutputStream).The data is copied from the buffer; later modification of the buffer will not affect the trie.
- Parameters:
type- selects the trie type; this method throws an exception if the type does not match the binary data; use null to accept any typevalueWidth- selects the number of bits in a data value; this method throws an exception if the valueWidth does not match the binary data; use null to accept any data value widthbytes- a buffer containing the binary data of a CodePointTrie- Returns:
- the trie
- See Also:
-
getType
-
getValueWidth
Returns the number of bits in a trie data value.- Returns:
- the number of bits in a trie data value
-
get
public int get(int c) Returns the value for a code point as stored in the map, with range checking. Returns an implementation-defined error value if c is not in the range 0..U+10FFFF.- Specified by:
getin classCodePointMap- Parameters:
c- the code point- Returns:
- the map value, or an implementation-defined error value if the code point is not in the range 0..U+10FFFF
-
asciiGet
public final int asciiGet(int c) Returns a trie value for an ASCII code point, without range checking.- Parameters:
c- the input code point; must be U+0000..U+007F- Returns:
- The ASCII code point's trie value.
-
getRange
Sets the range object to a range of code points beginning with the start parameter. The range start is the same as the start input parameter (even if there are preceding code points that have the same value). The range end is the last code point such that all those from start to there have the same value. Returns false if start is not 0..U+10FFFF. Can be used to efficiently iterate over all same-value ranges in a map. (This is normally faster than iterating over code points and get()ting each value, but may be much slower than a data structure that stores ranges directly.)If the
CodePointMap.ValueFilterparameter is not null, then the value to be delivered is passed through that filter, and the return value is the end of the range where all values are modified to the same actual value. The value is unchanged if that parameter is null.Example:
int start = 0; CodePointMap.Range range = new CodePointMap.Range(); while (map.getRange(start, null, range)) { int end = range.getEnd(); int value = range.getValue(); // Work with the range start..end and its value. start = end + 1; }- Specified by:
getRangein classCodePointMap- Parameters:
start- range startfilter- an object that may modify the map data value, or null if the values from the map are to be used unmodifiedrange- the range object that will be set to the code point range and value- Returns:
- true if start is 0..U+10FFFF; otherwise no new range is fetched
-
toBinary
Writes a representation of the trie to the output stream. Inverse offromBinary(org.graalvm.shadowed.com.ibm.icu.util.CodePointTrie.Type, org.graalvm.shadowed.com.ibm.icu.util.CodePointTrie.ValueWidth, java.nio.ByteBuffer).- Parameters:
os- the output stream- Returns:
- the number of bytes written
-
fastIndex
Deprecated.This API is ICU internal only. -
smallIndex
Deprecated.This API is ICU internal only. -
cpIndex
Deprecated.This API is ICU internal only.
-