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
00034 class free_list
00035 {
00036 public:
00037 virtual ~free_list();
00038
00044 int register_n(int n);
00045
00047 void release_n(int base, int n);
00048
00050 std::ostream& dump_free_list(std::ostream& os) const;
00051
00053 void insert(int base, int n);
00054
00056 void remove(int base, int n = 0);
00057
00059 int free_count() const;
00060
00061 protected:
00062
00070 virtual int extend(int n) = 0;
00071
00073 typedef std::pair<int, int> pos_lenght_pair;
00074 typedef std::list<pos_lenght_pair> free_list_type;
00075 free_list_type fl;
00076
00078 void remove(free_list_type::iterator i, int base, int n);
00079 };
00080
00081 }
00082
00083 #endif // SPOT_MISC_FREELIST_HH