OSDN Git Service

fix copyright year.
[bbk/bchan.git] / src / residhash.h
1 /*
2  * residhash.h
3  *
4  * Copyright (c) 2010 project bchan
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty. In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  *    misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source
23  *    distribution.
24  *
25  */
26
27 #include        <basic.h>
28 #include        <bsys/queue.h>
29 #include        <btron/dp.h>
30
31 #ifndef __RESIDHASH_H__
32 #define __RESIDHASH_H__
33
34 #ifndef RESIDHASH_BASE
35 #define RESIDHASH_BASE 10 
36 #endif
37
38 typedef struct residhash_node_t_ {
39         QUEUE queue;
40         TC *id;
41         W id_len;
42         UW attr;
43         COLOR color;
44 } residhash_node_t;
45
46 struct residhash_t_ {
47         W datanum;
48         residhash_node_t tbl[RESIDHASH_BASE];
49 };
50 typedef struct residhash_t_ residhash_t;
51
52 IMPORT W residhash_initialize(residhash_t *residhash);
53 IMPORT VOID residhash_finalize(residhash_t *residhash);
54 IMPORT W residhash_adddata(residhash_t *residhash, TC *idstr, W idstr_len, UW attr, COLOR color);
55 #define RESIDHASH_SEARCHDATA_NOTFOUND 0
56 #define RESIDHASH_SEARCHDATA_FOUND    1
57 IMPORT W residhash_searchdata(residhash_t *residhash, TC *idstr, W idstr_len, UW *attr, COLOR *color);
58 IMPORT VOID residhash_removedata(residhash_t *residhash, TC *idstr, W idstr_len);
59 IMPORT W residhash_datanum(residhash_t *residhash);
60
61 struct residhash_iterator_t_ {
62         residhash_t *residhash;
63         W tbl_index;
64         residhash_node_t *node;
65 };
66 typedef struct residhash_iterator_t_ residhash_iterator_t;
67
68 IMPORT VOID residhash_iterator_initialize(residhash_iterator_t *iter, residhash_t *target);
69 IMPORT VOID residhash_iterator_finalize(residhash_iterator_t *iter);
70 IMPORT Bool residhash_iterator_next(residhash_iterator_t *iter, TC **idstr, W *idstr_len, W *attr, W *color);
71
72 #endif