C/Migemo 1.4
mtree.h
[詳解]
1// vim:set ts=8 sts=4 sw=4 tw=0 et:
2//
3// mtree.h - Migemo tree (mtree) operations
4//
5// Written By: MURAOKA Taro <koron.kaoriya@gmail.com>
6// Need to include <stdio.h>
7
8#pragma once
9
10#include <stdio.h>
11
12#include "charset.h"
13#include "wordlist.h"
14
15#define MNODE_BLOCK_BYTES (64 * 1024)
16#define MNODE_BLOCK_HEADER_SIZE (sizeof(void *) + sizeof(size_t))
17#define MNODE_BLOCK_SIZE \
18 ((MNODE_BLOCK_BYTES - MNODE_BLOCK_HEADER_SIZE) / sizeof(mnode))
19
20typedef struct mnode mnode;
21struct mnode
22{
25
26 unsigned int code;
27 unsigned int weight;
29};
30
31typedef struct mnode_block mnode_block;
38
44
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57// Life cycle management
58mtree *mtree_open(void);
59void mtree_close(mtree *mt);
60
61// Load dictionary & query
62mtree *mtree_load(mtree *mt, FILE *fp, CHARSET_PROC_CHAR2INT char2int);
63mnode *mtree_query(mtree *mt, const unsigned char *query);
64
65// Other operations
67
68// Debug & maintenance
69void mtree_print_stat(mtree *mt, const char *title);
70
71#ifdef __cplusplus
72}
73#endif
#define CHARSET_PROC_CHAR2INT
Definition charset.h:21
mtree * mtree_load(mtree *mt, FILE *fp, CHARSET_PROC_CHAR2INT char2int)
Definition mtree.c:316
mnode * mtree_query(mtree *mt, const unsigned char *query)
Definition mtree.c:401
void mtree_print_stat(mtree *mt, const char *title)
Definition mtree.c:68
mnode * mtree_rootnode(mtree *mt)
Definition mtree.c:428
void mtree_close(mtree *mt)
Definition mtree.c:118
#define MNODE_BLOCK_SIZE
Definition mtree.h:17
mtree * mtree_open(void)
Definition mtree.c:392
Definition mtree.h:40
mnode_block * head
Definition mtree.h:41
mnode_block * curr
Definition mtree.h:42
Definition mtree.h:33
mnode_block * next
Definition mtree.h:34
mnode nodes[MNODE_BLOCK_SIZE]
Definition mtree.h:36
size_t used
Definition mtree.h:35
Definition mtree.h:22
wordlist * list
Definition mtree.h:28
mnode * low
Definition mtree.h:23
mnode * high
Definition mtree.h:23
unsigned int weight
Definition mtree.h:27
unsigned int code
Definition mtree.h:26
mnode * child
Definition mtree.h:24
Definition mtree.h:46
CHARSET_PROC_CHAR2INT char2int
Definition mtree.h:50
mnode_arena arena
Definition mtree.h:48
mnode * rootnode
Definition mtree.h:47
Definition wordlist.h:14