2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: PointerTable.h /main/1 1996/07/29 17:01:44 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef PointerTable_INCLUDED
28 #define PointerTable_INCLUDED 1
35 namespace SP_NAMESPACE {
38 template<class P, class K, class HF, class KF> class PointerTableIter;
40 template<class P, class K, class HF, class KF>
45 unsigned long n = HF::hash(key);
46 n = 0; // prevent warning
50 P insert(P, Boolean replace = 0);
51 // Return a reference so that it is possible to do
52 // lookups into a table of smart-pointers from multiple threads.
53 const P &lookup(const K &) const;
55 size_t count() const { return used_; }
57 void swap(PointerTable<P, K, HF, KF> &);
64 size_t startIndex(const K &k) const {
65 return size_t(HF::hash(k) & (vec_.size() - 1));
67 size_t nextIndex(size_t i) const {
68 return i == 0 ? vec_.size() - 1 : i - 1;
70 friend class PointerTableIter<P, K, HF, KF>;
73 template<class P, class K, class HF, class KF>
74 class PointerTableIter {
76 PointerTableIter(const PointerTable<P, K, HF, KF> &);
79 const PointerTable<P, K, HF, KF> *tablePtr_;
87 #endif /* not PointerTable_INCLUDED */
89 #ifdef SP_DEFINE_TEMPLATES
90 #include "PointerTable.C"