2 * Copyright (C) 2005, Diego Arroyuelo, all rights reserved.
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
26 #include <static_bitsequence.h>
27 #include <static_bitsequence_builder.h>
31 uint *elems; // elements of the permutation
32 uint nelems; // # of elements
33 static_bitsequence * bmap; // bitmap allowing rank() queries in O(1) time
34 uint *bwdptrs; // array of backward pointers
35 uint nbits; // log(nelems)
36 uint nbwdptrs; // # of backward pointers
46 /** Creates a permutation
48 * @author Diego Arroyuelo
50 perm createPerm(uint *elems, uint nelems, uint t, static_bitsequence_builder * bmb);
52 /** Gets the i-th element of the permutation
54 * @author Diego Arroyuelo
56 uint getelemPerm(perm P, uint i);
58 /** Destroys a permutation
60 * @author Diego Arroyuelo
62 void destroyPerm(perm P);
66 * @author Diego Arroyuelo
68 uint inversePerm(perm P, uint i);
70 /** Saves a permutation
72 * @author Diego Arroyuelo
74 uint savePerm(perm P, FILE *f);
76 /** Loads a permutation
78 * @author Diego Arroyuelo
80 perm loadPerm(FILE *f);
82 /** Returns the size of the data structure
84 * @author Diego Arroyuelo
86 uint sizeofPerm(perm P);