Home | History | Annotate | Download | only in common

Lines Matching full:trie

33  * This is a common implementation of a Unicode trie.
37 * This is the second common version of a Unicode trie (hence the name UTrie2).
57 * Trie structure.
79 * Open a frozen trie from its serialized from, stored in 32-bit-aligned memory.
81 * The memory must remain valid and unchanged as long as the trie is used.
82 * You must utrie2_close() the trie once you are done using it.
89 * @param pActualLength receives the actual number of bytes at data taken up by the trie data;
92 * @return the unserialized trie
103 * Open a frozen, empty "dummy" trie.
104 * A dummy trie is an empty trie, used when a real data trie cannot
109 * The trie always returns the initialValue,
112 * You must utrie2_close() the trie once you are done using it.
118 * @return the dummy trie
129 * Get a value from a code point as stored in the trie.
134 * @param trie the trie
139 utrie2_get32(const UTrie2 *trie, UChar32 c);
145 * trie value. This value will be passed on to the UTrie2EnumRange function.
148 * @param value a value from the trie
156 * of code points with the same value as retrieved from the trie and
171 * Enumerate efficiently all values in a trie.
172 * Do not modify the trie during the enumeration.
174 * For each entry in the trie, the value to be delivered is passed through
181 * @param trie a pointer to the trie
182 * @param enumValue a pointer to a function that may transform the trie entry value,
183 * or NULL if the values from the trie are to be used directly
189 utrie2_enum(const UTrie2 *trie,
192 /* Building a trie ---------------------------------------------------------- */
195 * Open an empty, writable trie. At build time, 32-bit data values are used.
198 * You must utrie2_close() the trie once you are done using it.
203 * @return a pointer to the allocated and initialized new trie
209 * Clone a trie.
212 * @param other the trie to clone
214 * @return a pointer to the new trie clone
220 * Clone a trie. The clone will be mutable/writable even if the other trie
224 * @param other the trie to clone
226 * @return a pointer to the new trie clone
232 * Close a trie and release associated memory.
234 * @param trie the trie
237 utrie2_close(UTrie2 *trie);
242 * @param trie the unfrozen trie
246 * - U_NO_WRITE_PERMISSION if the trie is frozen
249 utrie2_set32(UTrie2 *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode);
256 * @param trie the unfrozen trie
262 * - U_NO_WRITE_PERMISSION if the trie is frozen
265 utrie2_setRange32(UTrie2 *trie,
271 * Freeze a trie. Make it immutable (read-only) and compact it,
275 * A trie can be frozen only once. If this function is called again with different
278 * @param trie the trie
280 * the values stored in the trie will be truncated
284 * (the trie will be immutable and usable,
290 utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode);
293 * Test if the trie is frozen. (See utrie2_freeze().)
295 * @param trie the trie
296 * @return TRUE if the trie is frozen, that is, immutable, ready for serialization
300 utrie2_isFrozen(const UTrie2 *trie);
303 * Serialize a frozen trie into 32-bit aligned memory.
304 * If the trie is not frozen, then the function returns with a U_ILLEGAL_ARGUMENT_ERROR.
305 * A trie can be serialized multiple times.
307 * @param trie the frozen trie
308 * @param data a pointer to 32-bit-aligned memory to be filled with the trie data,
314 * - U_ILLEGAL_ARGUMENT_ERROR if the trie is not frozen or the data and capacity
316 * @return the number of bytes written or needed for the trie
321 utrie2_serialize(UTrie2 *trie,
377 * These macros provide fast data lookup from a frozen trie.
378 * They will crash when used on an unfrozen trie.
382 * Return a 16-bit trie value from a code point, with range checking.
383 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
385 * @param trie (const UTrie2 *, in) a frozen trie
387 * @return (uint16_t) The code point's trie value.
389 #define UTRIE2_GET16(trie, c) _UTRIE2_GET((trie), index, (trie)->indexLength, (c))
392 * Return a 32-bit trie value from a code point, with range checking.
393 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
395 * @param trie (const UTrie2 *, in) a frozen trie
397 * @return (uint32_t) The code point's trie value.
399 #define UTRIE2_GET32(trie, c) _UTRIE2_GET((trie), data32, 0, (c))
403 * and get a 16-bit value from the trie.
405 * @param trie (const UTrie2 *, in) a frozen trie
409 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
411 #define UTRIE2_U16_NEXT16(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, index, src, limit, c, result)
415 * and get a 32-bit value from the trie.
417 * @param trie (const UTrie2 *, in) a frozen trie
421 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
423 #define UTRIE2_U16_NEXT32(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, data32, src, limit, c, result)
427 * and get a 16-bit value from the trie.
429 * @param trietrie
433 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
435 #define UTRIE2_U16_PREV16(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, index, start, src, c, result)
439 * and get a 32-bit value from the trie.
441 * @param trie (const UTrie2 *, in) a frozen trie
445 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
447 #define UTRIE2_U16_PREV32(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, data32, start, src, c, result)
450 * UTF-8: Post-increment src and get a 16-bit value from the trie.
452 * @param trie (const UTrie2 *, in) a frozen trie
455 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
457 #define UTRIE2_U8_NEXT16(trie, src, limit, result)\
458 _UTRIE2_U8_NEXT(trie, data16, index, src, limit, result)
461 * UTF-8: Post-increment src and get a 32-bit value from the trie.
463 * @param trie (const UTrie2 *, in) a frozen trie
466 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
468 #define UTRIE2_U8_NEXT32(trie, src, limit, result) \
469 _UTRIE2_U8_NEXT(trie, data32, data32, src, limit, result)
472 * UTF-8: Pre-decrement src and get a 16-bit value from the trie.
474 * @param trie (const UTrie2 *, in) a frozen trie
477 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
479 #define UTRIE2_U8_PREV16(trie, start, src, result) \
480 _UTRIE2_U8_PREV(trie, data16, index, start, src, result)
483 * UTF-8: Pre-decrement src and get a 32-bit value from the trie.
485 * @param trie (const UTrie2 *, in) a frozen trie
488 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
490 #define UTRIE2_U8_PREV32(trie, start, src, result) \
491 _UTRIE2_U8_PREV(trie, data32, data32, start, src, result)
524 * Get a value from a lead surrogate code unit as stored in the trie.
526 * @param trie the trie
531 utrie2_get32FromLeadSurrogateCodeUnit(const UTrie2 *trie, UChar32 c);
534 * Enumerate the trie values for the 1024=0x400 code points
541 * Do not modify the trie during the enumeration.
544 * For each entry in the trie, the value to be delivered is passed through
551 * @param trie a pointer to the trie
552 * @param enumValue a pointer to a function that may transform the trie entry value,
553 * or NULL if the values from the trie are to be used directly
559 utrie2_enumForLeadSurrogate(const UTrie2 *trie, UChar32 lead,
566 * @param trie the unfrozen trie
570 * - U_NO_WRITE_PERMISSION if the trie is frozen
573 utrie2_set32ForLeadSurrogateCodeUnit(UTrie2 *trie,
578 * Return a 16-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
582 * @param trie (const UTrie2 *, in) a frozen trie
584 * @return (uint16_t) The code unit's trie value.
586 #define UTRIE2_GET16_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), index, c)
589 * Return a 32-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
593 * @param trie (const UTrie2 *, in) a frozen trie
595 * @return (uint32_t) The code unit's trie value.
597 #define UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), data32, c)
600 * Return a 16-bit trie value from a supplementary code point (U+10000..U+10ffff).
602 * @param trie (const UTrie2 *, in) a frozen trie
604 * @return (uint16_t) The code point's trie value.
606 #define UTRIE2_GET16_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), index, c)
609 * Return a 32-bit trie value from a supplementary code point (U+10000..U+10ffff).
611 * @param trie (const UTrie2 *, in) a frozen trie
613 * @return (uint32_t) The code point's trie value.
615 #define UTRIE2_GET32_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), data32, c)
631 trie(t), codePointStart(p), codePointLimit(p), codePoint(U_SENTINEL) {}
633 const UTrie2 *trie;
681 /** Build-time trie structure. */
686 * Trie structure definition.
714 UBool isMemoryOwned; /* TRUE if the trie owns the memory */
721 * Trie constants, defining shift widths, index array lengths, etc.
837 utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
846 utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c,
850 /** Internal low-level trie getter. Returns a data index. */
856 /** Internal trie
859 /** Internal trie getter from a lead surrogate code point (D800..DBFF). Returns the data index. */
863 /** Internal trie getter from a BMP code point. Returns the data index. */
868 /** Internal trie getter from a supplementary code point below highStart. Returns the data index. */
878 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
881 #define _UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c) \
883 _UTRIE2_INDEX_RAW(0, (trie)->index, c) : \
887 (trie)->index, c) : \
890 (c)>=(trie)->highStart ? \
891 (trie)->highValueIndex : \
892 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c))
894 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data. */
895 #define _UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c) \
896 (trie)->data[_UTRIE2_INDEX_FROM_U16_SINGLE_LEAD((trie)->index, c)]
898 /** Internal trie getter from a supplementary code point. Returns the data. */
899 #define _UTRIE2_GET_FROM_SUPP(trie, data, c) \
900 (trie)->data[(c)>=(trie)->highStart ? (trie)->highValueIndex : \
901 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c)]
904 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
907 #define _UTRIE2_GET(trie, data, asciiOffset, c) \
908 (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)]
911 #define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) { \
916 (result)=_UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c); \
918 (result)=(trie)->data[_UTRIE2_INDEX_FROM_LSCP((trie)->index, c)]; \
922 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
928 #define _UTRIE2_U16_PREV(trie, data, start, src, c, result) { \
933 (result)=(trie)->data[_UTRIE2_INDEX_FROM_BMP((trie)->index, c)]; \
937 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
943 #define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) { \
946 (result)=(trie)->ascii[__lead]; \
954 (result)=(trie)->data[ \
955 (trie)->index[(UTRIE2_UTF8_2B_INDEX_2_OFFSET-0xc0)+__lead]+ \
963 (result)=(trie)->data[ \
964 ((int32_t)((trie)->index[((__lead-0xe0)<<(12-UTRIE2_SHIFT_2))+ \
969 int32_t __index=utrie2_internalU8NextIndex((trie), __lead, (const uint8_t *)(src), \
972 (result)=(trie)->data[__index>>3]; \
978 #define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) { \
981 (result)=(trie)->ascii[__b]; \
983 int32_t __index=utrie2_internalU8PrevIndex((trie), __b, (const uint8_t *)(start), \
986 (result)=(trie)->data[__index>>3]; \