-
+/* static_sequence_wvtree.cpp
+ * Copyright (C) 2008, Francisco Claude, all rights reserved.
+ *
+ * static_sequence_wvtree definition
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
#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) {
for(uint i=0;i<n;i++)
symbols[i] = am->map(symbols[i]);
this->am = am;
+ am->use();
this->c=c;
- cout << "Building..."; cout.flush();
+ c->use();
root = new wt_node_internal(symbols, n, 0, c, bmb);
- cout << "done" << endl; cout.flush();
for(uint i=0;i<n;i++)
symbols[i] = am->unmap(symbols[i]);
}
static_sequence_wvtree::static_sequence_wvtree() {}
-
static_sequence_wvtree::~static_sequence_wvtree() {
delete root;
- delete am;
- delete c;
+ am->unuse();
+ c->unuse();
}
uint static_sequence_wvtree::rank(uint symbol, uint pos) {
static_sequence_wvtree * ret = new static_sequence_wvtree();
if(fread(&ret->n,sizeof(uint),1,fp)!=1) return NULL;
ret->c = wt_coder::load(fp);
+ ret->c->use();
ret->am = alphabet_mapper::load(fp);
+ ret->am->use();
ret->root = wt_node::load(fp);
return ret;
}
-