-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDependencyGraph.cs
More file actions
68 lines (58 loc) · 1.79 KB
/
DependencyGraph.cs
File metadata and controls
68 lines (58 loc) · 1.79 KB
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
// /home/vfpamplona/MonoProjects/hl2glsl/hl2glsl/DependencyGraph.cs created with MonoDevelop
// User: vfpamplona at 16:59 25/3/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using System.Collections;
namespace hl2glsl
{
public class DependencyGraph
{
private ArrayList dependants;
public DependencyGraph() {
dependants = new ArrayList();
}
public void PrintCallTree() {
for (int i=0; i<dependants.Count; i++) {
((DependencyGraphNode) dependants[i]).Print();
}
}
public ArrayList GetWhoThisFunctionCalls(string func) {
ArrayList functions = new ArrayList();
for (int i=0; i<dependants.Count; i++) {
if (((DependencyGraphNode)dependants[i]).IsCalledBy(func)) {
functions.Add(((DependencyGraphNode)dependants[i]).GetDependencyName());
}
}
return functions;
}
public DependencyGraphNode SearchDependant(string dependantName) {
DependencyGraphNode tmp;
for (int i=0; i<dependants.Count; i++) {
tmp = (DependencyGraphNode) dependants[i];
if (tmp.GetDependencyName().Equals(dependantName))
return tmp;
}
DependencyGraphNode novo = new DependencyGraphNode(dependantName);
dependants.Add(novo);
return novo;
}
public void ReplaceDependant(string toReplace, DependencyGraphNode newNode) {
DependencyGraphNode replacing = SearchDependant(toReplace);
for (int i=0; i<CountDependants(); i++) {
((DependencyGraphNode)dependants[i]).ReplaceCalledBy(replacing, newNode);
}
RemoveDependant(replacing);
}
public void AddDependant(DependencyGraphNode dep) {
dependants.Add(dep);
}
public void RemoveDependant(DependencyGraphNode dep) {
dependants.Remove(dep);
}
public int CountDependants() {
return dependants.Count;
}
}
}