1
/* This file is part of Malaga, a system for Natural Language Analysis.
2
* Copyright (C) 1995-1999 Bjoern Beutel
5
* Universitaet Erlangen-Nuernberg
6
* Abteilung fuer Computerlinguistik
9
* e-mail: malaga@linguistik.uni-erlangen.de
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
25
/* description ==============================================================*/
27
/* This module defines a new data type, "pool_t", for growing vectors of items
28
* of an arbitrary type. */
30
/* types ====================================================================*/
32
/* the abstract data type <pool_t> */
33
typedef struct POOL_T *pool_t;
35
/* functions ================================================================*/
37
extern pool_t new_pool (int_t item_size);
38
/* Create a new pool that records items of size <item_size>. */
40
extern void free_pool (pool_t *pool);
41
/* Free all memory used by <*pool>. */
43
extern void clear_pool (pool_t pool);
44
/* Clear <pool> (do not free any memory used by the pool). */
46
extern void *pool_to_vector (pool_t pool);
47
/* Return <pool> as a C vector (contiguous memory).
48
* The vector can be freed with "free" after use. */
50
extern void write_pool (pool_t pool, FILE *stream, string_t file_name);
51
/* Write <pool> to <stream> (<file_name> is needed for error messages). */
53
extern void *get_pool_space (pool_t pool, int_t num_items, int_t *index);
54
/* Get space for <num_items> contiguous items in pool <pool>,
55
* return its address as the function's result and the index in *<index>,
56
* if <index> != NULL. */
58
extern int_t pool_items (pool_t pool);
59
/* Return the number of the items in <pool>. */
61
extern void *pool_item (pool_t pool, int_t index);
62
/* Return the address of item with <index> in pool <pool>,
63
* or NULL if there is no such item. */
65
extern int_t pool_index (pool_t pool, void *item);
66
/* Return the index of <item> in <pool>.
67
* Report an error if <item> doesn't exist in <pool>. */
69
extern void *copy_to_pool (pool_t pool,
73
/* Copy the vector *<ptr> of length <num_items> into <pool>.
74
* The items of *<ptr> must be of same size as the items in <pool>.
75
* Return the address of the copy as the function's result and the
76
* index in *<index>, if <index> != NULL. */
78
extern string_t copy_string_to_pool (pool_t pool,
81
/* Copy the string <string> into <pool>, which must be a string pool.
82
* Return the copy of the string as the function's result as well as
83
* its index in *<index>, if <index> != NULL. */
85
/* end of file ==============================================================*/