Vcsn  2.2
Be Rational
vector.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <algorithm>
4 #include <vector>
5 
6 #include <boost/range/algorithm/find.hpp>
7 
9 #include <vcsn/misc/functional.hh> // hash_combine
10 #include <vcsn/misc/tuple.hh> // make_index_sequence.
11 
12 namespace vcsn
13 {
14 
15  namespace detail
16  {
18  template <typename Cont>
19  std::vector<typename Cont::value_type>
20  make_vector(const Cont& cont)
21  {
22  using std::begin;
23  using std::end;
24  return {begin(cont), end(cont)};
25  }
26  }
27 
29  template <typename T, typename Alloc>
30  ATTRIBUTE_PURE
31  bool
32  has(const std::vector<T, Alloc>& s, const T& e)
33  {
34  return boost::find(s, e) != std::end(s);
35  }
36 }
37 
38 namespace std
39 {
40  template <typename T, typename Alloc>
41  struct hash<vector<T, Alloc>>
42  {
43  size_t operator()(const std::vector<T, Alloc>& vs) const
44  {
45  auto res = size_t{0};
46  for (const auto& v: vs)
47  vcsn::hash_combine(res, v);
48  return res;
49  }
50  };
51 }
Definition: a-star.hh:8
STL namespace.
void hash_combine(std::size_t &seed, const T &v)
Definition: functional.hh:32
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
Definition: vector.hh:20
size_t operator()(const std::vector< T, Alloc > &vs) const
Definition: vector.hh:43
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
Definition: setalpha.hh:25