Home | History | Annotate | Download | only in common

Lines Matching refs:trie

31  * This is a common implementation of a "folded" trie.
52 * Trie constants, defining shift widths, index array lengths, etc.
117 * Number of bytes for a dummy trie.
118 * A dummy trie is an empty runtime trie, used when a real data trie cannot
138 * @param data data value for a surrogate from the trie, including the folding offset
145 * Run-time Trie structure.
178 /** Internal trie getter from an offset (0 if c16 is a BMP/lead units) and a 16-bit unit */
179 #define _UTRIE_GET_RAW(trie, data, offset, c16) \
180 (trie)->data[ \
181 ((int32_t)((trie)->index[(offset)+((c16)>>UTRIE_SHIFT)])<<UTRIE_INDEX_SHIFT)+ \
185 /** Internal trie getter from a pair of surrogates */
186 #define _UTRIE_GET_FROM_PAIR(trie, data, c, c2, result, resultType) { \
190 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
191 __offset=(trie)->getFoldingOffset(result); \
195 (result)=_UTRIE_GET_RAW((trie), data, __offset, (c2)&0x3ff); \
197 (result)=(resultType)((trie)->initialValue); \
201 /** Internal trie getter from a BMP code point, treating a lead surrogate as a normal code point */
202 #define _UTRIE_GET_FROM_BMP(trie, data, c16) \
203 _UTRIE_GET_RAW(trie, data, 0xd800<=(c16) && (c16)<=0xdbff ? UTRIE_LEAD_INDEX_DISP : 0, c16);
206 * Internal trie getter from a code point.
208 * if((c32)<=0xd7ff) { (result)=_UTRIE_GET_RAW(trie, data, 0, c32); }
210 #define _UTRIE_GET(trie, data, c32, result, resultType) \
213 (result)=_UTRIE_GET_FROM_BMP(trie, data, c32); \
217 _UTRIE_GET_FROM_PAIR(trie, data, __lead16, c32, result, resultType); \
220 (result)=(resultType)((trie)->initialValue); \
224 #define _UTRIE_NEXT(trie, data, src, limit, c, c2, result, resultType) { \
228 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
231 _UTRIE_GET_FROM_PAIR((trie), data, (c), (c2), (result), resultType); \
235 (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \
240 #define _UTRIE_PREVIOUS(trie, data, start, src, c, c2, result, resultType) { \
244 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
250 _UTRIE_GET_FROM_PAIR((trie), data, (c), (c2), (result), resultType); \
254 (result)=_UTRIE_GET_RAW((trie), data, 0, (c)); \
259 (result)=_UTRIE_GET_RAW((trie), data, UTRIE_LEAD_INDEX_DISP, (c)); \
269 * (trie->isLatin1Linear).
271 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
274 #define UTRIE_GET16_LATIN1(trie) ((trie)->index+(trie)->indexLength+UTRIE_DATA_BLOCK_LENGTH)
280 * (trie->isLatin1Linear).
282 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
285 #define UTRIE_GET32_LATIN1(trie) ((trie)->data32+UTRIE_DATA_BLOCK_LENGTH)
288 * Get a 16-bit trie value from a BMP code point (UChar, <=U+ffff).
291 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
293 * @return (uint16_t) trie lookup result
295 #define UTRIE_GET16_FROM_LEAD(trie, c16) _UTRIE_GET_RAW(trie, index, 0, c16)
298 * Get a 32-bit trie value from a BMP code point (UChar, <=U+ffff).
301 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
303 * @return (uint32_t) trie lookup result
305 #define UTRIE_GET32_FROM_LEAD(trie, c16) _UTRIE_GET_RAW(trie, data32, 0, c16)
308 * Get a 16-bit trie value from a BMP code point (UChar, <=U+ffff).
312 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
314 * @return (uint16_t) trie lookup result
316 #define UTRIE_GET16_FROM_BMP(trie, c16) _UTRIE_GET_FROM_BMP(trie, index, c16)
319 * Get a 32-bit trie value from a BMP code point (UChar, <=U+ffff).
323 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
325 * @return (uint32_t) trie lookup result
327 #define UTRIE_GET32_FROM_BMP(trie, c16) _UTRIE_GET_FROM_BMP(trie, data32, c16)
330 * Get a 16-bit trie value from a code point.
334 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
336 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
338 #define UTRIE_GET16(trie, c32, result) _UTRIE_GET(trie, index, c32, result, uint16_t)
341 * Get a 32-bit trie value from a code point.
345 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
347 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
349 #define UTRIE_GET32(trie, c32, result) _UTRIE_GET(trie, data32, c32, result, uint32_t)
353 * and get a 16-bit value from the trie.
355 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
360 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
362 #define UTRIE_NEXT16(trie, src, limit, c, c2, result) _UTRIE_NEXT(trie, index, src, limit, c, c2, result, uint16_t)
366 * and get a 32-bit value from the trie.
368 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
373 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
375 #define UTRIE_NEXT32(trie, src, limit, c, c2, result) _UTRIE_NEXT(trie, data32, src, limit, c, c2, result, uint32_t)
379 * and get a 16-bit value from the trie.
381 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
386 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
388 #define UTRIE_PREVIOUS16(trie, start, src, c, c2, result) _UTRIE_PREVIOUS(trie, index, start, src, c, c2, result, uint16_t)
392 * and get a 32-bit value from the trie.
394 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
399 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
401 #define UTRIE_PREVIOUS32(trie, start, src, c, c2, result) _UTRIE_PREVIOUS(trie, data32, start, src, c, c2, result, uint32_t)
404 * Get a 16-bit trie value from a pair of surrogates.
406 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
409 * @param result (uint16_t, out) uint16_t variable for the trie lookup result
411 #define UTRIE_GET16_FROM_PAIR(trie, c, c2, result) _UTRIE_GET_FROM_PAIR(trie, index, c, c2, result, uint16_t)
414 * Get a 32-bit trie value from a pair of surrogates.
416 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
419 * @param result (uint32_t, out) uint32_t variable for the trie lookup result
421 #define UTRIE_GET32_FROM_PAIR(trie, c, c2, result) _UTRIE_GET_FROM_PAIR(trie
424 * Get a 16-bit trie value from a folding offset (from the value of a lead surrogate)
427 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
430 * @return (uint16_t) trie lookup result
432 #define UTRIE_GET16_FROM_OFFSET_TRAIL(trie, offset, c2) _UTRIE_GET_RAW(trie, index, offset, (c2)&0x3ff)
435 * Get a 32-bit trie value from a folding offset (from the value of a lead surrogate)
438 * @param trie (const UTrie *, in) a pointer to the runtime trie structure
441 * @return (uint32_t) trie lookup result
443 #define UTRIE_GET32_FROM_OFFSET_TRAIL(trie, offset, c2) _UTRIE_GET_RAW(trie, data32, offset, (c2)&0x3ff)
449 * trie value. This value will be passed on to the UTrieEnumRange function.
452 * @param value a value from the trie
460 * of code points with the same value as retrieved from the trie and
475 * Enumerate efficiently all values in a trie.
476 * For each entry in the trie, the value to be delivered is passed through
483 * @param trie a pointer to the runtime trie structure
484 * @param enumValue a pointer to a function that may transform the trie entry value,
485 * or NULL if the values from the trie are to be used directly
491 utrie_enum(const UTrie *trie,
495 * Unserialize a trie from 32-bit-aligned memory.
497 * Fills the UTrie runtime trie structure with the settings for the trie data.
499 * @param trie a pointer to the runtime trie structure
500 * @param data a pointer to 32-bit-aligned memory containing trie data
503 * @return the number of bytes at data taken up by the trie data
506 utrie_unserialize(UTrie *trie, const void *data, int32_t length, UErrorCode *pErrorCode);
509 * "Unserialize" a dummy trie.
510 * A dummy trie is an empty runtime trie, used when a real data trie cannot
513 * The input memory is filled so that the trie always returns the initialValue,
517 * @param trie a pointer to the runtime trie structure
518 * @param data a pointer to 32-bit-aligned memory to be filled with the dummy trie data
529 utrie_unserializeDummy(UTrie *trie,
547 /* Building a trie ----------------------------------------------------------*/
550 * Build-time trie structure.
577 * Build-time trie callback function, used with utrie_serialize().
595 UNewTrieGetFoldedValue(UNewTrie *trie, UChar32 start, int32_t offset);
598 * Open a build-time trie structure.
602 * Although the trie is never fully expanded to a linear array, especially when
630 * Clone a build-time trie structure with all entries.
633 * @param other the build-time trie structure to clone
643 * Close a build-time trie structure, and release memory
646 * @param trie the build-time trie
649 utrie_close(UNewTrie *trie);
652 * Get the data array of a build-time trie.
656 * @param trie the build-time trie
662 utrie_getData(UNewTrie *trie, int32_t *pLength);
667 * @param trie the build-time trie
673 utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
676 * Get a value from a code point as stored in the build-time trie.
678 * @param trie the build-time trie
686 utrie_get32(UNewTrie *trie, UChar32 c, UBool *pInBlockZero);
693 * @param trie the build-time trie
701 utrie_setRange32(UNewTrie *trie, UChar32 start, UChar32 limit, uint32_t value, UBool overwrite);
704 * Compact the build-time trie after all values are set, and then
707 * After this, the trie can only be serizalized again and/or closed;
712 * @param trie the build-time trie
713 * @param data a pointer to 32-bit-aligned memory for the trie data
724 * - U_MEMORY_ALLOCATION_ERROR if the trie data array is too small
727 * @return the number of bytes written for the trie
730 utrie_serialize(UNewTrie *trie, void *data, int32_t capacity,
747 * Trie data structure in serialized form:
755 /** "Trie" in big-endian US-ASCII (0x54726965) */