Initialize Tizen 2.3
[external/ragel.git] / aapl / bsttable.h
1 /*
2  *  Copyright 2002 Adrian Thurston <thurston@complang.org>
3  */
4
5 /*  This file is part of Aapl.
6  *
7  *  Aapl is free software; you can redistribute it and/or modify it under the
8  *  terms of the GNU Lesser General Public License as published by the Free
9  *  Software Foundation; either version 2.1 of the License, or (at your option)
10  *  any later version.
11  *
12  *  Aapl is distributed in the hope that it will be useful, but WITHOUT ANY
13  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  *  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
15  *  more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with Aapl; if not, write to the Free Software Foundation, Inc., 59
19  *  Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21
22 #ifndef _AAPL_BSTTABLE_H
23 #define _AAPL_BSTTABLE_H
24
25 #include "compare.h"
26 #include "vector.h"
27
28 /**
29  * \addtogroup bst 
30  * @{
31  */
32
33 /** 
34  * \class BstTable
35  * \brief Binary search table for structures that contain a key.
36  *
37  * This is the basic binary search table. It can be used to contain a
38  * structure that has a key and possibly some data. The key should be a member
39  * of the element class and accessible with getKey(). A class containing the
40  * compare routine must be supplied.
41  */
42
43 /*@}*/
44
45 #define BST_TEMPL_DECLARE class Element, class Key, \
46                 class Compare = CmpOrd<Key>, class Resize = ResizeExpn
47 #define BST_TEMPL_DEF class Element, class Key, class Compare, class Resize
48 #define BST_TEMPL_USE Element, Key, Compare, Resize
49 #define GET_KEY(el) ((el).getKey())
50 #define BSTTABLE
51
52 #include "bstcommon.h"
53
54 #undef BST_TEMPL_DECLARE
55 #undef BST_TEMPL_DEF
56 #undef BST_TEMPL_USE
57 #undef GET_KEY
58 #undef BSTTABLE
59
60 /**
61  * \fn BstTable::insert(const Key &key, Element **lastFound)
62  * \brief Insert a new element with the given key.
63  *
64  * If the given key does not already exist in the table a new element is
65  * inserted with the given key. A constructor taking only const Key& is used
66  * to initialize the new element. If lastFound is given, it is set to the new
67  * element created. If the insert fails then lastFound is set to the existing
68  * element with the same key. 
69  *
70  * \returns The new element created upon success, null upon failure.
71  */
72
73 /**
74  * \fn BstTable::insertMulti(const Key &key)
75  * \brief Insert a new element even if the key exists already.
76  *
77  * If the key exists already then the new element is placed next to some
78  * element with the same key. InsertMulti cannot fail. A constructor taking
79  * only const Key& is used to initialize the new element.
80  *
81  * \returns The new element created.
82  */
83
84 #endif /* _AAPL_BSTTABLE_H */