Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
arithm
group
arrayofelmts.cpp
Go to the documentation of this file.
1
12
#include "
group.hpp
"
13
#include "
elmt.hpp
"
14
#include "
arrayofelmts.hpp
"
15
16
17
using namespace
arithm;
18
19
20
ArrayOfElmts::ArrayOfElmts
()
21
{
22
}
23
24
25
ArrayOfElmts::ArrayOfElmts
(
verifierUtils::ByteTree
* bt,
Group
* grp)
26
{
27
if
(!bt->
isNode
())
28
{
29
std::cout<<
"ERROR: in ArrayOfElmts(bt,grp), bt is not "
30
<<
"a Node.\nbt="
;
31
bt->
prettyPrint
(
""
);
32
std::cout<<std::endl;
33
exit(1);
34
}
35
elmts
.resize(bt->
size
());
36
for
(
unsigned
int
i=0; i<bt->
size
(); i++)
37
elmts
[i] =
new
Elmt
(grp->
getElmt
(bt->
getChild
(i)));
38
}
39
40
41
verifierUtils::ByteTree
*
ArrayOfElmts::toByteTree
()
42
{
43
verifierUtils::ByteTree
* result =
new
verifierUtils::Node
();
44
for
(
unsigned
int
i=0; i<
elmts
.size(); i++)
45
result->
addChild
(
elmts
[i]->toByteTree());
46
return
result;
47
}
48
49
50
ArrayOfElmts
ArrayOfElmts::subArray
(std::vector<bool> keepList)
51
{
52
if
(keepList.size() !=
elmts
.size())
53
{
54
std::cout<<
"ERROR: in ArrayOfElmts.subArray(keepList),"
55
<<
" keepList and this are not of the same "
56
<<
"size.\nthis.size()="
<<
elmts
.size()
57
<<
"\nkeepList.size()="
<<keepList.size()
58
<<std::endl;
59
exit(1);
60
}
61
ArrayOfElmts
result;
62
for
(
unsigned
int
i=0; i<keepList.size(); i++)
63
if
(keepList[i])
64
result.
addElmt
(
getElmt
(i));
65
return
result;
66
}
67
68
69
void
ArrayOfElmts::addElmt
(
Elmt
e)
70
{
71
Elmt
* ptr =
new
Elmt
(e);
72
elmts
.push_back(ptr);
73
}
74
75
76
Elmt
ArrayOfElmts::getElmt
(
unsigned
int
i)
77
{
78
Elmt
res = (*
elmts
[i]);
79
return
res;
80
}
81
82
83
unsigned
int
ArrayOfElmts::size
()
84
{
85
return
elmts
.size();
86
}