StRoot
1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
StarRoot
StMultiKeyMap.h
1
#ifndef MULTIKEYMAP_H
2
#define MULTIKEYMAP_H
3
#include <vector>
4
class
StMultiKeyMapIter
;
5
class
StMultiKeyNode
;
6
7
class
StMultiKeyMap
8
{
9
friend
class
StMultiKeyMapIter
;
10
public
:
11
StMultiKeyMap
(
int
nKeys);
12
~
StMultiKeyMap
();
13
void
Clear(
const
char
*opt=
""
);
14
void
Add(
const
void
*obj,
const
float
*keys);
15
void
Add(
const
void
*obj,
const
double
*keys);
16
const
StMultiKeyNode
*GetTop()
const
{
return
mTop;}
17
StMultiKeyNode
*GetTop() {
return
mTop;}
18
void
SetTop(
StMultiKeyNode
*top) {mTop = top;}
19
double
Quality();
20
int
MakeTree();
21
int
ls(
const
char
*file=
""
)
const
;
22
int
Size()
const
;
23
int
GetNKey()
const
{
return
mNKey;}
24
// statics
25
static
void
Test();
26
static
void
Test2();
27
28
29
protected
:
30
int
mNKey;
31
StMultiKeyNode
*mTop;
32
std::vector<StMultiKeyNode*> mArr;
33
};
34
35
36
37
class
StMultiKeyNode
38
{
39
friend
class
StMultiKeyMapIter
;
40
public
:
41
StMultiKeyNode
(
int
nKeys);
42
StMultiKeyNode
(
const
StMultiKeyNode
&source);
43
virtual
~
StMultiKeyNode
();
44
virtual
void
Set(
const
void
*obj,
const
float
*keys);
45
void
Set(
const
void
*obj,
const
double
*keys);
46
void
Add(
const
void
*obj,
const
float
*keys);
47
virtual
void
Add(
StMultiKeyNode
*node);
48
virtual
double
Quality();
49
virtual
int
ls(
const
char
*file=
""
)
const
;
50
51
const
float
*GetKeys()
const
{
return
mKeys;}
52
float
GetKey()
const
{
return
mKeys[int(mIKey)];}
53
int
GetIKey()
const
{
return
mIKey;}
54
void
SetIKey(
int
ik) { mIKey=ik; }
55
int
GetNKey()
const
{
return
mNKey;}
56
int
GetNumb(
int
way)
const
{
return
mNumb[way];}
57
int
Size()
const
{
return
mNumb[0]+mNumb[1]+1;}
58
void
*GetObj ()
const
{
return
(
void
*)mObj ;}
59
void
Clear();
60
static
int
GetNInst();
61
// Non user functions
62
protected
:
63
StMultiKeyNode
*LLink()
const
{
return
mLink[0];}
64
StMultiKeyNode
*RLink()
const
{
return
mLink[1];}
65
private
:
66
void
Init();
67
68
69
// statics
70
public
:
71
72
protected
:
73
char
mNKey;
//keys number defined
74
char
mIKey;
//key number used on this level
75
int
mNumb[2];
//Number of left/right objects
76
StMultiKeyNode
*mLink[2];
//Left/Right subtree pointers
77
const
void
*mObj;
//Some user object mapped to keys
78
float
*mKeys;
//keys for this object
79
int
mId;
80
};
81
82
83
class
StMultiKeyMapIter
84
{
85
public
:
86
StMultiKeyMapIter
(
const
StMultiKeyNode
*node,
const
float
*kMin=0,
const
float
*kMax=0);
87
void
Set(
const
StMultiKeyNode
*node,
const
float
*kMin=0,
const
float
*kMax=0);
88
void
Update(
const
float
*kMin=0,
const
float
*kMax=0);
89
void
Reset();
90
91
~
StMultiKeyMapIter
();
92
StMultiKeyNode
*operator*()
const
{
return
(
StMultiKeyNode
*)mStk[mLev];}
93
StMultiKeyMapIter
&operator++();
94
int
Level()
const
{
return
mLev;}
95
float
*GetKMin()
const
{
return
mKMin;}
96
float
*GetKMax()
const
{
return
mKMax;}
97
const
int
*Touched()
const
{
return
mTouched;}
98
private
:
99
const
StMultiKeyNode
*LLink(
const
StMultiKeyNode
*node)
const
;
100
const
StMultiKeyNode
*RLink(
const
StMultiKeyNode
*node)
const
;
101
const
StMultiKeyNode
*Left(
const
StMultiKeyNode
*node);
102
int
FullCheck();
103
protected
:
104
mutable
int
mTouched[3];
105
std::vector<float> mMinMax;
106
float
*mKMin;
107
float
*mKMax;
108
int
mNK;
109
int
mLev;
110
const
StMultiKeyNode
*mTop;
111
std::vector<const StMultiKeyNode*> mStk;
112
};
113
#endif //MULTYKEYBINTREE_H
StMultiKeyMapIter
Definition:
StMultiKeyMap.h:83
StMultiKeyMap
Definition:
StMultiKeyMap.h:7
StMultiKeyNode
Definition:
StMultiKeyMap.h:37
Generated by
1.8.5