Import libcds.
[SXSI/libcds.git] / src / static_bitsequence / static_bitsequence_naive.h
1 /* static_bitsequence_naive.h
2  * Copyright (C) 2008, Francisco Claude, all rights reserved.
3  *
4  * Naive Bitsequence - don't use, only for testing
5  *
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.
10  *
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.
15  *
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  *
20  */
21
22
23 #ifndef _STATIC_BITSEQUENCE_NAIVE_H
24 #define _STATIC_BITSEQUENCE_NAIVE_H
25
26 #include <static_bitsequence.h>
27
28 /** Class used for testing, should not be used with long bitmaps
29  *  @author Francisco Claude
30  */
31 class static_bitsequence_naive: public static_bitsequence {
32 public:
33   /** Builds a naive bitsequence, receives the bitmap and the length
34    *  in bits
35    */
36   static_bitsequence_naive(uint * bitseq, uint len);
37   
38   virtual ~static_bitsequence_naive();
39   
40   /** Returns the number of ones until position i */
41   virtual uint rank1(uint i);
42   
43   /** Returns the position of the i-th one 
44    * @return (uint)-1 if i=0, len if i>num_ones or the position */
45   virtual uint select1(uint i);
46   
47   /** Returns the i-th bit */
48   virtual bool access(uint i);
49   
50   /** Returns the size of the structure in bytes */
51   virtual uint size();
52   
53   /** - Not implemented - */
54         virtual int save(FILE * fp);
55   
56   
57 protected:
58   uint * bitseq;
59 };
60
61 #endif  /* _STATIC_BITSEQUENCE_NAIVE_H */
62