Initialize Tizen 2.3
[external/ragel.git] / aapl / sbsttable.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_SBSTTABLE_H
23 #define _AAPL_SBSTTABLE_H
24
25 #include "compare.h"
26 #include "svector.h"
27
28 /**
29  * \addtogroup bst 
30  * @{
31  */
32
33 /** 
34  * \class SBstTable
35  * \brief Copy-on-write binary search table for structures that contain a key.
36  *
37  * This is a basic binary search table that employs a copy-on-write data
38  * storage mechanism. It can be used to contain a structure that has a key and
39  * possibly some data. The key should be a member of the element class and
40  * accessible with getKey(). A class containing the compare routine must be
41  * supplied.
42  */
43
44 /*@}*/
45
46 #define BST_TEMPL_DECLARE class Element, class Key, \
47                 class Compare = CmpOrd<Key>, class Resize = ResizeExpn
48 #define BST_TEMPL_DEF class Element, class Key, class Compare, class Resize
49 #define BST_TEMPL_USE Element, Key, Compare, Resize
50 #define GET_KEY(el) ((el).getKey())
51 #define BstTable SBstTable
52 #define Vector SVector
53 #define Table STable
54 #define BSTTABLE
55 #define SHARED_BST
56
57 #include "bstcommon.h"
58
59 #undef BST_TEMPL_DECLARE
60 #undef BST_TEMPL_DEF
61 #undef BST_TEMPL_USE
62 #undef GET_KEY
63 #undef BstTable
64 #undef Vector
65 #undef Table
66 #undef BSTTABLE
67 #undef SHARED_BST
68
69 /**
70  * \fn SBstTable::insert(const Key &key, Element **lastFound)
71  * \brief Insert a new element with the given key.
72  *
73  * If the given key does not already exist in the table a new element is
74  * inserted with the given key. A constructor taking only const Key& is used
75  * to initialize the new element. If lastFound is given, it is set to the new
76  * element created. If the insert fails then lastFound is set to the existing
77  * element with the same key. 
78  *
79  * \returns The new element created upon success, null upon failure.
80  */
81
82 /**
83  * \fn SBstTable::insertMulti(const Key &key)
84  * \brief Insert a new element even if the key exists already.
85  *
86  * If the key exists already then the new element is placed next to some
87  * element with the same key. InsertMulti cannot fail. A constructor taking
88  * only const Key& is used to initialize the new element.
89  *
90  * \returns The new element created.
91  */
92
93 #endif /* _AAPL_SBSTTABLE_H */