14 #ifndef STXXL_PAGER_HEADER
15 #define STXXL_PAGER_HEADER
20 #include <stxxl/bits/noncopyable.h>
21 #include <stxxl/bits/common/rand.h>
22 #include <stxxl/bits/common/simple_vector.h>
25 __STXXL_BEGIN_NAMESPACE
37 template <
unsigned npages_>
43 enum { n_pages = npages_ };
49 void hit(int_type ipage)
51 assert(ipage < int_type(npages_));
57 template <
unsigned npages_ = 0>
60 typedef unsigned_type size_type;
61 typedef std::list<size_type> list_type;
64 simple_vector<list_type::iterator> history_entry;
67 enum { n_pages = npages_ };
71 for (size_type i = 0; i < n_pages; ++i)
72 history_entry[i] = history.insert(history.end(), i);
77 return history.back();
80 void hit(size_type ipage)
82 assert(ipage < n_pages);
83 history.splice(history.begin(), history, history_entry[ipage]);
88 history.swap(obj.history);
89 history_entry.swap(obj.history_entry);
97 typedef unsigned_type size_type;
98 typedef std::list<size_type> list_type;
102 simple_vector<list_type::iterator> history_entry;
105 lru_pager(size_type npages_ = 0) : n_pages(npages_), history_entry(n_pages)
107 for (size_type i = 0; i < n_pages; ++i)
108 history_entry[i] = history.insert(history.end(), i);
113 return history.back();
116 void hit(size_type ipage)
118 assert(ipage < n_pages);
119 history.splice(history.begin(), history, history_entry[ipage]);
124 std::swap(n_pages, obj.n_pages);
125 history.swap(obj.history);
126 history_entry.swap(obj.history_entry);
132 __STXXL_END_NAMESPACE
136 template <
unsigned npages_>
137 void swap(stxxl::lru_pager<npages_> & a,
138 stxxl::lru_pager<npages_> & b)
144 #endif // !STXXL_PAGER_HEADER
Pager with random replacement strategy.
Definition: pager.h:38