-
Notifications
You must be signed in to change notification settings - Fork 4
/
DependencyGraphNode.cs
77 lines (63 loc) · 1.77 KB
/
DependencyGraphNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// /home/vfpamplona/MonoProjects/hl2glsl/hl2glsl/DependencyGraph.cs created with MonoDevelop
// User: vfpamplona at 10:29 6/3/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using System.Collections;
namespace hl2glsl {
public class DependencyGraphNode {
private string dependencyName;
private ArrayList calledBy;
public DependencyGraphNode(string dependencyName) {
this.dependencyName = dependencyName;
calledBy = new ArrayList();
}
public void AddCallsBy(DependencyGraphNode func) {
if (func == null)
return;
for (int i=0; i<calledBy.Count; i++) {
if (func == calledBy[i]) return;
}
calledBy.Add(func);
}
public string GetDependencyName() {
return dependencyName;
}
public void SetDependencyName(string name) {
dependencyName = name;
}
public void ReplaceCalledBy(DependencyGraphNode toReplace, DependencyGraphNode newOne) {
for (int i=0; i<calledBy.Count; i++) {
if (toReplace == calledBy[i]) {
calledBy.Remove(toReplace);
if (newOne != null)
calledBy.Add(newOne);
return;
}
}
}
public bool IsCalledBy(string func) {
for (int i=0; i<calledBy.Count; i++) {
if (func.Equals(((DependencyGraphNode)calledBy[i]).GetDependencyName() )) {
return true;
}
}
return false;
}
public ArrayList GetCalledByList() {
return calledBy;
}
public void Print() {
Console.WriteLine(dependencyName);
if (calledBy.Count > 0) {
Console.WriteLine("Called By:");
for (int i=0; i<calledBy.Count; i++) {
Console.WriteLine("\t" + ((DependencyGraphNode)calledBy[i]).GetDependencyName());
}
} else {
Console.WriteLine("Called By Anyone");
}
}
}
}