1 /*****************************************************************************
2 * Copyright (C) 2005, Rodrigo Gonzalez, all rights reserved. *
4 * New RANK, SELECT, SELECT-NEXT and SPARSE RANK implementations. *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19 ****************************************************************************/
30 static const unsigned wordShift = 5;
31 static const unsigned superFactor = 8; // 256 bit blocks
33 static const unsigned wordShift = 6;
34 static const unsigned superFactor = 4; // 256 bit blocks
37 ulong *data; //here is the bit-array
41 ulong *Rs; //superblock array
42 uchar *Rb; //block array
43 ulong BuildRankSub(ulong, ulong); //internal use of BuildRank
44 void BuildRank(); //crea indice para rank
46 BitRank(ulong *, ulong, bool);
47 ~BitRank(); //destructor
48 ulong rank(ulong i); //Rank from 0 to n-1
49 ulong select(ulong x); // gives the position of the x:th 1.
50 ulong select0(ulong x); // gives the position of the x:th 0.
52 bool IsBitSet(ulong i);