Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_core
Attribute
Types
SumAgg.inl
Go to the documentation of this file.
1
namespace
iv
2
{
3
4
template
<
class
Int >
5
SumAgg< Int >::SumAgg
() :
6
current( 0 ),
7
count( 0 )
8
{
9
}
10
11
template
<
class
Int >
12
SumAgg< Int >::SumAgg
( Int current,
int
count ) :
13
current( current ),
14
count( count )
15
{
16
}
17
18
template
<
class
Int >
19
SumAgg< Int >
SumAgg< Int >::Insert
( Int value )
const
20
{
21
Int current = this->current + value;
22
int
count = this->count + 1;
23
if
( count == 0 )
24
current = 0;
25
return
SumAgg< Int >
( current, count );
26
}
27
28
template
<
class
Int >
29
SumAgg< Int >
SumAgg< Int >::Remove
( Int value )
const
30
{
31
Int current = this->current - value;
32
int
count = this->count - 1;
33
if
( count == 0 )
34
current = 0;
35
return
SumAgg< Int >
( current, count );
36
}
37
38
template
<
class
Int >
39
Int
SumAgg< Int >::Aggregated
()
const
40
{
41
return
this->current;
42
}
43
44
template
<
class
Int >
45
int
SumAgg< Int >::Size
()
const
46
{
47
return
this->count;
48
}
49
50
}