Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

flex_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 flex_vector;
22 
23 template <typename T,
24  typename MemoryPolicy,
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>>
44  : MemoryPolicy::transience_t::owner
45 {
47  using base_t = typename MemoryPolicy::transience_t::owner;
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 
71  flex_vector_transient() = default;
72 
79  : base_t { std::move(static_cast<base_t&>(v)) }
80  , impl_ { v.impl_.size, v.impl_.shift,
81  v.impl_.root->inc(), v.impl_.tail->inc() }
82  {}
83 
89  iterator begin() const { return {impl_}; }
90 
95  iterator end() const { return {impl_, typename iterator::end_t{}}; }
96 
103 
110 
115  size_type size() const { return impl_.size; }
116 
121  bool empty() const { return impl_.size == 0; }
122 
130  { return impl_.get(index); }
131 
138  reference at(size_type index) const
139  { return impl_.get_check(index); }
140 
145  void push_back(value_type value)
146  { impl_.push_back_mut(*this, std::move(value)); }
147 
154  void set(size_type index, value_type value)
155  { impl_.assoc_mut(*this, index, std::move(value)); }
156 
164  template <typename FnT>
165  void update(size_type index, FnT&& fn)
166  { impl_.update_mut(*this, index, std::forward<FnT>(fn)); }
167 
173  void take(size_type elems)
174  { impl_.take_mut(*this, elems); }
175 
181  void drop(size_type elems)
182  { impl_.drop_mut(*this, elems); }
183 
189  {
190  this->owner_t::operator=(owner_t{});
191  return persistent_type{ impl_ };
192  }
194  { return persistent_type{ std::move(impl_) }; }
195 
202  {
203  r.owner_t::operator=(owner_t{});
204  concat_mut_l(impl_, *this, r.impl_);
205  }
207  { concat_mut_lr_l(impl_, *this, r.impl_, r); }
208 
215  {
216  l.owner_t::operator=(owner_t{});
217  concat_mut_r(l.impl_, impl_, *this);
218  }
220  { concat_mut_lr_r(l.impl_, l, impl_, *this); }
221 
222 private:
224 
226  : impl_(std::move(impl))
227  {}
228 
230 };
231 
232 } // namespace immer
void append(flex_vector_transient &&r)
const auto default_bits
Definition: config.hpp:63
void update_mut(edit_t e, size_t idx, FnT &&fn)
Definition: rrbtree.hpp:494
detail::rbts::rrbtree_iterator< T, MemoryPolicy, B, BL > iterator
std::reverse_iterator< iterator > reverse_iterator
void take_mut(edit_t e, size_t new_size)
Definition: rrbtree.hpp:531
std::size_t size_t
Definition: bits.hpp:20
reference operator[](size_type index) const
Definition: box.hpp:161
void prepend(flex_vector_transient &&l)
static const rrbtree & empty()
Definition: rrbtree.hpp:47
void push_back_mut(edit_t e, T value)
Definition: rrbtree.hpp:397
const T & get_check(size_t index) const
Definition: rrbtree.hpp:476
memory_policy< default_heap_policy, default_refcount_policy > default_memory_policy
void update(size_type index, FnT &&fn)
std::uint32_t bits_t
Definition: bits.hpp:17
reference at(size_type index) const
void prepend(flex_vector_transient &l)
const T & get(size_t index) const
Definition: rrbtree.hpp:471
void assoc_mut(edit_t e, size_t idx, T value)
Definition: rrbtree.hpp:517
void drop_mut(edit_t e, size_t elems)
Definition: rrbtree.hpp:600
typename MemoryPolicy::transience_t::owner base_t
typename MemoryPolicy::transience_t::owner owner_t
void append(flex_vector_transient &r)
flex_vector_transient(vector_transient< T, MemoryPolicy, B, BL > v)
Released under the MIT license