aGrUM  0.16.0
nodeGraphPart_tpl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 // to ease parsing by IDE
33 
34 namespace gum {
35 
36  template < typename VAL >
37  INLINE NodeProperty< VAL > NodeGraphPart::nodesProperty(VAL (*f)(const NodeId&),
38  Size size) const {
39  return asNodeSet().hashMap(f, size);
40  }
41 
42  template < typename VAL >
43  INLINE NodeProperty< VAL > NodeGraphPart::nodesProperty(const VAL& val,
44  Size size) const {
45  return asNodeSet().hashMap(val, size);
46  }
47 
48  template < typename VAL >
49  INLINE List< VAL > NodeGraphPart::listMapNodes(VAL (*f)(const NodeId&)) const {
50  return asNodeSet().listMap(f);
51  }
52 
53  template < typename T >
54  void NodeGraphPart::populateNodesFromProperty(const NodeProperty< T >& h) {
55  clear();
56 
57  for (const auto iter = h.begin(); iter != h.end(); ++iter) {
58  NodeId new_one = iter.key();
59 
60  if (existsNode(new_one)) {
61  GUM_ERROR(DuplicateElement, new_one << " already exists in the graph");
62  }
63 
64  addNodeWithId(new_one);
65  }
66  }
67 
68 } /* namespace gum */
69 
70 #endif // DOXYGEN_SHOULD_SKIP_THIS
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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))
NodeProperty< VAL > nodesProperty(VAL(*f)(const NodeId &), Size size=0) const
a method to create a HashTable with key:NodeId and value:VAL
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
HashTable< Key, NewKey, NewAlloc > hashMap(NewKey(*f)(const Key &), Size capacity=0) const
Creates a hashtable of NewKey from the set.
Definition: set_tpl.h:838
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"
virtual void clear()
alias for clearNodes
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
List< NewKey, NewAlloc > listMap(NewKey(*f)(const Key &)) const
A method to create a List of NewKey from the set.
Definition: set_tpl.h:884
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55