2 * Copyright 2002 Adrian Thurston <thurston@cs.queensu.ca>
5 /* This file is part of Aapl.
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)
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
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
22 #ifndef _AAPL_SBSTSET_H
23 #define _AAPL_SBSTSET_H
32 * \brief Copy-on-write binary search table for types that are the key.
34 * This is a set style binary search table that employs the copy-on-write
35 * mechanism for storing table data. BstSet is suitable for types that
36 * comprise the entire key. Rather than look into the element to retrieve the
37 * key, the element is the key. A class that contains a comparison routine
38 * for the key must be given.
46 #define BST_TEMPL_DECLARE class Key, class Compare = CmpOrd<Key>, \
47 class Resize = ResizeExpn
48 #define BST_TEMPL_DEF class Key, class Compare, class Resize
49 #define BST_TEMPL_USE Key, Compare, Resize
50 #define GET_KEY(el) (el)
51 #define BstTable SBstSet
52 #define Vector SVector
58 #include "bstcommon.h"
60 #undef BST_TEMPL_DECLARE
72 * \fn SBstSet::insert(const Key &key, Key **lastFound)
73 * \brief Insert the given key.
75 * If the given key does not already exist in the table then it is inserted.
76 * The key's copy constructor is used to place the item in the table. If
77 * lastFound is given, it is set to the new entry created. If the insert fails
78 * then lastFound is set to the existing key of the same value.
80 * \returns The new element created upon success, null upon failure.
84 * \fn SBstSet::insertMulti(const Key &key)
85 * \brief Insert the given key even if it exists already.
87 * If the key exists already then it is placed next to some other key of the
88 * same value. InsertMulti cannot fail. The key's copy constructor is used to
89 * place the item in the table.
91 * \returns The new element created.
94 #endif /* _AAPL_SBSTSET_H */