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 * tail.h - trie tail for keeping suffixes
24 * Author: Theppitak Karoonboonyanan <theppitak@gmail.com>
34 * @brief trie tail for keeping suffixes
38 * @brief Double-array structure type
40 typedef struct _Tail Tail;
44 Tail * tail_fread (FILE *file);
46 void tail_free (Tail *t);
48 int tail_fwrite (const Tail *t, FILE *file);
51 const TrieChar * tail_get_suffix (const Tail *t, TrieIndex index);
53 Bool tail_set_suffix (Tail *t, TrieIndex index, const TrieChar *suffix);
55 TrieIndex tail_add_suffix (Tail *t, const TrieChar *suffix);
57 TrieData tail_get_data (const Tail *t, TrieIndex index);
59 Bool tail_set_data (Tail *t, TrieIndex index, TrieData data);
61 void tail_delete (Tail *t, TrieIndex index);
63 int tail_walk_str (const Tail *t,
69 Bool tail_walk_char (const Tail *t,
75 * @brief Test walkability in tail with a character
77 * @param t : the tail data
78 * @param s : the tail data index
79 * @param suffix_idx : current character index in suffix
80 * @param c : the character to test walkability
82 * @return boolean indicating walkability
84 * Test if the character @a c can be used to walk from given character
85 * position @a suffix_idx of entry @a s of the tail data @a t.
88 Bool tail_is_walkable_char (Tail *t,
93 #define tail_is_walkable_char(t,s,suffix_idx,c) \
94 (tail_get_suffix ((t), (s)) [suffix_idx] == (c))