OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [ext/] [pb_assoc/] [lu_policy.hpp] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// -*- C++ -*-
2
 
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.
10
 
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.
15
 
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.
20
 
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.
29
 
30
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
31
 
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.
39
 
40
/**
41
 * @file lu_policy.hpp
42
 * Contains policies for list update containers.
43
 */
44
 
45
#ifndef LU_POLICY_HPP
46
#define LU_POLICY_HPP
47
 
48
namespace pb_assoc
49
{
50
  struct move_to_front_lu_metadata
51
  { };
52
 
53
#define PB_ASSOC_CLASS_T_DEC \
54
        template<typename Metadata_Reference>
55
 
56
#define PB_ASSOC_CLASS_C_DEC \
57
        move_to_front_lu_policy<Metadata_Reference>
58
 
59
  template<typename Metadata_Reference =
60
           std::allocator<move_to_front_lu_metadata>::reference>
61
    class move_to_front_lu_policy
62
    {
63
    public:
64
      void
65
      swap(PB_ASSOC_CLASS_C_DEC& r_other);
66
 
67
    protected:
68
      typedef move_to_front_lu_metadata metadata_type;
69
 
70
      typedef Metadata_Reference metadata_reference;
71
 
72
      metadata_type
73
      operator()() const;
74
 
75
      inline bool
76
      operator()(metadata_reference r_data) const;
77
    };
78
 
79
#include <ext/pb_assoc/detail/lu_policy/mtf_lu_policy_imp.hpp>
80
 
81
#undef PB_ASSOC_CLASS_T_DEC
82
 
83
#undef PB_ASSOC_CLASS_C_DEC
84
 
85
  template<typename Size_Type>
86
    class counter_lu_policy_base;
87
 
88
  template<typename Size_Type = size_t>
89
    class counter_lu_metadata
90
    {
91
    public:
92
      typedef Size_Type size_type;
93
 
94
  private:
95
      counter_lu_metadata(size_type init_count) : m_count(init_count)
96
      { }
97
 
98
      mutable size_type m_count;
99
 
100
      friend class counter_lu_policy_base<Size_Type>;
101
    };
102
 
103
  template<typename Size_Type>
104
    class counter_lu_policy_base;
105
 
106
#define PB_ASSOC_CLASS_T_DEC \
107
        template<typename Size_Type>
108
 
109
#define PB_ASSOC_CLASS_C_DEC \
110
        counter_lu_policy_base<Size_Type>
111
 
112
  template<typename Size_Type>
113
    class counter_lu_policy_base
114
    {
115
    protected:
116
      typedef Size_Type size_type;
117
 
118
    counter_lu_metadata<Size_Type>
119
    operator()(size_type max_size) const;
120
 
121
    template<typename Metadata_Reference>
122
      bool
123
      operator()(Metadata_Reference r_data, size_type m_max_count) const;
124
    };
125
 
126
#include <ext/pb_assoc/detail/lu_policy/counter_lu_metadata_imp.hpp>
127
 
128
#undef PB_ASSOC_CLASS_T_DEC
129
 
130
#undef PB_ASSOC_CLASS_C_DEC
131
 
132
#define PB_ASSOC_CLASS_T_DEC \
133
        template<typename Size_Type, typename Metadata_Reference>
134
 
135
#define PB_ASSOC_CLASS_C_DEC \
136
        counter_lu_policy<Size_Type, Metadata_Reference>
137
 
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>
142
    {
143
    public:
144
      typedef Size_Type size_type;
145
 
146
      counter_lu_policy(size_type max_count = 5);
147
 
148
      void
149
      swap(PB_ASSOC_CLASS_C_DEC& r_other);
150
 
151
      inline
152
      size_type
153
      get_max_count() const;
154
 
155
    protected:
156
 
157
      typedef counter_lu_metadata< Size_Type> metadata_type;
158
 
159
      typedef Metadata_Reference metadata_reference;
160
 
161
      metadata_type
162
      operator()() const;
163
 
164
      bool
165
      operator()(metadata_reference r_data) const;
166
 
167
    private:
168
      typedef counter_lu_policy_base< Size_Type> my_base;
169
 
170
      size_type m_max_count;
171
    };
172
 
173
#include <ext/pb_assoc/detail/lu_policy/counter_lu_policy_imp.hpp>
174
 
175
#undef PB_ASSOC_CLASS_T_DEC
176
 
177
#undef PB_ASSOC_CLASS_C_DEC
178
 
179
} // namespace pb_assoc
180
 
181
#endif // #ifndef LU_POLICY_HPP

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.