acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
array_union.h
1
#pragma once
2
3
4
template
<
typename
ARRAY >
5
class
array_union_base
6
{
7
8
public
:
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
66
template
<
typename
ARRAY >
67
class
array_traits
:
68
public
ARRAY
69
{
70
public
:
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
80
template
<
typename
ARRAY >
81
using
array_union = array_traits < array_union_base < ARRAY > >;
array_traits
Definition
array_union.h:69
array_union_base
Definition
array_union.h:6
prototype
collection
array_union.h
Generated by
1.17.0