1 /***************************************************************************
2 * Copyright (C) 2007 by Veli Mäkinen *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
22 * Wavelet tree by Veli Mäkinen,
25 #ifndef _RLWAVELETTREE_H_
26 #define _RLWAVELETTREE_H_
27 #include "GapEncode.h"
35 ulong *leaves; // stores the leaf positions of characters 0..2^maxlevel-1
38 void remapAlphabet(uchar*, ulong);
40 ulong prevRunLen; // Used by charAtPosRun()
45 RLWaveletTree(uchar *, ulong);
46 RLWaveletTree(FILE *);
49 void Save(FILE *) const;
50 ulong rank(ulong c, ulong i);
52 ulong select(ulong c, ulong j);
54 bool IsCharAtPos(ulong c, ulong i);
56 ulong charAtPos(ulong i);
57 ulong charAtPos(ulong i, ulong *rank);
58 ulong charAtPosRun(ulong i, ulong *rank);
59 double spaceInBits() {
60 return 0; // Not implemented