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 ****************************************************************************/
24 #include "BlockArray.h"
31 static const unsigned wordShift = 5;
32 static const unsigned superFactor = 8; // 256 bit blocks
34 static const unsigned wordShift = 6;
35 static const unsigned superFactor = 4; // 256 bit blocks
37 static const unsigned s = W*superFactor;
39 ulong *data; //here is the bit-array
42 BlockArray *Rs; //superblock array
43 uchar *Rb; //block array
44 ulong BuildRankSub(ulong, ulong); //internal use of BuildRank
45 void BuildRank(); //crea indice para rank
47 BitRank(ulong *, ulong, bool);
49 ~BitRank(); //destructor
51 ulong rank(ulong i); //Rank from 0 to n-1
52 ulong select(ulong x); // gives the position of the x:th 1.
53 ulong select0(ulong x); // gives the position of the x:th 0.
55 bool IsBitSet(ulong i);