Synthia
Generic and flexible data structure generator
GraphCrawler.java
Go to the documentation of this file.
1 package ca.uqac.lif.synthia.tree;
2 
3 import java.util.HashMap;
4 import java.util.Map;
5 
6 public abstract class GraphCrawler<T>
7 {
8  protected Map<Node<T>,Integer> m_nodes;
9 
10  protected int m_idCounter;
11 
12  public GraphCrawler()
13  {
14  super();
15  m_nodes = new HashMap<Node<T>,Integer>();
16  m_idCounter = 0;
17 
18  }
19 
20  protected int getId(Node<T> n)
21  {
22  if (m_nodes.containsKey(n))
23  {
24  return m_nodes.get(n);
25  }
26  int id = m_idCounter++;
27  m_nodes.put(n, id);
28  return id;
29  }
30 
31 }
ca.uqac.lif.synthia.tree.GraphCrawler.m_idCounter
int m_idCounter
Definition: GraphCrawler.java:10
ca.uqac.lif.synthia.tree.GraphCrawler.getId
int getId(Node< T > n)
Definition: GraphCrawler.java:20
ca.uqac.lif.synthia.tree.GraphCrawler
Definition: GraphCrawler.java:6
ca.uqac.lif.synthia.tree.GraphCrawler.GraphCrawler
GraphCrawler()
Definition: GraphCrawler.java:12
ca.uqac.lif.synthia.tree.Node
Simple implementation of a labeled nodel.
Definition: Node.java:31
ca.uqac.lif.synthia.tree.GraphCrawler.m_nodes
Map< Node< T >, Integer > m_nodes
Definition: GraphCrawler.java:8