Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

vector_transient.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 
13 #include <immer/memory_policy.hpp>
14 
15 namespace immer {
16 
17 template <typename T,
18  typename MemoryPolicy,
21 class vector;
22 
23 template <typename T,
24  typename MemoryPolicy,
27 class flex_vector_transient;
28 
39 template <typename T,
40  typename MemoryPolicy = default_memory_policy,
42  detail::rbts::bits_t BL = detail::rbts::derive_bits_leaf<T, MemoryPolicy, B>>
43 class vector_transient
44  : MemoryPolicy::transience_t::owner
45 {
48  using owner_t = typename MemoryPolicy::transience_t::owner;
49 
50 public:
51  static constexpr auto bits = B;
52  static constexpr auto bits_leaf = BL;
53  using memory_policy = MemoryPolicy;
54 
55  using value_type = T;
56  using reference = const T&;
58  using difference_type = std::ptrdiff_t;
59  using const_reference = const T&;
60 
63  using reverse_iterator = std::reverse_iterator<iterator>;
64 
66 
72  vector_transient() = default;
73 
79  iterator begin() const { return {impl_}; }
80 
85  iterator end() const { return {impl_, typename iterator::end_t{}}; }
86 
93 
100 
105  size_type size() const { return impl_.size; }
106 
111  bool empty() const { return impl_.size == 0; }
112 
120  { return impl_.get(index); }
121 
128  reference at(size_type index) const
129  { return impl_.get_check(index); }
130 
135  void push_back(value_type value)
136  { impl_.push_back_mut(*this, std::move(value)); }
137 
144  void set(size_type index, value_type value)
145  { impl_.assoc_mut(*this, index, std::move(value)); }
146 
154  template <typename FnT>
155  void update(size_type index, FnT&& fn)
156  { impl_.update_mut(*this, index, std::forward<FnT>(fn)); }
157 
163  void take(size_type elems)
164  { impl_.take_mut(*this, elems); }
165 
171  {
172  this->owner_t::operator=(owner_t{});
173  return persistent_type{ impl_ };
174  }
176  { return persistent_type{ std::move(impl_) }; }
177 
178 private:
179  friend flex_t;
181 
183  : impl_(std::move(impl))
184  {}
185 
187 };
188 
189 } // namespace immer
const auto default_bits
Definition: config.hpp:63
persistent_type persistent() &
const T & get(size_t index) const
Definition: rbtree.hpp:368
void update(size_type index, FnT &&fn)
void assoc_mut(edit_t e, size_t idx, T value)
Definition: rbtree.hpp:413
std::reverse_iterator< iterator > reverse_iterator
reference at(size_type index) const
std::size_t size_t
Definition: bits.hpp:20
Definition: box.hpp:161
detail::rbts::rbtree_iterator< T, MemoryPolicy, B, BL > iterator
void take(size_type elems)
static const rbtree & empty()
Definition: rbtree.hpp:40
detail::rbts::size_t size_type
memory_policy< default_heap_policy, default_refcount_policy > default_memory_policy
reverse_iterator rend() const
reference operator[](size_type index) const
const T & get_check(size_t index) const
Definition: rbtree.hpp:373
std::uint32_t bits_t
Definition: bits.hpp:17
void push_back(value_type value)
typename MemoryPolicy::transience_t::owner owner_t
void take_mut(edit_t e, size_t new_size)
Definition: rbtree.hpp:455
void push_back_mut(edit_t e, T value)
Definition: rbtree.hpp:267
persistent_type persistent() &&
static constexpr auto bits_leaf
void update_mut(edit_t e, size_t idx, FnT &&fn)
Definition: rbtree.hpp:391
static constexpr auto bits
reverse_iterator rbegin() const
std::ptrdiff_t difference_type
Released under the MIT license