-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHash.cpp
More file actions
85 lines (77 loc) · 1.9 KB
/
Copy pathHash.cpp
File metadata and controls
85 lines (77 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "Hash.h"
#include "limits.h"
#include "assert.h"
#include <iostream>
extern const int CANONICAL_SCORE;
map_it Hash::Begin ()
{
return Junctions.begin();
}
void Hash::Insert (OP Location,Junction & J,bool Unique)
{
JStat T;
int Paring=J.Type;
assert(Paring >=0 && Paring <=CANONICAL_SCORE);
assert(Location.x <= Location.y);
Junc_I=Junctions.find(Location);
if (Junc_I == Junctions.end()) //New entry..
{
T.Count=1;T.Junc_Type=Paring;
/*for(int i=0;i<ENT_LIM-15;i++)
{
T.L_Anchor[i]=0;
T.R_Anchor[i]=0;
}*/
if (Unique)
T.Unique=true;
else
T.Unique=false;
Junctions[Location]=T;
}
else
{
//assert(J.L>=0 && J.R>=0);
assert((Junc_I->second).Count>0 && (Junc_I->second).Junc_Type==Paring);
(Junc_I->second).Count++;
/*if(J.L>=ENT_LIM)
{
if ((Junc_I->second).L_Anchor[ENT_LIM-1]!=CHAR_MAX) (Junc_I->second).L_Anchor[ENT_LIM-1]++;
}
else if ((Junc_I->second).L_Anchor[J.L]!=CHAR_MAX) (Junc_I->second).L_Anchor[ENT_LIM-1]++;
if(J.L>=ENT_LIM)
{
if ((Junc_I->second).R_Anchor[ENT_LIM-1]!=CHAR_MAX) (Junc_I->second).R_Anchor[ENT_LIM-1]++;
}
else if ((Junc_I->second).R_Anchor[J.L]!=CHAR_MAX) (Junc_I->second).R_Anchor[ENT_LIM-1]++;*/
if (Unique)
(Junc_I->second).Unique=true;
}
}
void Hash::Delete (OP Location)
{
Junc_I=Junctions.find(Location);
if (Junc_I != Junctions.end()) Junctions.erase(Junc_I);
}
bool Hash::Init_Iterate(OP & Location,JStat & Data)
{
Junc_I=Junctions.begin();
if (Junc_I == Junctions.end()) return false;
else
{
Last=Junc_I;//save last pos...
Location = Junc_I->first;
Data = Junc_I->second;
Junc_I++;
return true;
}
}
bool Hash::Iterate(OP & Location,JStat & Data)
{
if(Junc_I == Junctions.end()) return false;
Last=Junc_I;//save last pos...
Location = Junc_I->first;
Data = Junc_I->second;
Junc_I++;
return true;
}
//}----------------------------- Classes -------------------------------------------------/