Class Trie2Writable
java.lang.Object
com.ibm.icu.impl.Trie2
com.ibm.icu.impl.Trie2Writable
- All Implemented Interfaces:
Iterable<Trie2.Range>
-
Nested Class Summary
Nested classes/interfaces inherited from class Trie2
Trie2.CharSequenceIterator, Trie2.CharSequenceValues, Trie2.Range, Trie2.Trie2Iterator, Trie2.UTrie2Header, Trie2.ValueMapper, Trie2.ValueWidth -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]private intprivate intprivate int[]private int[]private intprivate intprivate booleanprivate int[]private static final intThe start of data blocks for U+0800 and above.private static final intThe null data block.private static final intThe start of allocated data blocks.private static final intThe null index-2 block, following the gap in the index-2 table.private static final intThe start of allocated index-2 blocks.private static final intprivate static final intprivate booleanprivate static final intMaximum length of the runtime data array.private static final intMaximum length of the runtime index array.Fields inherited from class Trie2
data16, data32, dataLength, dataNullOffset, errorValue, fHash, header, highStart, highValueIndex, index, indexLength, initialValue, UNEWTRIE2_INDEX_1_LENGTH, UNEWTRIE2_INDEX_GAP_LENGTH, UNEWTRIE2_INDEX_GAP_OFFSET, UNEWTRIE2_MAX_DATA_LENGTH, UNEWTRIE2_MAX_INDEX_2_LENGTH, UTRIE2_BAD_UTF8_DATA_OFFSET, UTRIE2_CP_PER_INDEX_1_ENTRY, UTRIE2_DATA_BLOCK_LENGTH, UTRIE2_DATA_GRANULARITY, UTRIE2_DATA_MASK, UTRIE2_DATA_START_OFFSET, UTRIE2_INDEX_1_OFFSET, UTRIE2_INDEX_2_BLOCK_LENGTH, UTRIE2_INDEX_2_BMP_LENGTH, UTRIE2_INDEX_2_MASK, UTRIE2_INDEX_2_OFFSET, UTRIE2_INDEX_SHIFT, UTRIE2_LSCP_INDEX_2_LENGTH, UTRIE2_LSCP_INDEX_2_OFFSET, UTRIE2_MAX_INDEX_1_LENGTH, UTRIE2_OMITTED_BMP_INDEX_1_LENGTH, UTRIE2_OPTIONS_VALUE_BITS_MASK, UTRIE2_SHIFT_1, UTRIE2_SHIFT_1_2, UTRIE2_SHIFT_2, UTRIE2_UTF8_2B_INDEX_2_LENGTH, UTRIE2_UTF8_2B_INDEX_2_OFFSET -
Constructor Summary
ConstructorsConstructorDescriptionTrie2Writable(int initialValueP, int errorValueP) Create a new, empty, writable Trie2.Trie2Writable(Trie2 source) Create a new build time (modifiable) Trie2 whose contents are the same as the source Trie2. -
Method Summary
Modifier and TypeMethodDescriptionprivate intallocDataBlock(int copyBlock) private intprivate voidprivate voidprivate voidprivate booleanequal_int(int[] a, int s, int t, int length) private voidfillBlock(int block, int start, int limit, int value, int initialValue, boolean overwrite) initialValue is ignored if overwrite=trueprivate intfindHighStart(int highValue) private intfindSameDataBlock(int dataLength, int otherBlock, int blockLength) private intfindSameIndex2Block(int index2Length, int otherBlock) private voidfreeze(Trie2 dest, Trie2.ValueWidth valueBits) intget(int codePoint) Get the value for a code point as stored in the Trie2.private intget(int c, boolean fromLSCP) private intgetDataBlock(int c, boolean forLSCP) No error checking for illegal arguments.intgetFromU16SingleLead(char c) Get a trie value for a UTF-16 code unit.private intgetIndex2Block(int c, boolean forLSCP) private voidinit(int initialValueP, int errorValueP) private booleanisInNullBlock(int c, boolean forLSCP) private booleanisWritableBlock(int block) private voidreleaseDataBlock(int block) private Trie2Writableset(int c, boolean forLSCP, int value) set(int c, int value) Set a value for a code point.setForLeadSurrogateCodeUnit(char codeUnit, int value) Set a value for a UTF-16 code unit.private voidsetIndex2Entry(int i2, int block) setRange(int start, int end, int value, boolean overwrite) Set a value in a range of code points [start..end].setRange(Trie2.Range range, boolean overwrite) Set the values from a Trie2.Range.Produce an optimized, read-only Trie2_16 from this writable Trie.Produce an optimized, read-only Trie2_32 from this writable Trie.private voidprivate voidwriteBlock(int block, int value) Methods inherited from class Trie2
charSequenceIterator, createFromSerialized, equals, getVersion, hashCode, iterator, iterator, iteratorForLeadSurrogate, iteratorForLeadSurrogate, rangeEnd, serializeHeaderMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
UTRIE2_MAX_INDEX_LENGTH
private static final int UTRIE2_MAX_INDEX_LENGTHMaximum length of the runtime index array. Limited by its own 16-bit index values, and by uint16_t UTrie2Header.indexLength. (The actual maximum length is lower, (0x110000>>UTRIE2_SHIFT_2)+UTRIE2_UTF8_2B_INDEX_2_LENGTH+UTRIE2_MAX_INDEX_1_LENGTH.)- See Also:
-
UTRIE2_MAX_DATA_LENGTH
private static final int UTRIE2_MAX_DATA_LENGTHMaximum length of the runtime data array. Limited by 16-bit index values that are left-shifted by UTRIE2_INDEX_SHIFT, and by uint16_t UTrie2Header.shiftedDataLength.- See Also:
-
UNEWTRIE2_INITIAL_DATA_LENGTH
private static final int UNEWTRIE2_INITIAL_DATA_LENGTH- See Also:
-
UNEWTRIE2_MEDIUM_DATA_LENGTH
private static final int UNEWTRIE2_MEDIUM_DATA_LENGTH- See Also:
-
UNEWTRIE2_INDEX_2_NULL_OFFSET
private static final int UNEWTRIE2_INDEX_2_NULL_OFFSETThe null index-2 block, following the gap in the index-2 table.- See Also:
-
UNEWTRIE2_INDEX_2_START_OFFSET
private static final int UNEWTRIE2_INDEX_2_START_OFFSETThe start of allocated index-2 blocks.- See Also:
-
UNEWTRIE2_DATA_NULL_OFFSET
private static final int UNEWTRIE2_DATA_NULL_OFFSETThe null data block. Length 64=0x40 even if UTRIE2_DATA_BLOCK_LENGTH is smaller, to work with 6-bit trail bytes from 2-byte UTF-8.- See Also:
-
UNEWTRIE2_DATA_START_OFFSET
private static final int UNEWTRIE2_DATA_START_OFFSETThe start of allocated data blocks.- See Also:
-
UNEWTRIE2_DATA_0800_OFFSET
private static final int UNEWTRIE2_DATA_0800_OFFSETThe start of data blocks for U+0800 and above. Below, compaction uses a block length of 64 for 2-byte UTF-8. From here on, compaction uses UTRIE2_DATA_BLOCK_LENGTH. Data values for 0x780 code points beyond ASCII.- See Also:
-
index1
private int[] index1 -
index2
private int[] index2 -
data
private int[] data -
index2Length
private int index2Length -
dataCapacity
private int dataCapacity -
firstFreeBlock
private int firstFreeBlock -
index2NullOffset
private int index2NullOffset -
isCompacted
private boolean isCompacted -
map
private int[] map -
UTRIE2_DEBUG
private boolean UTRIE2_DEBUG
-
-
Constructor Details
-
Trie2Writable
public Trie2Writable(int initialValueP, int errorValueP) Create a new, empty, writable Trie2. 32-bit data values are used.- Parameters:
initialValueP- the initial value that is set for all code pointserrorValueP- the value for out-of-range code points and illegal UTF-8
-
Trie2Writable
Create a new build time (modifiable) Trie2 whose contents are the same as the source Trie2.- Parameters:
source- the source Trie2. Its contents will be copied into the new Trie2.
-
-
Method Details
-
init
private void init(int initialValueP, int errorValueP) -
isInNullBlock
private boolean isInNullBlock(int c, boolean forLSCP) -
allocIndex2Block
private int allocIndex2Block() -
getIndex2Block
private int getIndex2Block(int c, boolean forLSCP) -
allocDataBlock
private int allocDataBlock(int copyBlock) -
releaseDataBlock
private void releaseDataBlock(int block) -
isWritableBlock
private boolean isWritableBlock(int block) -
setIndex2Entry
private void setIndex2Entry(int i2, int block) -
getDataBlock
private int getDataBlock(int c, boolean forLSCP) No error checking for illegal arguments. -
set
Set a value for a code point.- Parameters:
c- the code pointvalue- the value
-
set
-
uncompact
private void uncompact() -
writeBlock
private void writeBlock(int block, int value) -
fillBlock
private void fillBlock(int block, int start, int limit, int value, int initialValue, boolean overwrite) initialValue is ignored if overwrite=true -
setRange
Set a value in a range of code points [start..end]. All code points c with startinvalid input: '<'=cinvalid input: '<'=end will get the value if overwrite is true or if the old value is the initial value.- Parameters:
start- the first code point to get the valueend- the last code point to get the value (inclusive)value- the valueoverwrite- flag for whether old non-initial values are to be overwritten
-
setRange
Set the values from a Trie2.Range. All code points within the range will get the value if overwrite is true or if the old value is the initial value. Ranges with the lead surrogate flag set will set the alternate lead-surrogate values in the Trie, rather than the code point values. This function is intended to work with the ranges produced when iterating the contents of a source Trie.- Parameters:
range- contains the range of code points and the value to be set.overwrite- flag for whether old non-initial values are to be overwritten
-
setForLeadSurrogateCodeUnit
Set a value for a UTF-16 code unit. Note that a Trie2 stores separate values for supplementary code points in the lead surrogate range (accessed via the plain set() and get() interfaces) and for lead surrogate code units. The lead surrogate code unit values are set via this function and read by the function getFromU16SingleLead(). For code units outside of the lead surrogate range, this function behaves identically to set().- Parameters:
codeUnit- A UTF-16 code unit.value- the value to be stored in the Trie2.
-
get
-
get
private int get(int c, boolean fromLSCP) -
getFromU16SingleLead
public int getFromU16SingleLead(char c) Get a trie value for a UTF-16 code unit. This function returns the same value as get() if the input character is outside of the lead surrogate range There are two values stored in a Trie for inputs in the lead surrogate range. This function returns the alternate value, while Trie2.get() returns the main value.- Specified by:
getFromU16SingleLeadin classTrie2- Parameters:
c- the code point or lead surrogate value.- Returns:
- the value
-
equal_int
private boolean equal_int(int[] a, int s, int t, int length) -
findSameIndex2Block
private int findSameIndex2Block(int index2Length, int otherBlock) -
findSameDataBlock
private int findSameDataBlock(int dataLength, int otherBlock, int blockLength) -
findHighStart
private int findHighStart(int highValue) -
compactData
private void compactData() -
compactIndex2
private void compactIndex2() -
compactTrie
private void compactTrie() -
toTrie2_16
Produce an optimized, read-only Trie2_16 from this writable Trie. The data values outside of the range that will fit in a 16 bit unsigned value will be truncated. -
toTrie2_32
Produce an optimized, read-only Trie2_32 from this writable Trie. -
freeze
-