1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * libdatrie - Double-Array Trie Library
4 * Copyright (C) 2006 Theppitak Karoonboonyanan <theppitak@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * alpha-map.h - map between character codes and trie alphabet
24 * Author: Theppitak Karoonboonyanan <theppitak@gmail.com>
41 * @brief AlphaMap data type and functions
43 * AlphaMap is a mapping between AlphaChar and TrieChar. AlphaChar is the
44 * alphabet character used in words of a target language, while TrieChar
45 * is a small integer with packed range of values and is actually used in
46 * trie state transition calculations.
48 * Since double-array trie relies on sparse state transition table,
49 * a small set of input characters can make the table small, i.e. with
50 * small number of columns. But in real life, alphabet characters can be
51 * of non-continuous range of values. The unused slots between them can
52 * waste the space in the table, and can increase the chance of unused
55 * AlphaMap is thus defined for mapping between non-continuous ranges of
56 * values of AlphaChar and packed and continuous range of Triechar.
58 * In this implementation, TrieChar is defined as a single-byte integer,
59 * which means the largest AlphaChar set that is supported is of 255
60 * values, as the special value of 0 is reserved for null-termination code.
64 * @brief AlphaMap data type
66 typedef struct _AlphaMap AlphaMap;
68 AlphaMap * alpha_map_new ();
70 AlphaMap * alpha_map_clone (const AlphaMap *a_map);
72 void alpha_map_free (AlphaMap *alpha_map);
74 int alpha_map_add_range (AlphaMap *alpha_map,
78 int alpha_char_strlen (const AlphaChar *str);
79 int alpha_char_strcmp (const AlphaChar *str1, const AlphaChar *str2);
85 #endif /* __ALPHA_MAP_H */