Home | History | Annotate | Download | only in common

Lines Matching full:trie

28  * This is a common implementation of a "folded" trie.
49 * Trie constants, defining shift widths, index array lengths, etc.
114 * Number of bytes for a dummy trie.
115 * A dummy trie is an empty runtime trie, used when a real data trie cannot
135 * @param data data value for a surrogate from the trie, including the folding offset
142 * Run-time Trie structure.
175 /** Internal trie getter from an offset (0 if c16 is a BMP/lead units) and a 16-bit unit */
176 #define _UTRIE_GET_RAW(trie, data, offset, c16) \
177 (trie)->data[ \
178 ((int32_t)((trie)->index[(offset)+((c16)>>UTRIE_SHIFT)])<<UTRIE_INDEX_SHIFT)+ \
182 /** Internal trie getter from a pair of surrogates */
183 #define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) { \
187 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
188 __offset=(trie)->getFoldingOffset(result); \
192 (result)=_UTRIE_GET_RAW((trie), data, __offset, (c2)&0x3ff); \
194 (result)=(resultType)((trie)->initialValue); \
198 /** Internal trie getter from a BMP code point, treating a lead surrogate as a normal code point */
199 #define _UTRIE_GET_FROM_BMP(trie, data, c16) \
200 _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16);
203 * Internal trie getter from a code point.
205 * if((c32)<=0xd7ff) { (result)=_UTRIE_GET_RAW(trie, data, 0, c32); }
207 #define _UTRIE_GET(trie, data, c32, result, resultType) \
210 (result)=_UTRIE_GET_FROM_BMP(trie, data, c32); \
214 _UTRIE_GET_FROM_PAIR(trie, data, __lead16, c32, result, resultType); \
217 (result)=(resultType)((trie)->initialValue); \
221 #define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) { \
225 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
228 _UTRIE_GET_FROM_PAIR((trie), data, (c), (c2), (result), resultType); \
232 (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \
237 #define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) { \
241 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
247 _UTRIE_GET_FROM_PAIR((trie), data, (c), (c2), (result), resultType); \
251 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
256 (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \
266 * (trie->isLatin1Linear).
268 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
271 #define UTRIE_GET16_LATIN1(trie) ((trie)->index+(trie)->indexLength+UTRIE_DATA_BLOCK_LENGTH)
277 * (trie->isLatin1Linear).
279 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
282 #define UTRIE_GET32_LATIN1(trie) ((trie)->data32+UTRIE_DATA_BLOCK_LENGTH)
285 * Get a 16-bit trie value from a BMP code point (UChar, <=U+ffff).
288 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
290 * @return (uint16_t) trie lookup result
292 #define UTRIE_GET16_FROM_LEAD(trie, c16) _UTRIE_GET_RAW(trie, index, 0, c16)
295 * Get a 32-bit trie value from a BMP code point (UChar, <=U+ffff).
298 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
300 * @return (uint32_t) trie lookup result
302 #define UTRIE_GET32_FROM_LEAD(trie, c16) _UTRIE_GET_RAW(trie, data32, 0, c16)
305 * Get a 16-bit trie value from a BMP code point (UChar, <=U+ffff).
309 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
311 * @return (uint16_t) trie lookup result
313 #define UTRIE_GET16_FROM_BMP(trie, c16) _UTRIE_GET_FROM_BMP(trie, index, c16)
316 * Get a 32-bit trie value from a BMP code point (UChar, <=U+ffff).
320 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
322 * @return (uint32_t) trie lookup result
324 #define UTRIE_GET32_FROM_BMP(trie, c16) _UTRIE_GET_FROM_BMP(trie, data32, c16)
327 * Get a 16-bit trie value from a code point.
331 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
333 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
335 #define UTRIE_GET16(trie, c32, result) _UTRIE_GET(trie, index, c32, result, uint16_t)
338 * Get a 32-bit trie value from a code point.
342 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
344 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
346 #define UTRIE_GET32(trie, c32, result) _UTRIE_GET(trie, data32, c32, result, uint32_t)
350 * and get a 16-bit value from the trie.
352 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
357 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
359 #define UTRIE_NEXT16(trie, src, limit, c, c2, result) _UTRIE_NEXT(trie, index, src, limit, c, c2, result, uint16_t)
363 * and get a 32-bit value from the trie.
365 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
370 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
372 #define UTRIE_NEXT32(trie, src, limit, c, c2, result) _UTRIE_NEXT(trie, data32, src, limit, c, c2, result, uint32_t)
376 * and get a 16-bit value from the trie.
378 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
383 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
385 #define UTRIE_PREVIOUS16(trie, start, src, c, c2, result) _UTRIE_PREVIOUS(trie, index, start, src, c, c2, result, uint16_t)
389 * and get a 32-bit value from the trie.
391 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
396 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
398 #define UTRIE_PREVIOUS32(trie, start, src, c, c2, result) _UTRIE_PREVIOUS(trie, data32, start, src, c, c2, result, uint32_t)
401 * Get a 16-bit trie value from a pair of surrogates.
403 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
406 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
408 #define UTRIE_GET16_FROM_PAIR(trie, c, c2, result) _UTRIE_GET_FROM_PAIR(trie, index, c, c2, result, uint16_t)
411 * Get a 32-bit trie value from a pair of surrogates.
413 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
416 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
418 #define UTRIE_GET32_FROM_PAIR(trie, c, c2, result) _UTRIE_GET_FROM_PAIR(trie, data32, c, c2, result, uint32_t)
421 * Get a 16-bit trie value from a folding offset (from the value of a lead surrogate)
424 * @param trietrie structure
427 * @return (uint16_t) trie lookup result
429 #define UTRIE_GET16_FROM_OFFSET_TRAIL(trie, offset, c2) _UTRIE_GET_RAW(trie, index, offset, (c2)&0x3ff)
432 * Get a 32-bit trie value from a folding offset (from the value of a lead surrogate)
435 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
438 * @return (uint32_t) trie lookup result
440 #define UTRIE_GET32_FROM_OFFSET_TRAIL(trie, offset, c2) _UTRIE_GET_RAW(trie, data32, offset, (c2)&0x3ff)
446 * trie value. This value will be passed on to the UTrieEnumRange function.
449 * @param value a value from the trie
457 * of code points with the same value as retrieved from the trie and
472 * Enumerate efficiently all values in a trie.
473 * For each entry in the trie, the value to be delivered is passed through
480 * @param trie a pointer to the runtime trie structure
481 * @param enumValue a pointer to a function that may transform the trie entry value,
482 * or NULL if the values from the trie are to be used directly
488 utrie_enum(const UTrie *trie,
492 * Unserialize a trie from 32-bit-aligned memory.
494 * Fills the UTrie runtime trie structure with the settings for the trie data.
496 * @param trie a pointer to the runtime trie structure
497 * @param data a pointer to 32-bit-aligned memory containing trie data
500 * @return the number of bytes at data taken up by the trie data
503 utrie_unserialize(UTrie *trie, const void *data, int32_t length, UErrorCode *pErrorCode);
506 * "Unserialize" a dummy trie.
507 * A dummy trie is an empty runtime trie, used when a real data trie cannot
510 * The input memory is filled so that the trie always returns the initialValue,
514 * @param trie a pointer to the runtime trie structure
515 * @param data a pointer to 32-bit-aligned memory to be filled with the dummy trie data
526 utrie_unserializeDummy(UTrie *trie,
544 /* Building a trie ----------------------------------------------------------*/
547 * Build-time trie structure.
574 * Build-time trie callback function, used with utrie_serialize().
592 UNewTrieGetFoldedValue(UNewTrie *trie, UChar32 start, int32_t offset);
595 * Open a build-time trie structure.
599 * Although the trie is never fully expanded to a linear array, especially when
627 * Clone a build-time trie structure with all entries.
630 * @param other the build-time trie structure to clone
640 * Close a build-time trie structure, and release memory
643 * @param trie the build-time trie
646 utrie_close(UNewTrie *trie);
649 * Get the data array of a build-time trie.
653 * @param trie the build-time trie
659 utrie_getData(UNewTrie *trie, int32_t *pLength);
664 * @param trie the build-time trie
670 utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
673 * Get a value from a code point as stored in the build-time trie.
675 * @param trie the build-time trie
683 utrie_get32(UNewTrie *trie, UChar32 c, UBool *pInBlockZero);
690 * @param trie the build-time trie
698 utrie_setRange32(UNewTrie *trie, UChar32 start, UChar32 limit, uint32_t value, UBool overwrite);
701 * Compact the build-time trie after all values are set, and then
704 * After this, the trie can only be serizalized again and/or closed;
709 * @param trie the build-time trie
710 * @param data a pointer to 32-bit-aligned memory for the trie data
721 * - U_MEMORY_ALLOCATION_ERROR if the trie data array is too small
724 * @return the number of bytes written for the trie
727 utrie_serialize(UNewTrie *trie, void *data, int32_t capacity,
744 * Trie data structure in serialized form:
752 /** "Trie" in big-endian US-ASCII (0x54726965) */