Lines Matching refs:trie

36  * This is a common implementation of a Unicode trie.
40 * This is the second common version of a Unicode trie (hence the name UTrie2).
84 * Open a frozen trie from its serialized from, stored in 32-bit-aligned memory.
86 * The memory must remain valid and unchanged as long as the trie is used.
87 * You must utrie2_close() the trie once you are done using it.
94 * @param pActualLength receives the actual number of bytes at data taken up by the trie data;
97 * @return the unserialized trie
108 * Open a frozen, empty "dummy" trie.
109 * A dummy trie is an empty trie, used when a real data trie cannot
114 * The trie always returns the initialValue,
117 * You must utrie2_close() the trie once you are done using it.
123 * @return the dummy trie
134 * Get a value from a code point as stored in the trie.
139 * @param trie the trie
144 utrie2_get32(const UTrie2 *trie, UChar32 c);
150 * trie value. This value will be passed on to the UTrie2EnumRange function.
153 * @param value a value from the trie
161 * of code points with the same value as retrieved from the trie and
176 * Enumerate efficiently all values in a trie.
177 * Do not modify the trie during the enumeration.
179 * For each entry in the trie, the value to be delivered is passed through
186 * @param trie a pointer to the trie
187 * @param enumValue a pointer to a function that may transform the trie entry value,
188 * or NULL if the values from the trie are to be used directly
194 utrie2_enum(const UTrie2 *trie,
197 /* Building a trie ---------------------------------------------------------- */
200 * Open an empty, writable trie. At build time, 32-bit data values are used.
203 * You must utrie2_close() the trie once you are done using it.
208 * @return a pointer to the allocated and initialized new trie
214 * Clone a trie.
217 * @param other the trie to clone
219 * @return a pointer to the new trie clone
225 * Clone a trie. The clone will be mutable/writable even if the other trie
229 * @param other the trie to clone
231 * @return a pointer to the new trie clone
237 * Close a trie and release associated memory.
239 * @param trie the trie
242 utrie2_close(UTrie2 *trie);
247 * @param trie the unfrozen trie
251 * - U_NO_WRITE_PERMISSION if the trie is frozen
254 utrie2_set32(UTrie2 *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode);
261 * @param trie the unfrozen trie
267 * - U_NO_WRITE_PERMISSION if the trie is frozen
270 utrie2_setRange32(UTrie2 *trie,
276 * Freeze a trie. Make it immutable (read-only) and compact it,
280 * A trie can be frozen only once. If this function is called again with different
283 * @param trie the trie
285 * the values stored in the trie will be truncated
289 * (the trie will be immutable and usable,
295 utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode);
298 * Test if the trie is frozen. (See utrie2_freeze().)
300 * @param trie the trie
301 * @return true if the trie is frozen, that is, immutable, ready for serialization
305 utrie2_isFrozen(const UTrie2 *trie);
308 * Serialize a frozen trie into 32-bit aligned memory.
309 * If the trie is not frozen, then the function returns with a U_ILLEGAL_ARGUMENT_ERROR.
310 * A trie can be serialized multiple times.
312 * @param trie the frozen trie
313 * @param data a pointer to 32-bit-aligned memory to be filled with the trie data,
319 * - U_ILLEGAL_ARGUMENT_ERROR if the trie is not frozen or the data and capacity
321 * @return the number of bytes written or needed for the trie
326 utrie2_serialize(const UTrie2 *trie,
348 * These macros provide fast data lookup from a frozen trie.
349 * They will crash when used on an unfrozen trie.
353 * Return a 16-bit trie value from a code point, with range checking.
354 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
356 * @param trie (const UTrie2 *, in) a frozen trie
358 * @return (uint16_t) The code point's trie value.
360 #define UTRIE2_GET16(trie, c) _UTRIE2_GET((trie), index, (trie)->indexLength, (c))
363 * Return a 32-bit trie value from a code point, with range checking.
364 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
366 * @param trie (const UTrie2 *, in) a frozen trie
368 * @return (uint32_t) The code point's trie value.
370 #define UTRIE2_GET32(trie, c) _UTRIE2_GET((trie), data32, 0, (c))
374 * and get a 16-bit value from the trie.
376 * @param trie (const UTrie2 *, in) a frozen trie
380 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
382 #define UTRIE2_U16_NEXT16(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, index, src, limit, c, result)
386 * and get a 32-bit value from the trie.
388 * @param trie (const UTrie2 *, in) a frozen trie
392 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
394 #define UTRIE2_U16_NEXT32(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, data32, src, limit, c, result)
398 * and get a 16-bit value from the trie.
400 * @param trie (const UTrie2 *, in) a frozen trie
404 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
406 #define UTRIE2_U16_PREV16(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, index, start, src, c, result)
410 * and get a 32-bit value from the trie.
412 * @param trie (const UTrie2 *, in) a frozen trie
416 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
418 #define UTRIE2_U16_PREV32(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, data32, start, src, c, result)
421 * UTF-8: Post-increment src and get a 16-bit value from the trie.
423 * @param trie (const UTrie2 *, in) a frozen trie
426 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
428 #define UTRIE2_U8_NEXT16(trie, src, limit, result)\
429 _UTRIE2_U8_NEXT(trie, data16, index, src, limit, result)
432 * UTF-8: Post-increment src and get a 32-bit value from the trie.
434 * @param trie (const UTrie2 *, in) a frozen trie
437 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
439 #define UTRIE2_U8_NEXT32(trie, src, limit, result) \
440 _UTRIE2_U8_NEXT(trie, data32, data32, src, limit, result)
443 * UTF-8: Pre-decrement src and get a 16-bit value from the trie.
445 * @param trie (const UTrie2 *, in) a frozen trie
448 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
450 #define UTRIE2_U8_PREV16(trie, start, src, result) \
451 _UTRIE2_U8_PREV(trie, data16, index, start, src, result)
454 * UTF-8: Pre-decrement src and get a 32-bit value from the trie.
456 * @param trie (const UTrie2 *, in) a frozen trie
459 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
461 #define UTRIE2_U8_PREV32(trie, start, src, result) \
462 _UTRIE2_U8_PREV(trie, data32, data32, start, src, result)
495 * Get a value from a lead surrogate code unit as stored in the trie.
497 * @param trie the trie
502 utrie2_get32FromLeadSurrogateCodeUnit(const UTrie2 *trie, UChar32 c);
505 * Enumerate the trie values for the 1024=0x400 code points
512 * Do not modify the trie during the enumeration.
515 * For each entry in the trie, the value to be delivered is passed through
522 * @param trie a pointer to the trie
523 * @param enumValue a pointer to a function that may transform the trie entry value,
524 * or NULL if the values from the trie are to be used directly
530 utrie2_enumForLeadSurrogate(const UTrie2 *trie, UChar32 lead,
537 * @param trie the unfrozen trie
541 * - U_NO_WRITE_PERMISSION if the trie is frozen
544 utrie2_set32ForLeadSurrogateCodeUnit(UTrie2 *trie,
549 * Return a 16-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
553 * @param trie (const UTrie2 *, in) a frozen trie
555 * @return (uint16_t) The code unit's trie value.
557 #define UTRIE2_GET16_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), index, c)
560 * Return a 32-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
564 * @param trie (const UTrie2 *, in) a frozen trie
566 * @return (uint32_t) The code unit's trie value.
568 #define UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), data32, c)
571 * Return a 16-bit trie value from a supplementary code point (U+10000..U+10ffff).
573 * @param trie (const UTrie2 *, in) a frozen trie
575 * @return (uint16_t) The code point's trie value.
577 #define UTRIE2_GET16_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), index, c)
580 * Return a 32-bit trie value from a supplementary code point (U+10000..U+10ffff).
582 * @param trie (const UTrie2 *, in) a frozen trie
584 * @return (uint32_t) The code point's trie value.
586 #define UTRIE2_GET32_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), data32, c)
603 trie(t), codePointStart(p), codePointLimit(p), codePoint(U_SENTINEL) {}
605 const UTrie2 *trie;
640 /** Build-time trie structure. */
673 UBool isMemoryOwned; /* true if the trie owns the memory */
800 utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
809 utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c,
813 /** Internal low-level trie getter. Returns a data index. */
819 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data index. */
822 /** Internal trie getter from a lead surrogate code point (D800..DBFF). Returns the data index. */
826 /** Internal trie getter from a BMP code point. Returns the data index. */
831 /** Internal trie getter from a supplementary code point below highStart. Returns the data index. */
841 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
844 #define _UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c) \
846 _UTRIE2_INDEX_RAW(0, (trie)->index, c) : \
850 (trie)->index, c) : \
853 (c)>=(trie)->highStart ? \
854 (trie)->highValueIndex : \
855 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c))
857 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data. */
858 #define _UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c) \
859 (trie)->data[_UTRIE2_INDEX_FROM_U16_SINGLE_LEAD((trie)->index, c)]
861 /** Internal trie getter from a supplementary code point. Returns the data. */
862 #define _UTRIE2_GET_FROM_SUPP(trie, data, c) \
863 (trie)->data[(c)>=(trie)->highStart ? (trie)->highValueIndex : \
864 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c)]
867 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
870 #define _UTRIE2_GET(trie, data, asciiOffset, c) \
871 (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)]
874 #define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) UPRV_BLOCK_MACRO_BEGIN { \
879 (result)=_UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c); \
881 (result)=(trie)->data[_UTRIE2_INDEX_FROM_LSCP((trie)->index, c)]; \
885 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
891 #define _UTRIE2_U16_PREV(trie, data, start, src, c, result) UPRV_BLOCK_MACRO_BEGIN { \
896 (result)=(trie)->data[_UTRIE2_INDEX_FROM_BMP((trie)->index, c)]; \
900 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
906 #define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) UPRV_BLOCK_MACRO_BEGIN { \
909 (result)=(trie)->ascii[__lead]; \
918 (result)=(trie)->data[ \
919 ((int32_t)((trie)->index[((__lead-0xe0)<<(12-UTRIE2_SHIFT_2))+ \
928 (result)=(trie)->data[ \
929 (trie)->index[(UTRIE2_UTF8_2B_INDEX_2_OFFSET-0xc0)+__lead]+ \
932 int32_t __index=utrie2_internalU8NextIndex((trie), __lead, (const uint8_t *)(src), \
935 (result)=(trie)->data[__index>>3]; \
941 #define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) UPRV_BLOCK_MACRO_BEGIN { \
944 (result)=(trie)->ascii[__b]; \
946 int32_t __index=utrie2_internalU8PrevIndex((trie), __b, (const uint8_t *)(start), \
949 (result)=(trie)->data[__index>>3]; \