| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* libdatrie - Double-Array Trie Library |
| 4 |
* Copyright (C) 2006 Theppitak Karoonboonyanan <[email protected]> |
| 5 |
* |
| 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. |
| 10 |
* |
| 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. |
| 15 |
* |
| 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 |
| 19 |
*/ |
| 20 |
|
| 21 |
/* |
| 22 |
* tail.h - trie tail for keeping suffixes |
| 23 |
* Created: 2006-08-12 |
| 24 |
* Author: Theppitak Karoonboonyanan <[email protected]> |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef __TAIL_H |
| 28 |
#define __TAIL_H |
| 29 |
|
| 30 |
#include "triedefs.h" |
| 31 |
|
| 32 |
/** |
| 33 |
* @file tail.h |
| 34 |
* @brief trie tail for keeping suffixes |
| 35 |
*/ |
| 36 |
|
| 37 |
/** |
| 38 |
* @brief Tail structure type |
| 39 |
*/ |
| 40 |
typedef struct _Tail Tail; |
| 41 |
|
| 42 |
Tail * tail_new (void); |
| 43 |
|
| 44 |
Tail * tail_fread (FILE *file); |
| 45 |
|
| 46 |
void tail_free (Tail *t); |
| 47 |
|
| 48 |
size_t tail_get_serialized_size (const Tail *t); |
| 49 |
|
| 50 |
int tail_serialize (const Tail *t, uint8 **ptr); |
| 51 |
|
| 52 |
int tail_fwrite (const Tail *t, FILE *file); |
| 53 |
|
| 54 |
|
| 55 |
const TrieChar * tail_get_suffix (const Tail *t, TrieIndex index); |
| 56 |
|
| 57 |
Bool tail_set_suffix (Tail *t, TrieIndex index, const TrieChar *suffix); |
| 58 |
|
| 59 |
TrieIndex tail_add_suffix (Tail *t, const TrieChar *suffix); |
| 60 |
|
| 61 |
TrieData tail_get_data (const Tail *t, TrieIndex index); |
| 62 |
|
| 63 |
Bool tail_set_data (Tail *t, TrieIndex index, TrieData data); |
| 64 |
|
| 65 |
void tail_delete (Tail *t, TrieIndex index); |
| 66 |
|
| 67 |
int tail_walk_str (const Tail *t, |
| 68 |
TrieIndex s, |
| 69 |
short *suffix_idx, |
| 70 |
const TrieChar *str, |
| 71 |
int len); |
| 72 |
|
| 73 |
Bool tail_walk_char (const Tail *t, |
| 74 |
TrieIndex s, |
| 75 |
short *suffix_idx, |
| 76 |
TrieChar c); |
| 77 |
|
| 78 |
/** |
| 79 |
* @brief Test walkability in tail with a character |
| 80 |
* |
| 81 |
* @param t : the tail data |
| 82 |
* @param s : the tail data index |
| 83 |
* @param suffix_idx : current character index in suffix |
| 84 |
* @param c : the character to test walkability |
| 85 |
* |
| 86 |
* @return boolean indicating walkability |
| 87 |
* |
| 88 |
* Test if the character @a c can be used to walk from given character |
| 89 |
* position @a suffix_idx of entry @a s of the tail data @a t. |
| 90 |
*/ |
| 91 |
/* |
| 92 |
Bool tail_is_walkable_char (Tail *t, |
| 93 |
TrieIndex s, |
| 94 |
short suffix_idx, |
| 95 |
const TrieChar c); |
| 96 |
*/ |
| 97 |
#define tail_is_walkable_char(t,s,suffix_idx,c) \ |
| 98 |
(tail_get_suffix ((t), (s)) [suffix_idx] == (c)) |
| 99 |
|
| 100 |
#endif /* __TAIL_H */ |
| 101 |
|
| 102 |
/* |
| 103 |
vi:ts=4:ai:expandtab |
| 104 |
*/ |