00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef SPOT_MISC_FREELIST_HH
00024
# define SPOT_MISC_FREELIST_HH
00025
00026
#include <list>
00027
#include <utility>
00028
00029
namespace spot
00030 {
00031
00033 class free_list
00034 {
00035
public:
00036
virtual ~free_list();
00037
00043
int register_n(
int n);
00044
00046
void release_n(
int base,
int n);
00047
00049 std::ostream&
dump_free_list(std::ostream& os)
const;
00050
00052
void insert(
int base,
int n);
00053
00055
void remove(
int base,
int n = 0);
00056
00057
protected:
00058
00066
virtual int extend(
int n) = 0;
00067
00069 typedef std::pair<int, int>
pos_lenght_pair;
00070 typedef std::list<pos_lenght_pair>
free_list_type;
00071 free_list_type fl;
00072
00074
void remove(free_list_type::iterator i,
int base,
int n);
00075 };
00076
00077 }
00078
00079
#endif // SPOT_MISC_FREELIST_HH