tnarr.hpp
Go to the documentation of this file.
1
2#pragma once
3
6
7namespace by {
8
9 template <typename T, typename TACTIC = strTactic> class tnarr: public tnucontainer<T>, public tarrayable<T> {
10 BY(ADT(tnarr, tnucontainer<T>))
11
12 public:
13 friend class arr;
14 typedef tstr<T, TACTIC> wrap;
15 typedef typename super::iter iter;
16 typedef typename super::iteration iteration;
17 friend class narrIteration;
18#include "../iter/narrIteration.hpp"
19
20 public:
21 tnarr();
22
25 template <typename... Es> explicit tnarr(const Es&... elems) {
26 static_assert(areBaseOfT<T, Es...>::value, "some of type of args are not base of type 'T'");
27 add({(T*) &elems...});
28 }
29
30 tnarr(const me& rhs);
31
32 public:
33 me& operator=(const me& rhs) = default;
34
36
37 T& operator[](nidx n) override { return *get(n); }
38
39 public:
40 // len:
41 ncnt len() const override;
42
43 // has:
44 using super::in;
45 nbool in(nidx n) const override;
46
47 // get:
48 using super::get;
49 using tarrayable<T>::get;
50 T* get(nidx n) override;
51
52 // set:
53 using super::set;
54 using tarrayable<T>::set;
55 nbool set(const iter& at, const T& new1) override;
56 nbool set(nidx n, const T& new1) override;
57
58 // add:
59 using super::add;
61 nbool add(const iter& e, const T& new1) override;
62 nbool add(nidx n, const T& new1) override;
63 void add(const iter& here, const iter& from, const iter& to) override;
64
65 // del:
66 using super::del;
68 nbool del(const iter& from, const iter& end) override;
69 nbool del(const iter& it) override;
70 nbool del(nidx n) override;
71
72 // etc:
73 void rel() override;
74
75 clonable* clone() const override { return new me(*this); }
76
77 void onCloneDeep(const clonable& from) override;
78
79 std::string asStr() const;
80
81 protected:
82 iteration* _onMakeIteration(ncnt step, nbool isReversed) const override;
83
84 private:
85 narrIteration* _getIteration(const iter& it);
86
87 private:
88 std::vector<wrap> _vec;
89 };
90
91 class node;
92 typedef tnarr<node> narr;
93} // namespace by
Managed array container for byeol language.
Definition: arr.hpp:14
Interface for objects that can be cloned.
Definition: clonable.hpp:12
Deferred execution utility like defer keyword in other languages.
Definition: end.hpp:14
Definition: tarrayable.hpp:10
virtual nbool add(nidx n, const T &new1)=0
Definition: tnarr.hpp:9
tnarr(const Es &... elems)
Definition: tnarr.hpp:25
nbool del(nidx n) override
nbool add(nidx n, const T &new1) override
Definition: tnucontainer.hpp:9
Strong reference smart pointer with strict type checking.
Definition: tstr.hpp:13
nbool del()
delete last element if exists.
Bidirectional iterator for key-value containers.
Definition: biter.hpp:9
Definition: biteration.hpp:5
Definition: narrIteration.hpp:7