Home | History | Annotate | Download | only in common

Lines Matching refs: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,
368 * These macros provide fast data lookup from a frozen trie.
369 * They will crash when used on an unfrozen trie.
373 * Return a 16-bit trie value from a code point, with range checking.
374 * Returns trie->errorValue if c is not in the range 0..U+10ffff.
376 * @param trie (const UTrie2 *, in) a frozen trie
378 * @return (uint16_t) The code point's trie value.
380 #define UTRIE2_GET16(trie, c) _UTRIE2_GET((trie), index, (trie)->indexLength, (c))
383 * Return a 32-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 (uint32_t) The code point's trie value.
390 #define UTRIE2_GET32(trie, c) _UTRIE2_GET((trie), data32, 0, (c))
394 * and get a 16-bit value from the trie.
396 * @param trie (const UTrie2 *, in) a frozen trie
400 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
402 #define UTRIE2_U16_NEXT16(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, index, src, limit, c, result)
406 * and get a 32-bit value from the trie.
408 * @param trie (const UTrie2 *, in) a frozen trie
412 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
414 #define UTRIE2_U16_NEXT32(trie, src, limit, c, result) _UTRIE2_U16_NEXT(trie, data32, src, limit, c, result)
418 * and get a 16-bit value from the trie.
420 * @param trie (const UTrie2 *, in) a frozen trie
424 trie lookup result
426 #define UTRIE2_U16_PREV16(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, index, start, src, c, result)
430 * and get a 32-bit value from the trie.
432 * @param trie (const UTrie2 *, in) a frozen trie
436 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
438 #define UTRIE2_U16_PREV32(trie, start, src, c, result) _UTRIE2_U16_PREV(trie, data32, start, src, c, result)
441 * UTF-8: Post-increment src and get a 16-bit value from the trie.
443 * @param trie (const UTrie2 *, in) a frozen trie
446 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
448 #define UTRIE2_U8_NEXT16(trie, src, limit, result)\
449 _UTRIE2_U8_NEXT(trie, data16, index, src, limit, result)
452 * UTF-8: Post-increment src and get a 32-bit value from the trie.
454 * @param trie (const UTrie2 *, in) a frozen trie
457 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
459 #define UTRIE2_U8_NEXT32(trie, src, limit, result) \
460 _UTRIE2_U8_NEXT(trie, data32, data32, src, limit, result)
463 * UTF-8: Pre-decrement src and get a 16-bit value from the trie.
465 * @param trie (const UTrie2 *, in) a frozen trie
468 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
470 #define UTRIE2_U8_PREV16(trie, start, src, result) \
471 _UTRIE2_U8_PREV(trie, data16, index, start, src, result)
474 * UTF-8: Pre-decrement src and get a 32-bit value from the trie.
476 * @param trie (const UTrie2 *, in) a frozen trie
479 * @param result (uint16_t, out) uint32_t variable for the trie lookup result
481 #define UTRIE2_U8_PREV32(trie, start, src, result) \
482 _UTRIE2_U8_PREV(trie, data32, data32, start, src, result)
515 * Get a value from a lead surrogate code unit as stored in the trie.
517 * @param trie the trie
522 utrie2_get32FromLeadSurrogateCodeUnit(const UTrie2 *trie, UChar32 c);
525 * Enumerate the trie values for the 1024=0x400 code points
532 * Do not modify the trie during the enumeration.
535 * For each entry in the trie, the value to be delivered is passed through
542 * @param trie a pointer to the trie
543 * @param enumValue a pointer to a function that may transform the trie entry value,
544 * or NULL if the values from the trie are to be used directly
550 utrie2_enumForLeadSurrogate(const UTrie2 *trie, UChar32 lead,
557 * @param trie the unfrozen trie
561 * - U_NO_WRITE_PERMISSION if the trie is frozen
564 utrie2_set32ForLeadSurrogateCodeUnit(UTrie2 *trie,
569 * Return a 16-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
573 * @param trie (const UTrie2 *, in) a frozen trie
575 * @return (uint16_t) The code unit's trie value.
577 #define UTRIE2_GET16_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), index, c)
580 * Return a 32-bit trie value from a UTF-16 single/lead code unit (<=U+ffff).
584 * @param trie (const UTrie2 *, in) a frozen trie
586 * @return (uint32_t) The code unit's trie value.
588 #define UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c) _UTRIE2_GET_FROM_U16_SINGLE_LEAD((trie), data32, c)
591 * Return a 16-bit trie value from a supplementary code point (U+10000..U+10ffff).
593 * @param trie (const UTrie2 *, in) a frozen trie
595 * @return (uint16_t) The code point's trie value.
597 #define UTRIE2_GET16_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), index, c)
600 * Return a 32-bit trie value from a supplementary code point (U+10000..U+10ffff).
602 * @param trie (const UTrie2 *, in) a frozen trie
604 * @return (uint32_t) The code point's trie value.
606 #define UTRIE2_GET32_FROM_SUPP(trie, c) _UTRIE2_GET_FROM_SUPP((trie), data32, c)
622 trie(t), codePointStart(p), codePointLimit(p), codePoint(U_SENTINEL) {}
624 const UTrie2 *trie;
672 /** Build-time trie structure. */
677 * Trie structure definition.
705 UBool isMemoryOwned; /* TRUE if the trie owns the memory */
712 * Trie constants, defining shift widths, index array lengths, etc.
828 utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
837 utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c,
841 /** Internal low-level trie getter. Returns a data index. */
847 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data index. */
850 /** Internal trie getter from a lead surrogate code point (D800..DBFF). Returns the data index. */
854 /** Internal trie getter from a BMP code point. Returns the data index. */
859 /** Internal trie getter from a supplementary code point below highStart. Returns the data index. */
869 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
872 #define _UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c) \
874 _UTRIE2_INDEX_RAW(0, (trie)->index, c) : \
878 (trie)->index, c) : \
881 (c)>=(trie)->highStart ? \
882 (trie)->highValueIndex : \
883 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c))
885 /** Internal trie getter from a UTF-16 single/lead code unit. Returns the data. */
886 #define _UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c) \
887 (trie)->data[_UTRIE2_INDEX_FROM_U16_SINGLE_LEAD((trie)->index, c)]
889 /** Internal trie getter from a supplementary code point. Returns the data. */
890 #define _UTRIE2_GET_FROM_SUPP(trie, data, c) \
891 (trie)->data[(c)>=(trie)->highStart ? (trie)->highValueIndex : \
892 _UTRIE2_INDEX_FROM_SUPP((trie)->index, c)]
895 * Internal trie getter from a code point, with checking that c is in 0..10FFFF.
898 #define _UTRIE2_GET(trie, data, asciiOffset, c) \
899 (trie)->data[_UTRIE2_INDEX_FROM_CP(trie, asciiOffset, c)]
902 #define _UTRIE2_U16_NEXT(trie, data, src, limit, c, result) { \
907 (result)=_UTRIE2_GET_FROM_U16_SINGLE_LEAD(trie, data, c); \
909 (result)=(trie)->data[_UTRIE2_INDEX_FROM_LSCP((trie)->index, c)]; \
913 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
919 #define _UTRIE2_U16_PREV(trie, data, start, src, c, result) { \
924 (result)=(trie)->data[_UTRIE2_INDEX_FROM_BMP((trie)->index, c)]; \
928 (result)=_UTRIE2_GET_FROM_SUPP((trie), data, (c)); \
934 #define _UTRIE2_U8_NEXT(trie, ascii, data, src, limit, result) { \
937 (result)=(trie)->ascii[__lead]; \
945 (result)=(trie)->data[ \
946 (trie)->index[(UTRIE2_UTF8_2B_INDEX_2_OFFSET-0xc0)+__lead]+ \
954 (result)=(trie)->data[ \
955 ((int32_t)((trie)->index[((__lead-0xe0)<<(12-UTRIE2_SHIFT_2))+ \
960 int32_t __index=utrie2_internalU8NextIndex((trie), __lead, (const uint8_t *)(src), \
963 (result)=(trie)->data[__index>>3]; \
969 #define _UTRIE2_U8_PREV(trie, ascii, data, start, src, result) { \
972 (result)=(trie)->ascii[__b]; \
974 int32_t __index=utrie2_internalU8PrevIndex((trie), __b, (const uint8_t *)(start), \
977 (result)=(trie)->data[__index>>3]; \