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