freelist.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SPOT_MISC_FREELIST_HH
00026 # define SPOT_MISC_FREELIST_HH
00027
00028 #include <list>
00029 #include <utility>
00030 #include <iosfwd>
00031
00032 namespace spot
00033 {
00034
00037 class free_list
00038 {
00039 public:
00040 virtual ~free_list();
00041
00047 int register_n(int n);
00048
00050 void release_n(int base, int n);
00051
00053 std::ostream& dump_free_list(std::ostream& os) const;
00054
00056 void insert(int base, int n);
00057
00059 void remove(int base, int n = 0);
00060
00062 int free_count() const;
00063
00064 protected:
00065
00073 virtual int extend(int n) = 0;
00074
00076 typedef std::pair<int, int> pos_lenght_pair;
00077 typedef std::list<pos_lenght_pair> free_list_type;
00078 free_list_type fl;
00079
00081 void remove(free_list_type::iterator i, int base, int n);
00082 };
00083
00084 }
00085
00086 #endif // SPOT_MISC_FREELIST_HH