Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

set.hpp
Go to the documentation of this file.
1 //
2 // immer: immutable data structures for C++
3 // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
4 //
5 // This software is distributed under the Boost Software License, Version 1.0.
6 // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
7 //
8 
9 #pragma once
10 
11 #include <immer/memory_policy.hpp>
14 
15 #include <functional>
16 
17 namespace immer {
18 
19 template <typename T,
20  typename Hash,
21  typename Equal,
22  typename MemoryPolicy,
25 
56 template <typename T,
57  typename Hash = std::hash<T>,
58  typename Equal = std::equal_to<T>,
59  typename MemoryPolicy = default_memory_policy,
61 class set
62 {
64 
65 public:
66  using key_type = T;
67  using value_type = T;
69  using diference_type = std::ptrdiff_t;
70  using hasher = Hash;
71  using key_equal = Equal;
72  using reference = const T&;
73  using const_reference = const T&;
74 
76  MemoryPolicy, B>;
78 
80 
85  set() = default;
86 
92  iterator begin() const { return {impl_}; }
93 
98  iterator end() const { return {impl_, typename iterator::end_t{}}; }
99 
104  size_type size() const { return impl_.size; }
105 
111  size_type count(const T& value) const
112  { return impl_.template get<detail::constantly<size_type, 1>,
114 
118  bool operator==(const set& other) const
119  { return impl_.equals(other.impl_); }
120  bool operator!=(const set& other) const
121  { return !(*this == other); }
122 
128  set insert(T value) const
129  { return impl_.add(std::move(value)); }
130 
136  set erase(const T& value) const
137  { return impl_.sub(value); }
138 
143  transient_type transient() const&
144  { return transient_type{ impl_ }; }
145  transient_type transient() &&
146  { return transient_type{ std::move(impl_) }; }
147 
148  // Semi-private
149  const impl_t& impl() const { return impl_; }
150 
151 private:
153 
155  : impl_(std::move(impl))
156  {}
157 
159 };
160 
161 } // namespace immer
static const champ & empty()
Definition: champ.hpp:37
const auto default_bits
Definition: config.hpp:63
const T & const_reference
Definition: set.hpp:73
Hash hasher
Definition: set.hpp:70
set insert(T value) const
Definition: set.hpp:128
size_type size() const
Definition: set.hpp:104
std::uint32_t bits_t
Definition: bits.hpp:23
champ add(T v) const
Definition: champ.hpp:219
std::size_t size_t
Definition: bits.hpp:21
bool operator==(const set &other) const
Definition: set.hpp:118
memory_policy< default_heap_policy, default_refcount_policy > default_memory_policy
champ sub(const K &k) const
Definition: champ.hpp:407
const T & reference
Definition: set.hpp:72
set erase(const T &value) const
Definition: set.hpp:136
detail::hamts::size_t size_type
Definition: set.hpp:68
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
Definition: hash.h:84
Equal key_equal
Definition: set.hpp:71
bool operator!=(const set &other) const
Definition: set.hpp:120
iterator begin() const
Definition: set.hpp:92
iterator end() const
Definition: set.hpp:98
bool equals(const champ &other) const
Definition: champ.hpp:425
size_type count(const T &value) const
Definition: set.hpp:111
detail::hamts::champ_iterator< T, Hash, Equal, MemoryPolicy, B > iterator
Definition: set.hpp:76
T value_type
Definition: set.hpp:67
friend transient_type
Definition: set.hpp:152
const impl_t & impl() const
Definition: set.hpp:149
std::ptrdiff_t diference_type
Definition: set.hpp:69
impl_t impl_
Definition: set.hpp:158
T key_type
Definition: set.hpp:66
Released under the MIT license