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
StMultiKeyMapM.h.C
1
#ifndef MULTIKEYMAP_H
2
#define MULTIKEYMAP_H
3
#include <vector>
4
class
StMultiKeyMapMIter
;
5
class
StMultiKeyNode
;
6
7
class
StMultiKeyMapM
8
{
9
friend
class
StMultiKeyMapMIter
;
10
public
:
11
StMultiKeyMapM
(
int
nKeys);
12
~
StMultiKeyMapM
();
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(
int
keepArray=0);
21
int
ls(
const
char
*file=
""
)
const
;
22
int
Size()
const
;
23
int
GetNKey()
const
{
return
mNKey;}
24
StMultiKeyNode
** GetArr() {
return
&mArr[0];}
25
// statics
26
static
void
Test();
27
static
void
Test2();
28
29
30
protected
:
31
int
mNKey;
32
StMultiKeyNode
*mTop;
33
std::vector<StMultiKeyNode*> mArr;
34
};
35
36
37
38
class
StMultiKeyNode
39
{
40
friend
class
StMultiKeyMapMIter
;
41
public
:
42
StMultiKeyNode
(
int
nKeys);
43
StMultiKeyNode
(
const
StMultiKeyNode
&source);
44
virtual
~
StMultiKeyNode
();
45
virtual
void
Set(
const
void
*obj,
const
float
*keys);
46
void
Set(
const
void
*obj,
const
double
*keys);
47
void
Add(
const
void
*obj,
const
float
*keys);
48
virtual
void
Add(
StMultiKeyNode
*node);
49
virtual
double
Quality();
50
virtual
int
ls(
const
char
*file=
""
)
const
;
51
52
const
float
*GetKeys()
const
{
return
mKeys;}
53
float
GetKey()
const
{
return
mKeys[int(mIKey)];}
54
int
GetIKey()
const
{
return
mIKey;}
55
void
SetIKey(
int
ik) { mIKey=ik; }
56
int
GetNKey()
const
{
return
mNKey;}
57
int
GetNumb(
int
way)
const
{
return
mNumb[way];}
58
int
Size()
const
{
return
mNumb[0]+mNumb[1]+1;}
59
void
*GetObj ()
const
{
return
(
void
*)mObj ;}
60
void
Clear();
61
static
int
GetNInst();
62
// Non user functions
63
protected
:
64
StMultiKeyNode
*LLink()
const
{
return
mLink[0];}
65
StMultiKeyNode
*RLink()
const
{
return
mLink[1];}
66
private
:
67
void
Init();
68
69
70
// statics
71
public
:
72
73
protected
:
74
char
mNKey;
//keys number defined
75
char
mIKey;
//key number used on this level
76
int
mNumb[2];
//Number of left/right objects
77
StMultiKeyNode
*mLink[2];
//Left/Right subtree pointers
78
const
void
*mObj;
//Some user object mapped to keys
79
float
*mKeys;
//keys for this object
80
int
mId;
81
};
82
83
84
class
StMultiKeyMapMIter
85
{
86
public
:
87
StMultiKeyMapMIter
(
const
StMultiKeyNode
*node,
const
float
*kMin=0,
const
float
*kMax=0);
88
void
Set(
const
StMultiKeyNode
*node,
const
float
*kMin=0,
const
float
*kMax=0);
89
void
Update(
const
float
*kMin=0,
const
float
*kMax=0);
90
91
~
StMultiKeyMapMIter
();
92
StMultiKeyNode
*operator*()
const
{
return
(
StMultiKeyNode
*)mStk[mLev];}
93
StMultiKeyMapMIter
&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
void
Left(
const
StMultiKeyNode
*node);
100
int
FullCheck();
101
int
FilterLeft(
const
StMultiKeyNode
*node)
const
;
102
int
FilterRite(
const
StMultiKeyNode
*node)
const
;
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
std::vector<const StMultiKeyNode*> mStk;
111
};
112
#endif //MULTYKEYBINTREE_H
StMultiKeyNode
Definition:
StMultiKeyMap.h:37
StMultiKeyMapMIter
Definition:
StMultiKeyMapM.h.C:84
StMultiKeyMapM
Definition:
StMultiKeyMapM.h.C:7
Generated by
1.8.5