Home | History | Annotate | Download | only in common

Lines Matching refs:trie

34  * This is a common implementation of a Unicode trie.
38 * This is the second common version of a Unicode trie (hence the name UTrie2).
58 * Trie structure.
80 * Open a frozen trie from its serialized from, stored in 32-bit-aligned memory.
82 * The memory must remain valid and unchanged as long as the trie is used.
83 * You must utrie2_close() the trie once you are done using it.
90 * @param pActualLength receives the actual number of bytes at data taken up by the trie data;
93 * @return the unserialized trie
104 * Open a frozen, empty "dummy" trie.
105 * A dummy trie is an empty trie, used when a real data trie cannot
110 * The trie always returns the initialValue,
113 * You must utrie2_close() the trie once you are done using it.
119 * @return the dummy trie
130 * Get a value from a code point as stored in the trie.
135 * @param trie the trie
140 utrie2_get32(const UTrie2 *trie, UChar32 c);
146 * trie value. This value will be passed on to the UTrie2EnumRange function.
149 * @param value a value from the trie
157 * of code points with the same value as retrieved from the trie and
172 * Enumerate efficiently all values in a trie.
173 * Do not modify the trie during the enumeration.
175 * For each entry in the trie, the value to be delivered is passed through
182 * @param trie a pointer to the trie
183 * @param enumValue a pointer to a function that may transform the trie entry value,
184 * or NULL if the values from the trie are to be used directly
190 utrie2_enum(const UTrie2 *trie,
193 /* Building a trie ---------------------------------------------------------- */
196 * Open an empty, writable trie. At build time, 32-bit data values are used.
199 * You must utrie2_close() the trie once you are done using it.
204 * @return a pointer to the allocated and initialized new trie
210 * Clone a trie.
213 * @param other the trie to clone
215 * @return a pointer to the new trie clone
221 * Clone a trie. The clone will be mutable/writable even if the other trie
225 * @param other the trie to clone
227 * @return a pointer to the new trie clone
233 * Close a trie and release associated memory.
235 * @param trie the trie
238 utrie2_close(UTrie2 *trie);
243 * @param trie the unfrozen trie
247 * - U_NO_WRITE_PERMISSION if the trie is frozen
250 utrie2_set32(UTrie2 *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode);
257 * @param trie the unfrozen trie
263 * - U_NO_WRITE_PERMISSION if the trie is frozen
266 utrie2_setRange32(UTrie2 *trie,
272 * Freeze a trie. Make it immutable (read-only) and compact it,
276 * A trie can be frozen only once. If this function is called again with different
279 * @param trie the trie
281 * the values stored in the trie will be truncated
285 * (the trie will be immutable and usable,
291 utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode);
294 * Test if the trie is frozen. (See utrie2_freeze().)
296 * @param trie the trie
297 * @return TRUE if the trie is frozen, that is, immutable, ready for serialization
301 utrie2_isFrozen(const UTrie2 *trie);
304 * Serialize a frozen trie into 32-bit aligned memory.
305 * If the trie is not frozen, then the function returns with a U_ILLEGAL_ARGUMENT_ERROR.
306 * A trie can be serialized multiple times.
308 * @param trie the frozen trie
309 * @param data a pointer to 32-bit-aligned memory to be filled with the trie data,
315 * - U_ILLEGAL_ARGUMENT_ERROR if the trie is not frozen or the data and capacity
317 * @return the number of bytes written or needed for the trie
322 utrie2_serialize(UTrie2 *trie,
378 * These macros provide fast data lookup from a frozen trie.
379 * They will crash when used on an unfrozen trie.
383 * Return a 16-bit trie value from a code point, with range checking.
384 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
386 * @param trie (const UTrie2 *, in) a frozen trie
388 * @return (uint16_t) The code point's trie value.
390 #define UTRIE2_GET16(trie, c) _UTRIE2_GET((trie), index, (trie)->indexLength, (c))
393 * Return a 32-bit trie value from a code point, with range checking.
394 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
396 * @param trie (const UTrie2 *, in) a frozen trie
398 * @return (uint32_t) The code point's trie value.
400 #define UTRIE2_GET32(trie, c) _UTRIE2_GET((trie), data32, 0, (c))
404 * and get a 16-bit value from the trie.
406 * @param trie (const UTrie2 *, in) a frozen trie
410 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
412 #define UTRIE2_U16_NEXT16(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, index, src, limit, c, result)
416 * and get a 32-bit value from the trie.
418 * @param trie (const UTrie2 *, in) a frozen trie
422 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
424 #define UTRIE2_U16_NEXT32(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, data32, src, limit, c, result)
428 * and get a 16-bit value from the trie.
430 * @param trietrie
434 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
436 #define UTRIE2_U16_PREV16(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, index, start, src, c, result)
440 * and get a 32-bit value from the trie.
442 * @param trie (const UTrie2 *, in) a frozen trie
446 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
448 #define UTRIE2_U16_PREV32(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, data32, start, src, c, result)
451 * UTF-8: Post-increment src and get a 16-bit value from the trie.
453 * @param trie (const UTrie2 *, in) a frozen trie
456 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
458 #define UTRIE2_U8_NEXT16(trie, src, limit, result)\
459 _UTRIE2_U8_NEXT(trie, data16, index, src, limit, result)
462 * UTF-8: Post-increment src and get a 32-bit value from the trie.
464 * @param trie (const UTrie2 *, in) a frozen trie
467 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
469 #define UTRIE2_U8_NEXT32(trie, src, limit, result) \
470 _UTRIE2_U8_NEXT(trie, data32, data32, src, limit, result)
473 * UTF-8: Pre-decrement src and get a 16-bit value from the trie.
475 * @param trie (const UTrie2 *, in) a frozen trie
478 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
480 #define UTRIE2_U8_PREV16(trie, start, src, result) \
481 _UTRIE2_U8_PREV(trie, data16, index, start, src, result)
484 * UTF-8: Pre-decrement src and get a 32-bit value from the trie.
486 * @param trie (const UTrie2 *, in) a frozen trie
489 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
491 #define UTRIE2_U8_PREV32(trie, start, src, result) \
492 _UTRIE2_U8_PREV(trie, data32, data32, start, src, result)
525 * Get a value from a lead surrogate code unit as stored in the trie.
527 * @param trie the trie
532 utrie2_get32FromLeadSurrogateCodeUnit(const UTrie2 *trie, UChar32 c);
535 * Enumerate the trie values for the 1024=0x400 code points
542 * Do not modify the trie during the enumeration.
545 * For each entry in the trie, the value to be delivered is passed through
552 * @param trie a pointer to the trie
553 * @param enumValue a pointer to a function that may transform the trie entry value,
554 * or NULL if the values from the trie are to be used directly
560 utrie2_enumForLeadSurrogate(const UTrie2 *trie, UChar32 lead,
567 * @param trie the unfrozen trie
571 * - U_NO_WRITE_PERMISSION if the trie is frozen
574 utrie2_set32ForLeadSurrogateCodeUnit(UTrie2 *trie,
579 * Return a 16-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
583 * @param trie (const UTrie2 *, in) a frozen trie
585 * @return (uint16_t) The code unit's trie value.
587 #define UTRIE2_GET16_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), index, c)
590 * Return a 32-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
594 * @param trie (const UTrie2 *, in) a frozen trie
596 * @return (uint32_t) The code unit's trie value.
598 #define UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), data32, c)
601 * Return a 16-bit trie value from a supplementary code point (U+10000..U+10ffff).
603 * @param trie (const UTrie2 *, in) a frozen trie
605 * @return (uint16_t) The code point's trie value.
607 #define UTRIE2_GET16_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), index, c)
610 * Return a 32-bit trie value from a supplementary code point (U+10000..U+10ffff).
612 * @param trie (const UTrie2 *, in) a frozen trie
614 * @return (uint32_t) The code point's trie value.
616 #define UTRIE2_GET32_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), data32, c)
633 trie(t), codePointStart(p), codePointLimit(p), codePoint(U_SENTINEL) {}
635 const UTrie2 *trie;
683 /** Build-time trie structure. */
688 * Trie structure definition.
716 UBool isMemoryOwned; /* TRUE if the trie owns the memory */
723 * Trie constants, defining shift widths, index array lengths, etc.
839 utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
848 utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c,
852 /** Internal low-level trie getter. Returns a data index. */
858 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data index. */
861 /** Internal trie getter from a lead surrogate code point (D800..DBFF). Returns the data index. */
865 /** Internal trie getter from a BMP code point. Returns the data index. */
870 /** Internal trie getter from a supplementary code point below highStart. Returns the data index. */
880 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
883 #define _UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c) \
885 _UTRIE2_INDEX_RAW(0, (trie)->index, c) : \
889 (trie)->index, c) : \
892 (c)>=(trie)->highStart ? \
893 (trie)->highValueIndex : \
894 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c))
896 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data. */
897 #define _UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c) \
898 (trie)->data[_UTRIE2_INDEX_FROM_U16_SINGLE_LEAD((trie)->index, c)]
900 /** Internal trie getter from a supplementary code point. Returns the data. */
901 #define _UTRIE2_GET_FROM_SUPP(trie, data, c) \
902 (trie)->data[(c)>=(trie)->highStart ? (trie)->highValueIndex : \
903 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c)]
906 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
909 #define _UTRIE2_GET(trie, data, asciiOffset, c) \
910 (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)]
913 #define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) { \
918 (result)=_UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c); \
920 (result)=(trie)->data[_UTRIE2_INDEX_FROM_LSCP((trie)->index, c)]; \
924 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
930 #define _UTRIE2_U16_PREV(trie, data, start, src, c, result) { \
935 (result)=(trie)->data[_UTRIE2_INDEX_FROM_BMP((trie)->index, c)]; \
939 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
945 #define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) { \
948 (result)=(trie)->ascii[__lead]; \
956 (result)=(trie)->data[ \
957 (trie)->index[(UTRIE2_UTF8_2B_INDEX_2_OFFSET-0xc0)+__lead]+ \
965 (result)=(trie)->data[ \
966 ((int32_t)((trie)->index[((__lead-0xe0)<<(12-UTRIE2_SHIFT_2))+ \
971 int32_t __index=utrie2_internalU8NextIndex((trie), __lead, (const uint8_t *)(src), \
974 (result)=(trie)->data[__index>>3]; \
980 #define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) { \
983 (result)=(trie)->ascii[__b]; \
985 int32_t __index=utrie2_internalU8PrevIndex((trie), __b, (const uint8_t *)(start), \
988 (result)=(trie)->data[__index>>3]; \