list_update_policy.hpp
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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PB_DS_LU_POLICY_HPP
00042 #define PB_DS_LU_POLICY_HPP
00043
00044 #include <cstdlib>
00045 #include <ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp>
00046
00047 namespace __gnu_pbds
00048 {
00049
00050
00051 struct null_lu_metadata
00052 { };
00053
00054 #define PB_DS_CLASS_T_DEC template<typename Allocator>
00055 #define PB_DS_CLASS_C_DEC move_to_front_lu_policy<Allocator>
00056
00057
00058
00059 template<typename Allocator = std::allocator<char> >
00060 class move_to_front_lu_policy
00061 {
00062 public:
00063 typedef Allocator allocator_type;
00064
00065
00066 typedef null_lu_metadata metadata_type;
00067
00068
00069 typedef typename allocator_type::template rebind<metadata_type>::other metadata_rebind;
00070 typedef typename metadata_rebind::reference metadata_reference;
00071
00072
00073 metadata_type
00074 operator()() const;
00075
00076
00077
00078 inline bool
00079 operator()(metadata_reference r_metadata) const;
00080
00081 private:
00082 static null_lu_metadata s_metadata;
00083 };
00084
00085 #include <ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp>
00086
00087 #undef PB_DS_CLASS_T_DEC
00088 #undef PB_DS_CLASS_C_DEC
00089
00090 #define PB_DS_CLASS_T_DEC template<size_t Max_Count, class Allocator>
00091 #define PB_DS_CLASS_C_DEC counter_lu_policy<Max_Count, Allocator>
00092
00093
00094
00095 template<size_t Max_Count = 5, typename Allocator = std::allocator<char> >
00096 class counter_lu_policy
00097 : private detail::counter_lu_policy_base<typename Allocator::size_type>
00098 {
00099 public:
00100 typedef Allocator allocator_type;
00101
00102 enum
00103 {
00104 max_count = Max_Count
00105 };
00106
00107 typedef typename allocator_type::size_type size_type;
00108
00109
00110 typedef detail::counter_lu_metadata<size_type> metadata_type;
00111
00112
00113 typedef typename Allocator::template rebind<metadata_type>::other metadata_rebind;
00114 typedef typename metadata_rebind::reference metadata_reference;
00115
00116
00117 metadata_type
00118 operator()() const;
00119
00120
00121
00122 bool
00123 operator()(metadata_reference r_metadata) const;
00124
00125 private:
00126 typedef detail::counter_lu_policy_base<typename Allocator::size_type> base_type;
00127 };
00128
00129 #include <ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp>
00130
00131 #undef PB_DS_CLASS_T_DEC
00132 #undef PB_DS_CLASS_C_DEC
00133
00134 }
00135
00136 #endif