Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

dvektor.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 
12 #include <immer/memory_policy.hpp>
13 
14 namespace immer {
15 
16 template <typename T,
17  int B = 5,
18  typename MemoryPolicy = default_memory_policy>
19 class dvektor
20 {
22 
23 public:
24  using value_type = T;
25  using reference = const T&;
27  using difference_type = std::ptrdiff_t;
28  using const_reference = const T&;
29 
32  using reverse_iterator = std::reverse_iterator<iterator>;
33 
34  dvektor() = default;
35 
36  iterator begin() const { return {impl_}; }
37  iterator end() const { return {impl_, typename iterator::end_t{}}; }
38 
41 
42  std::size_t size() const { return impl_.size; }
43  bool empty() const { return impl_.size == 0; }
44 
46  { return impl_.get(index); }
47 
49  { return { impl_.push_back(std::move(value)) }; }
50 
51  dvektor assoc(std::size_t idx, value_type value) const
52  { return { impl_.assoc(idx, std::move(value)) }; }
53 
54  template <typename FnT>
55  dvektor update(std::size_t idx, FnT&& fn) const
56  { return { impl_.update(idx, std::forward<FnT>(fn)) }; }
57 
58 private:
59  dvektor(impl_t impl) : impl_(std::move(impl)) {}
60  impl_t impl_ = detail::dvektor::empty<T, B, MemoryPolicy>;
61 };
62 
63 } // namespace immer
detail::dvektor::iterator< T, B, MemoryPolicy > iterator
Definition: dvektor.hpp:30
impl assoc(std::size_t idx, T value) const
std::ptrdiff_t difference_type
Definition: dvektor.hpp:27
std::size_t size() const
Definition: dvektor.hpp:42
const T & const_reference
Definition: dvektor.hpp:28
std::reverse_iterator< iterator > reverse_iterator
Definition: dvektor.hpp:32
const T & get(std::size_t index) const
Definition: box.hpp:161
dvektor update(std::size_t idx, FnT &&fn) const
Definition: dvektor.hpp:55
const T & reference
Definition: dvektor.hpp:25
reverse_iterator rend() const
Definition: dvektor.hpp:40
std::size_t size_t
Definition: bits.hpp:21
memory_policy< default_heap_policy, default_refcount_policy > default_memory_policy
bool empty() const
Definition: dvektor.hpp:43
impl push_back(T value) const
dvektor(impl_t impl)
Definition: dvektor.hpp:59
iterator begin() const
Definition: dvektor.hpp:36
reference operator[](size_type index) const
Definition: dvektor.hpp:45
dvektor()=default
reverse_iterator rbegin() const
Definition: dvektor.hpp:39
impl update(std::size_t idx, FnT &&fn) const
dvektor assoc(std::size_t idx, value_type value) const
Definition: dvektor.hpp:51
iterator end() const
Definition: dvektor.hpp:37
impl_t impl_
Definition: dvektor.hpp:60
std::size_t size_type
Definition: dvektor.hpp:26
dvektor push_back(value_type value) const
Definition: dvektor.hpp:48
Released under the MIT license