projects
/
SXSI
/
XMLTree.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.
[SXSI/XMLTree.git]
/
libcds
/
src
/
static_sequence
/
static_sequence_wvtree.cpp
diff --git
a/libcds/src/static_sequence/static_sequence_wvtree.cpp
b/libcds/src/static_sequence/static_sequence_wvtree.cpp
index
ef504bd
..
ca93594
100644
(file)
--- a/
libcds/src/static_sequence/static_sequence_wvtree.cpp
+++ b/
libcds/src/static_sequence/static_sequence_wvtree.cpp
@@
-22,6
+22,7
@@
#include <static_sequence_wvtree.h>
static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
#include <static_sequence_wvtree.h>
static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
+ this->n = n;
for(uint i=0;i<n;i++)
symbols[i] = am->map(symbols[i]);
this->am = am;
for(uint i=0;i<n;i++)
symbols[i] = am->map(symbols[i]);
this->am = am;
@@
-34,13
+35,19
@@
static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder
}
static_sequence_wvtree::static_sequence_wvtree(uchar * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
}
static_sequence_wvtree::static_sequence_wvtree(uchar * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) {
+ this->n = n;
for(uint i=0;i<n;i++)
symbols[i] = (uchar)am->map((uint)symbols[i]);
this->am = am;
am->use();
this->c=c;
c->use();
for(uint i=0;i<n;i++)
symbols[i] = (uchar)am->map((uint)symbols[i]);
this->am = am;
am->use();
this->c=c;
c->use();
- root = new wt_node_internal(symbols, n, 0, c, bmb);
+ uint *done = new uint[n/W+1];
+ for (uint i = 0; i < n/W+1; i++)
+ done[i] = 0;
+ root = new wt_node_internal(symbols, n, 0, c, bmb, 0, done);
+ delete [] done;
+ delete [] symbols;
symbols = 0; // Already deleted!
// for(uint i=0;i<n;i++)
// symbols[i] = (uchar)am->unmap((uint)symbols[i]);
symbols = 0; // Already deleted!
// for(uint i=0;i<n;i++)
// symbols[i] = (uchar)am->unmap((uint)symbols[i]);
@@
-60,8
+67,8
@@
uint static_sequence_wvtree::rank(uint symbol, uint pos) {
uint static_sequence_wvtree::rankLessThan(uint &symbol, uint pos) {
uint s = am->map(symbol);
uint static_sequence_wvtree::rankLessThan(uint &symbol, uint pos) {
uint s = am->map(symbol);
- std::cout << "lessthan..." << std::endl;
- uint r = root->rankLessThan(s, pos
, 0, c
);
+
//
std::cout << "lessthan..." << std::endl;
+ uint r = root->rankLessThan(s, pos);
symbol = am->unmap(s);
return r;
}
symbol = am->unmap(s);
return r;
}
@@
-93,10
+100,10
@@
vector<int> static_sequence_wvtree::access(uint i, uint j, uint min, uint max)
vector<int> static_sequence_wvtree::accessAll(uint i, uint j)
{
vector<int> resultSet;
vector<int> static_sequence_wvtree::accessAll(uint i, uint j)
{
vector<int> resultSet;
- if (j
>
i)
+ if (j
<
i)
return resultSet;
return resultSet;
- resultSet.reserve(j-i+1);
+ // resultSet.reserve(j-i+1); // avoid reallocation
root->access(resultSet, i, j);
for (vector<int>::iterator it = resultSet.begin(); it != resultSet.end(); ++it)
*it = am->unmap(*it);
root->access(resultSet, i, j);
for (vector<int>::iterator it = resultSet.begin(); it != resultSet.end(); ++it)
*it = am->unmap(*it);