13 #ifndef STXXL_PAGER_HEADER
14 #define STXXL_PAGER_HEADER
18 #include <stxxl/bits/noncopyable.h>
19 #include <stxxl/bits/common/rand.h>
20 #include <stxxl/bits/common/simple_vector.h>
21 #include <stxxl/bits/compat_auto_ptr.h>
24 __STXXL_BEGIN_NAMESPACE
36 template <
unsigned npages_>
42 enum { n_pages = npages_ };
49 void hit(int_type ipage)
51 assert(ipage < int_type(npages_));
57 template <
unsigned npages_>
60 typedef std::list<int_type> list_type;
62 compat_auto_ptr<list_type>::result history;
63 simple_vector<list_type::iterator> history_entry;
66 enum { n_pages = npages_ };
68 lru_pager() : history(
new list_type), history_entry(npages_)
70 for (unsigned_type i = 0; i < npages_; i++)
71 history_entry[i] = history->insert(history->end(),
static_cast<int_type
>(i));
76 return history->back();
78 void hit(int_type ipage)
80 assert(ipage < int_type(npages_));
82 history->splice(history->begin(), *history, history_entry[ipage]);
88 compat_auto_ptr<list_type>::result tmp = obj.history;
89 obj.history = history;
91 std::swap(history_entry, obj.history_entry);
101 template <
unsigned npages_>
102 void swap(stxxl::lru_pager<npages_> & a,
103 stxxl::lru_pager<npages_> & b)
109 #endif // !STXXL_PAGER_HEADER