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