27 #ifndef GUM_NODE_GRAPH_PART_H 28 #define GUM_NODE_GRAPH_PART_H 33 #include <agrum/agrum.h> 35 #include <agrum/tools/graphs/graphElements.h> 37 #include <agrum/tools/core/signal/listener.h> 38 #include <agrum/tools/core/signal/signaler.h> 40 #ifndef DOXYGEN_SHOULD_SKIP_THIS 44 class NodeGraphPartTestSuite;
63 using iterator_category = std::forward_iterator_tag;
69 using difference_type = std::ptrdiff_t;
120 void setPos_(NodeId id)
noexcept;
145 using iterator_category = std::forward_iterator_tag;
151 using difference_type = std::ptrdiff_t;
288 bool holes_resize_policy =
true);
332 template <
typename T >
370 bool exists(
const NodeId id)
const;
382 virtual void clear();
412 const node_iterator_safe&
endSafe()
const noexcept;
416 node_iterator
begin()
const noexcept;
420 const node_iterator&
end()
const noexcept;
436 template <
typename VAL >
450 template <
typename VAL >
456 template <
typename VAL >
467 friend class gum_tests::NodeGraphPartTestSuite;
515 std::ostream& operator<<(std::ostream&,
const NodeGraphPart&);
519 #ifndef GUM_NO_INLINE 520 # include <agrum/tools/graphs/parts/nodeGraphPart_inl.h> 523 #include <agrum/tools/graphs/parts/nodeGraphPart_tpl.h>
NodeGraphPart & operator=(const NodeGraphPart &p)
copy operator
NodeGraphPartIterator(const NodeGraphPartIterator &it) noexcept
copy constructor
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeProperty< VAL > nodesProperty(const VAL &a, Size size=0) const
a method to create a hashMap with key:NodeId and value:VAL
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
node_iterator_safe beginSafe() const
a begin iterator to parse the set of nodes contained in the NodeGraphPart
void _updateEndIteratorSafe_()
updating endIterator (always at max+1)
NodeGraphPartIterator NodeConstIterator
NodeGraphPartIterator & operator=(const NodeGraphPartIterator &it) noexcept
copy assignment operator
INLINE void emplace(Args &&... args)
NodeGraphPartIteratorSafe(NodeGraphPartIteratorSafe &&it)
move constructor
NodeGraphPartIteratorSafe & operator=(const NodeGraphPartIteratorSafe &it)
copy assignment operator
Size size() const
alias for sizeNodes
NodeGraphPartIterator(NodeGraphPartIterator &&it) noexcept
move constructor
NodeGraphPartIteratorSafe NodeIteratorSafe
List< VAL > listMapNodes(VAL(*f)(const NodeId &)) const
a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x))
void setPos_(NodeId id) noexcept
this function is used by NodeGraphPart to update
NodeProperty< VAL > nodesProperty(VAL(*f)(const NodeId &), Size size=0) const
a method to create a HashTable with key:NodeId and value:VAL
NodeGraphPart(const NodeGraphPart &s)
copy constructor
bool exists(const NodeId id) const
alias for existsNode
virtual NodeId addNode()
insert a new node and return its id
void _addHole_(NodeId id)
to add a hole.
~NodeGraphPartIteratorSafe()
destructor
bool operator!=(const NodeGraphPartIterator &it) const noexcept
checks whether two iterators point toward different nodes
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
virtual ~NodeGraphPart()
destructor
NodeGraphPartIteratorSafe NodeConstIteratorSafe
void validate_() noexcept
ensure that the nodeId is either end() either a valid NodeId
bool empty() const
alias for emptyNodes
bool emptyNodes() const
indicates whether there exists nodes in the NodeGraphPart
void _clearNodes_()
code for clearing nodes (called twice)
node_iterator begin() const noexcept
a begin iterator to parse the set of nodes contained in the NodeGraphPart
Unsafe iterator on the node set of a graph.
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
Size _holes_size_
value for holes configuration
NodeGraphPartIteratorSafe(const NodeGraphPart &nodes)
default constructor
value_type operator*() const
dereferencing operator
Signaler1< NodeId > onNodeAdded
NodeSet asNodeSet() const
returns a copy of the set of nodes represented by the NodeGraphPart
void populateNodesFromProperty(const NodeProperty< T > &h)
populateNodesFromProperty clears *this and fills it with the keys of "h"
NodeGraphPartIterator & operator++() noexcept
increment the iterator
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
std::vector< NodeId > addNodes(Size n)
insert n nodes
virtual std::string toString() const
a function to display the set of nodes
NodeId pos_
the nodeid on which the iterator points currently
NodeGraphPartIterator NodeIterator
virtual void clear()
alias for clearNodes
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
NodeGraphPartIteratorSafe & operator=(NodeGraphPartIteratorSafe &&it)
move assignment operator
bool operator==(const NodeGraphPartIterator &it) const noexcept
checks whether two iterators point toward the same node
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
NodeGraphPartIterator & operator=(NodeGraphPartIterator &&it) noexcept
move assignment operator
bool _inHoles_(NodeId id) const
NodeGraphPartIteratorSafe(const NodeGraphPartIteratorSafe &it)
copy constructor
virtual void clearNodes()
remove all the nodes from the NodeGraphPart
const node_iterator_safe & endSafe() const noexcept
the end iterator to parse the set of nodes contained in the NodeGraphPart
NodeId nextNodeId() const
returns a new node id, not yet used by any node
bool operator!=(const NodeGraphPart &p) const
check whether two NodeGraphParts contain different nodes
void populateNodes(const NodeGraphPart &s)
populateNodes clears *this and fills it with the same nodes as "s"
virtual ~NodeGraphPartIterator() noexcept
destructor
Signaler1< NodeId > onNodeDeleted
friend class NodeGraphPartIteratorSafe
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
Safe iterator on the node set of a graph.
void _eraseHole_(NodeId id)
to delete hole.
const node_iterator & end() const noexcept
the end iterator to parse the set of nodes contained in the NodeGraphPart
void whenNodeDeleted(const void *src, NodeId id)
called when a node is deleted in the iterated NodeGraphPart
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
bool _holes_resize_policy_
value for holes configuration
virtual void eraseNode(const NodeId id)
erase the node with the given id