Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / include / ext / pb_assoc / lu_policy.hpp
blobdcdb0e5ac05b360e6dad99325a2dcafce631f753
1 // -*- C++ -*-
3 // Copyright (C) 2005 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
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,
19 // USA.
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.
40 /**
41 * @file lu_policy.hpp
42 * Contains policies for list update containers.
45 #ifndef LU_POLICY_HPP
46 #define LU_POLICY_HPP
48 namespace pb_assoc
50 struct move_to_front_lu_metadata
51 { };
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
63 public:
64 void
65 swap(PB_ASSOC_CLASS_C_DEC& r_other);
67 protected:
68 typedef move_to_front_lu_metadata metadata_type;
70 typedef Metadata_Reference metadata_reference;
72 metadata_type
73 operator()() const;
75 inline bool
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
91 public:
92 typedef Size_Type size_type;
94 private:
95 counter_lu_metadata(size_type init_count) : m_count(init_count)
96 { }
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
115 protected:
116 typedef Size_Type size_type;
118 counter_lu_metadata<Size_Type>
119 operator()(size_type max_size) const;
121 template<typename Metadata_Reference>
122 bool
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>
143 public:
144 typedef Size_Type size_type;
146 counter_lu_policy(size_type max_count = 5);
148 void
149 swap(PB_ASSOC_CLASS_C_DEC& r_other);
151 inline
152 size_type
153 get_max_count() const;
155 protected:
157 typedef counter_lu_metadata< Size_Type> metadata_type;
159 typedef Metadata_Reference metadata_reference;
161 metadata_type
162 operator()() const;
164 bool
165 operator()(metadata_reference r_data) const;
167 private:
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