testing
[SXSI/XMLTree.git] / libcds / src / static_sequence / static_sequence.h
1 /* static_sequence.h
2  * Copyright (C) 2008, Francisco Claude, all rights reserved.
3  *
4  * static_sequence definition
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 #ifndef _STATIC_SEQUENCE_H
23 #define _STATIC_SEQUENCE_H
24
25
26 #include <basics.h>
27 #include <iostream>
28
29 #define WVTREE_HDR 2
30
31 using namespace std;
32
33 /** Base class for static sequences, contains many abstract functions, so this can't
34  *  be instantiated. 
35  * 
36  *  @author Francisco Claude
37  */
38 class static_sequence {
39   
40 public:
41   static_sequence();
42   virtual ~static_sequence();
43
44   /** Returns the number of occurrences of c until position i */
45   virtual uint rank(uint c, uint i)=0;
46
47   /** Returns the position of the i-th c 
48    * @return (uint)-1 if i=0, len if i exceeds the number of cs */
49   virtual uint select(uint c, uint i)=0;
50
51   /** Returns the i-th element */
52   virtual uint access(uint i)=0;
53
54   /** Returns the length of the sequence */
55   virtual uint length();
56
57   /** Returns how many cs are in the sequence */
58   virtual uint count(uint c)=0;
59
60   /** Returns the size of the structure in bytes */
61   virtual uint size()=0;
62
63   /** Stores the bitmap given a file pointer, return 0 in case of success */
64   virtual uint save(FILE * fp)=0;
65   
66   /** Reads a bitmap determining the type */
67   static static_sequence * load(FILE * fp);
68   
69 protected:
70   /** Length of the bitstring */
71   uint len;
72   
73 };
74
75 #include <static_sequence_wvtree.h>
76
77 #endif  /* _STATIC_SEQUENCE_H */