AGENT++
4.0.3
Main Page
Related Pages
Classes
Files
File List
File Members
include
agent_pp
mib_avl_map.h
Go to the documentation of this file.
1
/*_############################################################################
2
_##
3
_## AGENT++ 4.0 - mib_avl_map.h
4
_##
5
_## Copyright (C) 2000-2013 Frank Fock and Jochen Katz (agentpp.com)
6
_##
7
_## Licensed under the Apache License, Version 2.0 (the "License");
8
_## you may not use this file except in compliance with the License.
9
_## You may obtain a copy of the License at
10
_##
11
_## http://www.apache.org/licenses/LICENSE-2.0
12
_##
13
_## Unless required by applicable law or agreed to in writing, software
14
_## distributed under the License is distributed on an "AS IS" BASIS,
15
_## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
_## See the License for the specific language governing permissions and
17
_## limitations under the License.
18
_##
19
_##########################################################################*/
20
// This may look like C code, but it is really -*- C++ -*-
21
/*
22
Copyright (C) 1988 Free Software Foundation
23
written by Doug Lea (dl@rocky.oswego.edu)
24
25
This file is part of the GNU C++ Library. This library is free
26
software; you can redistribute it and/or modify it under the terms of
27
the GNU Library General Public License as published by the Free
28
Software Foundation; either version 2 of the License, or (at your
29
option) any later version. This library is distributed in the hope
30
that it will be useful, but WITHOUT ANY WARRANTY; without even the
31
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
32
PURPOSE. See the GNU Library General Public License for more details.
33
You should have received a copy of the GNU Library General Public
34
License along with this library; if not, write to the Free Software
35
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36
*/
37
38
39
#ifndef _OidxPtrMibEntryPtrAVLMap_h
40
#ifdef __GNUG__
41
#pragma interface
42
#endif
43
#define _OidxPtrMibEntryPtrAVLMap_h 1
44
45
#include <
agent_pp/agent++.h
>
46
#include <
agent_pp/mib_map.h
>
47
48
#ifdef AGENTPP_NAMESPACE
49
namespace
Agentpp {
50
#endif
51
52
53
struct
OidxPtrMibEntryPtrAVLNode
54
{
55
OidxPtrMibEntryPtrAVLNode
*
lt
;
56
OidxPtrMibEntryPtrAVLNode
*
rt
;
57
OidxPtr
item
;
58
MibEntryPtr
cont
;
59
char
stat
;
60
OidxPtrMibEntryPtrAVLNode
(
OidxPtr
h,
MibEntryPtr
c,
61
OidxPtrMibEntryPtrAVLNode
* l=0,
OidxPtrMibEntryPtrAVLNode
* r=0);
62
~OidxPtrMibEntryPtrAVLNode
() {};
63
};
64
65
inline
OidxPtrMibEntryPtrAVLNode::OidxPtrMibEntryPtrAVLNode
(
OidxPtr
h,
MibEntryPtr
c,
66
OidxPtrMibEntryPtrAVLNode
* l,
OidxPtrMibEntryPtrAVLNode
* r)
67
:lt(l), rt(r), item(h), cont(c), stat(0) {}
68
69
typedef
OidxPtrMibEntryPtrAVLNode
*
OidxPtrMibEntryPtrAVLNodePtr
;
70
71
72
class
AGENTPP_DECL
OidxPtrMibEntryPtrAVLMap
:
public
OidxPtrMibEntryPtrMap
73
{
74
protected
:
75
OidxPtrMibEntryPtrAVLNode
*
root
;
76
77
OidxPtrMibEntryPtrAVLNode
* leftmost();
78
OidxPtrMibEntryPtrAVLNode
* rightmost();
79
OidxPtrMibEntryPtrAVLNode
* pred(
OidxPtrMibEntryPtrAVLNode
* t);
80
OidxPtrMibEntryPtrAVLNode
* succ(
OidxPtrMibEntryPtrAVLNode
* t);
81
void
_kill(
OidxPtrMibEntryPtrAVLNode
* t);
82
void
_add(
OidxPtrMibEntryPtrAVLNode
*& t);
83
void
_del(
OidxPtrMibEntryPtrAVLNode
* p,
OidxPtrMibEntryPtrAVLNode
*& t);
84
85
public
:
86
OidxPtrMibEntryPtrAVLMap
(
MibEntryPtr
deflt);
87
OidxPtrMibEntryPtrAVLMap
(
OidxPtrMibEntryPtrAVLMap
& a);
88
inline
~
OidxPtrMibEntryPtrAVLMap
();
89
90
MibEntryPtr
&
operator []
(
OidxPtr
key);
91
92
void
del
(
OidxPtr
key);
93
94
inline
Pix
first
();
95
inline
void
next
(
Pix
& i);
96
inline
OidxPtr
&
key
(
Pix
i);
97
inline
MibEntryPtr
&
contents
(
Pix
i);
98
99
Pix
seek
(
OidxPtr
key);
100
Pix
seek_inexact(
OidxPtr
key);
101
inline
int
contains
(
OidxPtr
key_);
102
103
inline
void
clear
();
104
105
Pix
last();
106
void
prev(
Pix
& i);
107
108
int
OK
();
109
};
110
111
inline
OidxPtrMibEntryPtrAVLMap::~OidxPtrMibEntryPtrAVLMap
()
112
{
113
_kill
(
root
);
114
}
115
116
inline
OidxPtrMibEntryPtrAVLMap::OidxPtrMibEntryPtrAVLMap
(
MibEntryPtr
deflt) :
OidxPtrMibEntryPtrMap
(deflt)
117
{
118
root
= 0;
119
}
120
121
inline
Pix
OidxPtrMibEntryPtrAVLMap::first
()
122
{
123
return
Pix
(
leftmost
());
124
}
125
126
inline
Pix
OidxPtrMibEntryPtrAVLMap::last
()
127
{
128
return
Pix
(
rightmost
());
129
}
130
131
inline
void
OidxPtrMibEntryPtrAVLMap::next
(
Pix
& i)
132
{
133
if
(i != 0) i =
Pix
(
succ
((
OidxPtrMibEntryPtrAVLNode
*)i));
134
}
135
136
inline
void
OidxPtrMibEntryPtrAVLMap::prev
(
Pix
& i)
137
{
138
if
(i != 0) i =
Pix
(
pred
((
OidxPtrMibEntryPtrAVLNode
*)i));
139
}
140
141
inline
OidxPtr
&
OidxPtrMibEntryPtrAVLMap::key
(
Pix
i)
142
{
143
if
(i == 0)
error
(
"null Pix"
);
144
return
((
OidxPtrMibEntryPtrAVLNode
*)i)->item;
145
}
146
147
inline
MibEntryPtr
&
OidxPtrMibEntryPtrAVLMap::contents
(
Pix
i)
148
{
149
if
(i == 0)
error
(
"null Pix"
);
150
return
((
OidxPtrMibEntryPtrAVLNode
*)i)->cont;
151
}
152
153
inline
void
OidxPtrMibEntryPtrAVLMap::clear
()
154
{
155
_kill
(
root
);
156
count
= 0;
157
root
= 0;
158
}
159
160
inline
int
OidxPtrMibEntryPtrAVLMap::contains
(
OidxPtr
key_)
161
{
162
return
seek
(key_) != 0;
163
}
164
165
#ifdef AGENTPP_NAMESPACE
166
}
167
#endif
168
169
#endif
Generated by
1.8.2