acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
array_union.h
1#pragma once
2
3
4template < typename ARRAY >
6{
7
8public:
9
10 using BASE_TYPE = typename ARRAY::BASE_TYPE;
11
12 ::array < ARRAY * > m_2a;
13
14 void add_array(ARRAY * parray)
15 {
16
17 m_2a.add(parray);
18
19 }
20
21 const BASE_TYPE & operator[](::collection::index iIndex)
22 {
23
24 ::collection::index iArray = 0;
25
26 for (; iArray < m_2a.size(); iArray++)
27 {
28
29 if (iIndex < m_2a[iArray]->size())
30 {
31
32 return m_2a[iArray]->element_at(iIndex);
33
34 }
35
36 iIndex -= m_2a[iArray]->size();
37
38 }
39
40 throw ::exception(error_index_out_of_bounds, "get_line with argument >= line_count");
41
42 return m_2a[iArray]->element_at(0);
43
44 }
45
46
47 ::collection::count size() const
48 {
49
50 ::collection::count c = 0;
51
52 for (::collection::index iArray = 0; iArray < m_2a.size(); iArray++)
53 {
54
55 c += m_2a[iArray]->size();
56
57 }
58
59 return c;
60
61 }
62
63
64};
65
66template < typename ARRAY >
68 public ARRAY
69{
70public:
71
72
73 ::collection::count get_upper_bound(::collection::index i = -1) const { return this->size() + i; }
74 bool has_elements(::collection::count cMinimum = 1) const { return this->size() > cMinimum; }
75 bool has_element() const { return this->has_elements(); }
76
77};
78
79
80template < typename ARRAY >
81using array_union = array_traits < array_union_base < ARRAY > >;
Definition array_union.h:69
Definition array_union.h:6