1 package edu.uci.ics.jung.graph.util;
2
3
4
5
6
7 public class Context<G,E>
8 {
9 @SuppressWarnings("unchecked")
10 private static Context instance = new Context();
11
12
13
14
15 public G graph;
16
17
18
19
20 public E element;
21
22
23
24
25
26
27 @SuppressWarnings("unchecked")
28 public static <G,E> Context<G,E> getInstance(G graph, E element) {
29 instance.graph = graph;
30 instance.element = element;
31 return instance;
32 }
33
34 @Override
35 public int hashCode() {
36 return graph.hashCode() ^ element.hashCode();
37 }
38
39 @SuppressWarnings("unchecked")
40 @Override
41 public boolean equals(Object o) {
42 if (!(o instanceof Context))
43 return false;
44 Context context = (Context)o;
45 return context.graph.equals(graph) && context.element.equals(element);
46 }
47 }
48