3 // Copyright (C) 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
42 * Contains policies for list update containers.
50 struct move_to_front_lu_metadata
53 #define PB_ASSOC_CLASS_T_DEC \
54 template<typename Metadata_Reference>
56 #define PB_ASSOC_CLASS_C_DEC \
57 move_to_front_lu_policy<Metadata_Reference>
59 template<typename Metadata_Reference =
60 std::allocator<move_to_front_lu_metadata>::reference>
61 class move_to_front_lu_policy
65 swap(PB_ASSOC_CLASS_C_DEC& r_other);
68 typedef move_to_front_lu_metadata metadata_type;
70 typedef Metadata_Reference metadata_reference;
76 operator()(metadata_reference r_data) const;
79 #include <ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp>
81 #undef PB_ASSOC_CLASS_T_DEC
83 #undef PB_ASSOC_CLASS_C_DEC
85 template<typename Size_Type>
86 class counter_lu_policy_base;
88 template<typename Size_Type = size_t>
89 class counter_lu_metadata
92 typedef Size_Type size_type;
95 counter_lu_metadata(size_type init_count) : m_count(init_count)
98 mutable size_type m_count;
100 friend class counter_lu_policy_base<Size_Type>;
103 template<typename Size_Type>
104 class counter_lu_policy_base;
106 #define PB_ASSOC_CLASS_T_DEC \
107 template<typename Size_Type>
109 #define PB_ASSOC_CLASS_C_DEC \
110 counter_lu_policy_base<Size_Type>
112 template<typename Size_Type>
113 class counter_lu_policy_base
116 typedef Size_Type size_type;
118 counter_lu_metadata<Size_Type>
119 operator()(size_type max_size) const;
121 template<typename Metadata_Reference>
123 operator()(Metadata_Reference r_data, size_type m_max_count) const;
126 #include <ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp>
128 #undef PB_ASSOC_CLASS_T_DEC
130 #undef PB_ASSOC_CLASS_C_DEC
132 #define PB_ASSOC_CLASS_T_DEC \
133 template<typename Size_Type, typename Metadata_Reference>
135 #define PB_ASSOC_CLASS_C_DEC \
136 counter_lu_policy<Size_Type, Metadata_Reference>
138 template<typename Size_Type = size_t,
139 typename Metadata_Reference =
140 typename std::allocator<counter_lu_metadata<Size_Type> >::reference>
141 class counter_lu_policy : private counter_lu_policy_base<Size_Type>
144 typedef Size_Type size_type;
146 counter_lu_policy(size_type max_count = 5);
149 swap(PB_ASSOC_CLASS_C_DEC& r_other);
153 get_max_count() const;
157 typedef counter_lu_metadata< Size_Type> metadata_type;
159 typedef Metadata_Reference metadata_reference;
165 operator()(metadata_reference r_data) const;
168 typedef counter_lu_policy_base< Size_Type> my_base;
170 size_type m_max_count;
173 #include <ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp>
175 #undef PB_ASSOC_CLASS_T_DEC
177 #undef PB_ASSOC_CLASS_C_DEC
179 } // namespace pb_assoc
181 #endif // #ifndef LU_POLICY_HPP