2 * Copyright (C) 2008, Francisco Claude, all rights reserved.
4 * static_sequence 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_SEQUENCE_H
23 #define _STATIC_SEQUENCE_H
30 #define GMR_CHUNK_HDR 3
32 #define WVTREE_NOPTRS_HDR 5
36 /** Base class for static sequences, contains many abstract functions, so this can't
39 * @author Francisco Claude
41 class static_sequence {
45 virtual ~static_sequence();
47 /** Returns the number of occurrences of c until position i */
48 virtual uint rank(uint c, uint i)=0;
49 virtual uint rankLessThan(uint &i, uint j)
51 //assert(0); // Implemented only in static_sequence_wvtree
55 /** Returns the position of the i-th c
56 * @return (uint)-1 if i=0, len if i exceeds the number of cs */
57 virtual uint select(uint c, uint i)=0;
59 /** Returns the i-th element */
60 virtual uint access(uint i)=0;
61 virtual uint access(uint i, uint &rank)
63 //assert(0); // Implemented only in static_sequence_wvtree
68 /** Returns the length of the sequence */
69 virtual uint length();
71 /** Returns how many cs are in the sequence */
72 virtual uint count(uint c);
74 /** Returns the size of the structure in bytes */
75 virtual uint size()=0;
77 /** Stores the bitmap given a file pointer, return 0 in case of success */
78 virtual uint save(FILE * fp)=0;
80 virtual bool test(uint * seq, uint n);
82 /** Reads a bitmap determining the type */
83 static static_sequence * load(FILE * fp);
86 /** Length of the bitstring */
91 #include <static_sequence_wvtree.h>
92 #include <static_sequence_gmr_chunk.h>
93 #include <static_sequence_wvtree_noptrs.h>
94 #include <static_sequence_gmr.h>
96 #endif /* _STATIC_SEQUENCE_H */