aGrUM
3.3.2
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
actionSet_inl.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
#pragma once
42
43
// to ease IDE parser
44
#include <
agrum/FMDP/planning/actionSet.h
>
45
46
namespace
gum
{
47
48
INLINE
ActionSet::ActionSet
() {
49
GUM_CONSTRUCTOR(
ActionSet
);
50
_actionSeq_
=
new
Sequence< Idx >
();
51
}
52
53
INLINE
ActionSet::ActionSet
(
const
ActionSet
& src) {
54
GUM_CONSTRUCTOR(
ActionSet
);
55
_actionSeq_
=
new
Sequence< Idx >
();
56
for
(
auto
idi = src.
beginSafe
(); idi != src.
endSafe
(); ++idi)
57
_actionSeq_
->
insert
(*idi);
58
}
59
60
INLINE
ActionSet
&
ActionSet::operator=
(
const
ActionSet
& src) {
61
_actionSeq_
=
new
Sequence< Idx >
();
62
for
(
auto
idi = src.
beginSafe
(); idi != src.
endSafe
(); ++idi)
63
_actionSeq_
->
insert
(*idi);
64
return
*
this
;
65
}
66
67
INLINE
ActionSet::~ActionSet
() {
68
GUM_DESTRUCTOR(
ActionSet
);
69
delete
_actionSeq_
;
70
}
71
72
INLINE
void
* ActionSet::operator
new
(
size_t
s) {
73
return
SmallObjectAllocator::instance
().
allocate
(s);
74
}
75
76
INLINE
void
ActionSet::operator
delete
(
void
* p) {
77
SmallObjectAllocator::instance
().
deallocate
(p,
sizeof
(
ActionSet
));
78
}
79
80
INLINE
SequenceIteratorSafe< Idx >
ActionSet::beginSafe
()
const
{
81
return
_actionSeq_
->
beginSafe
();
82
}
83
84
INLINE
SequenceIteratorSafe< Idx >
ActionSet::endSafe
()
const
{
return
_actionSeq_
->
endSafe
(); }
85
86
INLINE
ActionSet
&
ActionSet::operator+=
(
const
Idx
& elem) {
87
_actionSeq_
->
insert
(elem);
88
return
*
this
;
89
}
90
91
INLINE
ActionSet
&
ActionSet::operator+=
(
const
ActionSet
& src) {
92
for
(
auto
iter = src.
beginSafe
(); iter != src.
endSafe
(); ++iter)
93
if
(!
_actionSeq_
->
exists
(*iter))
_actionSeq_
->
insert
(*iter);
94
return
*
this
;
95
}
96
97
INLINE
ActionSet
&
ActionSet::operator-=
(
const
ActionSet
& src) {
98
for
(
auto
iter = src.
beginSafe
(); iter != src.
endSafe
(); ++iter)
99
if
(
_actionSeq_
->
exists
(*iter))
_actionSeq_
->
erase
(*iter);
100
return
*
this
;
101
}
102
103
INLINE
bool
ActionSet::operator==
(
const
ActionSet
& compared)
const
{
104
for
(
auto
iter = compared.
beginSafe
(); iter != compared.
endSafe
(); ++iter)
105
if
(!
_actionSeq_
->
exists
(*iter))
return
false
;
106
for
(
auto
iter = this->
beginSafe
(); iter != this->
endSafe
(); ++iter)
107
if
(!compared.
exists
(*iter))
return
false
;
108
return
true
;
109
}
110
111
INLINE
Size
ActionSet::size
()
const
{
return
_actionSeq_
->
size
(); }
112
113
INLINE
bool
ActionSet::exists
(
const
Idx
& elem)
const
{
return
_actionSeq_
->
exists
(elem); }
114
115
INLINE std::ostream&
operator<<
(std::ostream& streamy,
const
ActionSet
& objy) {
116
streamy << objy.
_actionSeq_
->
toString
();
117
return
streamy;
118
}
119
120
}
// namespace gum
actionSet.h
Headers of the MDDOperatorStrategy planer class.
gum::ActionSet::operator=
ActionSet & operator=(const ActionSet &src)
Constructor.
Definition
actionSet_inl.h:60
gum::ActionSet::operator<<
friend GUM_PUBLIC_FMDP std::ostream & operator<<(std::ostream &streamy, const ActionSet &objy)
Definition
actionSet_inl.h:115
gum::ActionSet::beginSafe
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
Definition
actionSet_inl.h:80
gum::ActionSet::exists
bool exists(const Idx &elem) const
Definition
actionSet_inl.h:113
gum::ActionSet::endSafe
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
Definition
actionSet_inl.h:84
gum::ActionSet::~ActionSet
~ActionSet()
Destructor.
Definition
actionSet_inl.h:67
gum::ActionSet::operator+=
ActionSet & operator+=(const Idx &elem)
Ajout d'un élément.
Definition
actionSet_inl.h:86
gum::ActionSet::ActionSet
ActionSet()
Constructor.
Definition
actionSet_inl.h:48
gum::ActionSet::operator==
bool operator==(const ActionSet &compared) const
Compares two ActionSet to check if they are equals.
Definition
actionSet_inl.h:103
gum::ActionSet::operator-=
ActionSet & operator-=(const ActionSet &src)
Use to insert the content of another set inside this one.
Definition
actionSet_inl.h:97
gum::ActionSet::_actionSeq_
Sequence< Idx > * _actionSeq_
The very bone of the ActionSet.
Definition
actionSet.h:186
gum::ActionSet::size
Size size() const
Gives the size.
Definition
actionSet_inl.h:111
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::toString
std::string toString() const
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::beginSafe
iterator_safe beginSafe() const
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::insert
void insert(const Key &k)
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::erase
void erase(const Key &k)
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::exists
bool exists(const Key &k) const
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::endSafe
const iterator_safe & endSafe() const noexcept
gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::size
Size size() const noexcept
gum::SequenceIteratorSafe< Idx >
gum::Sequence< Idx >
gum::SmallObjectAllocator::instance
static SmallObjectAllocator & instance()
Definition
smallObjectAllocator_inl.h:96
gum::SmallObjectAllocator::allocate
void * allocate(const size_t &objectSize)
Allocates a block.
Definition
smallObjectAllocator.cpp:72
gum::SmallObjectAllocator::deallocate
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Definition
smallObjectAllocator_inl.h:116
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.3.2
© PHW&CG&others - 2022
DoXyGeN 1.18.0