/usr/include/datrie/trie.h is in libdatrie-dev 0.2.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* libdatrie - Double-Array Trie Library
* Copyright (C) 2006 Theppitak Karoonboonyanan <thep@linux.thai.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* trie.h - Trie data type and functions
* Created: 2006-08-11
* Author: Theppitak Karoonboonyanan <thep@linux.thai.net>
*/
#ifndef __TRIE_H
#define __TRIE_H
#include <datrie/triedefs.h>
#include <datrie/alpha-map.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file trie.h
* @brief Trie data type and functions
*/
/**
* @brief Trie data type
*/
typedef struct _Trie Trie;
/**
* @brief Trie enumeration function
*
* @param key : the key of the entry
* @param data : the data of the entry
* @param user_data : the user-supplied data on enumerate call
*
* @return TRUE to continue enumeration, FALSE to stop
*/
typedef Bool (*TrieEnumFunc) (const AlphaChar *key,
TrieData key_data,
void *user_data);
/**
* @brief Trie walking state
*/
typedef struct _TrieState TrieState;
/*-----------------------*
* GENERAL FUNCTIONS *
*-----------------------*/
Trie * trie_new (const AlphaMap *alpha_map);
Trie * trie_new_from_file (const char *path);
Trie * trie_fread (FILE *file);
void trie_free (Trie *trie);
int trie_save (Trie *trie, const char *path);
int trie_fwrite (Trie *trie, FILE *file);
Bool trie_is_dirty (const Trie *trie);
/*------------------------------*
* GENERAL QUERY OPERATIONS *
*------------------------------*/
Bool trie_retrieve (const Trie *trie,
const AlphaChar *key,
TrieData *o_data);
Bool trie_store (Trie *trie, const AlphaChar *key, TrieData data);
Bool trie_store_if_absent (Trie *trie, const AlphaChar *key, TrieData data);
Bool trie_delete (Trie *trie, const AlphaChar *key);
Bool trie_enumerate (const Trie *trie,
TrieEnumFunc enum_func,
void *user_data);
/*-------------------------------*
* STEPWISE QUERY OPERATIONS *
*-------------------------------*/
TrieState * trie_root (const Trie *trie);
/*----------------*
* TRIE STATE *
*----------------*/
TrieState * trie_state_clone (const TrieState *s);
void trie_state_copy (TrieState *dst, const TrieState *src);
void trie_state_free (TrieState *s);
void trie_state_rewind (TrieState *s);
Bool trie_state_walk (TrieState *s, AlphaChar c);
Bool trie_state_is_walkable (const TrieState *s, AlphaChar c);
/**
* @brief Check for terminal state
*
* @param s : the state to check
*
* @return boolean value indicating whether it is a terminal state
*
* Check if the given state is a terminal state. A terminal state is a trie
* state that terminates a key, and stores a value associated with it.
*/
#define trie_state_is_terminal(s) trie_state_is_walkable((s),TRIE_CHAR_TERM)
Bool trie_state_is_single (const TrieState *s);
/**
* @brief Check for leaf state
*
* @param s : the state to check
*
* @return boolean value indicating whether it is a leaf state
*
* Check if the given state is a leaf state. A leaf state is a terminal state
* that has no other branch.
*/
#define trie_state_is_leaf(s) \
(trie_state_is_single(s) && trie_state_is_terminal(s))
TrieData trie_state_get_data (const TrieState *s);
#ifdef __cplusplus
}
#endif
#endif /* __TRIE_H */
/*
vi:ts=4:ai:expandtab
*/
|