-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCBvLookupTable.cpp
More file actions
57 lines (48 loc) · 1.29 KB
/
CBvLookupTable.cpp
File metadata and controls
57 lines (48 loc) · 1.29 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
#include "CBvLookupTable.h"
CBvLookupTable::CBvLookupTable(vector<TiXmlElement*>& m_sortedElements)
:CLookupTable(m_sortedElements)
{
string strLast(m_sortedElements[m_sortedElements.size() - 1]->Value());
map<string, int>::iterator itLut = m_lut.begin();
int iLast = m_lut[strLast];
m_pBitVec = new bit_vector(iLast + 1, 0);
itLut = m_lut.begin();
for (; itLut != m_lut.end(); itLut++)
{
cout << itLut->second << endl;
(*m_pBitVec)[itLut->second] = 1;
}
m_pSdVec = new sd_vector<>(*m_pBitVec);
}
CBvLookupTable::~CBvLookupTable()
{
if (m_pBitVec)
delete m_pBitVec;
delete m_pSdVec;
}
bool CBvLookupTable::LabelBV(int nID, string& elementName)
{
if (nID >= m_nElements)
return false;
rank_support_v<1> rank_bitvector(m_pBitVec);
int irank = rank_bitvector(nID);
irank += (*m_pBitVec)[nID];
map<string, int>::iterator itLut = m_lut.begin();
for (int i = 0; i < irank - 1; i++)
itLut++;
elementName = (*itLut).first;
return true;
}
bool CBvLookupTable::LabelSD(int nID, string& elementName)
{
if (nID >= m_nElements)
return false;
sd_vector<>::rank_1_type ranker(m_pSdVec);
int irank = ranker(nID);
irank += (*m_pBitVec)[nID];
map<string, int>::iterator itLut = m_lut.begin();
for (int i = 0; i < irank - 1; i++)
itLut++;
elementName = (*itLut).first;
return true;
}