Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / gnu / lib / libg++ / g++-include / gen / CHMap.hP
CommitLineData
e87b4ac1
PR
1// This may look like C code, but it is really -*- C++ -*-
2/*
3Copyright (C) 1988 Free Software Foundation
4 written by Doug Lea (dl@rocky.oswego.edu)
5
6This file is part of the GNU C++ Library. This library is free
7software; you can redistribute it and/or modify it under the terms of
8the GNU Library General Public License as published by the Free
9Software Foundation; either version 2 of the License, or (at your
10option) any later version. This library is distributed in the hope
11that it will be useful, but WITHOUT ANY WARRANTY; without even the
12implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU Library General Public License for more details.
14You should have received a copy of the GNU Library General Public
15License along with this library; if not, write to the Free Software
16Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17*/
18
19
20#ifndef _<T><C>CHMap_h
21#ifdef __GNUG__
22#pragma interface
23#endif
24#define _<T><C>CHMap_h 1
25
26#include "<T>.<C>.Map.h"
27
28#ifndef _<T><C>CHNode_h
29#define _<T><C>CHNode_h 1
30
31struct <T><C>CHNode
32{
33 <T><C>CHNode* tl;
34 <T> hd;
35 <C> cont;
36 <T><C>CHNode();
37 <T><C>CHNode(<T&> h, <C&> c, <T><C>CHNode* t = 0);
38 ~<T><C>CHNode();
39};
40
41inline <T><C>CHNode::<T><C>CHNode() {}
42
43inline <T><C>CHNode::<T><C>CHNode(<T&> h, <C&> c, <T><C>CHNode* t)
44 : hd(h), cont(c), tl(t) {}
45
46inline <T><C>CHNode::~<T><C>CHNode() {}
47
48typedef <T><C>CHNode* <T><C>CHNodePtr;
49
50#endif
51
52
53class <T><C>CHMap : public <T><C>Map
54{
55protected:
56 <T><C>CHNode** tab;
57 unsigned int size;
58
59public:
60 <T><C>CHMap(<C&> dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY);
61 <T><C>CHMap(<T><C>CHMap& a);
62 ~<T><C>CHMap();
63
64 <C>& operator [] (<T&> key);
65
66 void del(<T&> key);
67
68 Pix first();
69 void next(Pix& i);
70 <T>& key(Pix i);
71 <C>& contents(Pix i);
72
73 Pix seek(<T&> key);
74 int contains(<T&> key);
75
76 void clear();
77 int OK();
78};
79
80
81inline <T><C>CHMap::~<T><C>CHMap()
82{
83 clear();
84 delete tab;
85}
86
87inline int <T><C>CHMap::contains(<T&> key)
88{
89 return seek(key) != 0;
90}
91
92inline <T>& <T><C>CHMap::key(Pix p)
93{
94 if (p == 0) error("null Pix");
95 return ((<T><C>CHNode*)p)->hd;
96}
97
98inline <C>& <T><C>CHMap::contents(Pix p)
99{
100 if (p == 0) error("null Pix");
101 return ((<T><C>CHNode*)p)->cont;
102}
103
104#endif