1 /* static_bitsequence.h
2 * Copyright (C) 2008, Francisco Claude, all rights reserved.
4 * static_bitsequence definition
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
22 #ifndef _STATIC_BITSEQUENCE_H
23 #define _STATIC_BITSEQUENCE_H
27 #define RRR02_LIGHT_HDR 4
36 /** Base class for static bitsequences, contains many abstract functions, so this can't
37 * be instantiated. It includes base implementations for rank0, select0 and select1 based
40 * @author Francisco Claude
42 class static_bitsequence {
45 virtual ~static_bitsequence() {};
47 /** Returns the number of zeros until position i */
48 virtual uint rank0(uint i);
50 /** Returns the position of the i-th zero
51 * @return (uint)-1 if i=0, len if i>num_zeros or the position */
52 virtual uint select0(uint i);
54 /** Returns the number of ones until position i */
55 virtual uint rank1(uint i);
57 /** Returns the position of the i-th one
58 * @return (uint)-1 if i=0, len if i>num_ones or the position */
59 virtual uint select1(uint i);
61 /** Returns the i-th bit */
62 virtual bool access(uint i);
64 /** Returns the length in bits of the bitmap */
65 virtual uint length();
67 /** Returns how many ones are in the bitstring */
68 virtual uint count_one();
70 /** Returns how many zeros are in the bitstring */
71 virtual uint count_zero();
73 /** Returns the size of the structure in bytes */
74 virtual uint size()=0;
76 /** Stores the bitmap given a file pointer, return 0 in case of success */
77 virtual int save(FILE * fp)=0;
79 /** Reads a bitmap determining the type */
80 static static_bitsequence * load(FILE * fp);
83 /** Length of the bitstring */
85 /** Number of ones in the bitstring */
90 #include <static_bitsequence_rrr02.h>
91 #include <static_bitsequence_rrr02_light.h>
92 #include <static_bitsequence_naive.h>
93 #include <static_bitsequence_brw32.h>
94 #include <static_bitsequence_sdarray.h>
96 #endif /* _STATIC_BITSEQUENCE_H */