aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
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
45
46namespace gum {
47
49 GUM_CONSTRUCTOR(ActionSet);
51 }
52
53 INLINE ActionSet::ActionSet(const ActionSet& src) {
54 GUM_CONSTRUCTOR(ActionSet);
56 for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
57 _actionSeq_->insert(*idi);
58 }
59
62 for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
63 _actionSeq_->insert(*idi);
64 return *this;
65 }
66
68 GUM_DESTRUCTOR(ActionSet);
69 delete _actionSeq_;
70 }
71
72 INLINE void* ActionSet::operator new(size_t s) {
74 }
75
76 INLINE void ActionSet::operator delete(void* p) {
78 }
79
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
92 for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
93 if (!_actionSeq_->exists(*iter)) _actionSeq_->insert(*iter);
94 return *this;
95 }
96
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
Headers of the MDDOperatorStrategy planer class.
ActionSet & operator=(const ActionSet &src)
Constructor.
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
bool exists(const Idx &elem) const
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
~ActionSet()
Destructor.
ActionSet & operator+=(const Idx &elem)
Ajout d'un élément.
ActionSet()
Constructor.
bool operator==(const ActionSet &compared) const
Compares two ActionSet to check if they are equals.
ActionSet & operator-=(const ActionSet &src)
Use to insert the content of another set inside this one.
Sequence< Idx > * _actionSeq_
The very bone of the ActionSet.
Definition actionSet.h:186
Size size() const
Gives the size.
static SmallObjectAllocator & instance()
void * allocate(const size_t &objectSize)
Allocates a block.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree