1e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// -*- C++ -*-
2e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
3e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
4e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh//
5e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// This file is part of the GNU ISO C++ Library.  This library is free
6e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// software; you can redistribute it and/or modify it under the terms
7e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// of the GNU General Public License as published by the Free Software
8e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Foundation; either version 3, or (at your option) any later
9e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// version.
10e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
11e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// This library is distributed in the hope that it will be useful, but
12e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// WITHOUT ANY WARRANTY; without even the implied warranty of
13e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// General Public License for more details.
15e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
16e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Under Section 7 of GPL version 3, you are granted additional
17e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// permissions described in the GCC Runtime Library Exception, version
18e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// 3.1, as published by the Free Software Foundation.
19e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
20e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// You should have received a copy of the GNU General Public License and
21e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// a copy of the GCC Runtime Library Exception along with this program;
22e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// <http://www.gnu.org/licenses/>.
24e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
25e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
26e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
27e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Permission to use, copy, modify, sell, and distribute this software
28e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// is hereby granted without fee, provided that the above copyright
29e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// notice appears in all copies, and that both that copyright notice
30e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// and this permission notice appear in supporting documentation. None
31e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// of the above authors, nor IBM Haifa Research Laboratories, make any
32e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// representation about the suitability of this software for any
33e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// purpose. It is provided "as is" without express or implied
34e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// warranty.
35e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
36e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh/**
37e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * @file standard_policies.hpp
38e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Contains standard policies for containers.
39e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh */
40e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
41e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#ifndef PB_DS_STANDARD_POLICIES_HPP
42e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#define PB_DS_STANDARD_POLICIES_HPP
43e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
44e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <memory>
45e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/hash_policy.hpp>
46e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/list_update_policy.hpp>
47e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/tree_policy.hpp>
48e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
49e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/trie_policy.hpp>
50e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <ext/pb_ds/tag_and_trait.hpp>
51e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#include <tr1/functional>
52e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
53e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehnamespace __gnu_pbds
54e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh{
55e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh  namespace detail
56e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh  {
57e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Key>
58e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_hash_fn
59e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
60e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef std::tr1::hash<Key> type;
61e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
62e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
63e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Key>
64e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_eq_fn
65e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
66e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef std::equal_to<Key> type;
67e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
68e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
69e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    enum
70e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      {
71e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh	default_store_hash = false
72e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      };
73e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
74e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_comb_hash_fn
75e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
76e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::direct_mask_range_hashing<> type;
77e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
78e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
79e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Comb_Hash_Fn>
80e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_resize_policy
81e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
82e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    private:
83e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef typename Comb_Hash_Fn::size_type size_type;
84e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
85e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::direct_mask_range_hashing<size_type> default_fn;
86e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef is_same<default_fn, Comb_Hash_Fn> same_type;
87e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::hash_exponential_size_policy<size_type> iftrue;
88e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::hash_prime_size_policy iffalse;
89e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type;
90e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef typename cond_type::__type size_policy_type;
91e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
92e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::hash_load_check_resize_trigger<false, size_type> trigger;
93e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
94e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    public:
95e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::hash_standard_resize_policy<size_policy_type, trigger, false, size_type> type;
96e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
97e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
98e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_update_policy
99e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
100e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::move_to_front_lu_policy<> type;
101e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
102e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
103e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Comb_Probe_Fn>
104e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_probe_fn
105e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
106e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    private:
107e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef typename Comb_Probe_Fn::size_type size_type;
108e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
109e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::direct_mask_range_hashing<size_type> default_fn;
110e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef is_same<default_fn, Comb_Probe_Fn> same_type;
111e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::linear_probe_fn<size_type> iftrue;
112e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::quadratic_probe_fn<size_type> iffalse;
113e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type;
114e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
115e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    public:
116e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef typename cond_type::__type type;
117e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
118e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
119e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Key>
120e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_trie_e_access_traits;
121e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
122e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    template<typename Char, class Char_Traits>
123e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    struct default_trie_e_access_traits<std::basic_string<Char, Char_Traits, std::allocator<char> > >
124e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    {
125e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    private:
126e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef std::basic_string<Char, Char_Traits, std::allocator<char> > string_type;
127e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
128e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    public:
129e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh      typedef __gnu_pbds::string_trie_e_access_traits<string_type> type;
130e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh    };
131e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
132e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh  } // namespace detail
133e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} // namespace __gnu_pbds
134e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
135e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#endif // #ifndef PB_DS_STANDARD_POLICIES_HPP
136e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh
137