本文整理汇总了C#中SpreadsheetUtilities.DependencyGraph.GetDependees方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyGraph.GetDependees方法的具体用法?C# DependencyGraph.GetDependees怎么用?C# DependencyGraph.GetDependees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpreadsheetUtilities.DependencyGraph
的用法示例。
在下文中一共展示了DependencyGraph.GetDependees方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StressTest15
public void StressTest15()
{
// Dependency graph
DependencyGraph t = new DependencyGraph();
// A bunch of strings to use
const int SIZE = 100;
string[] letters = new string[SIZE];
for (int i = 0; i < SIZE; i++)
{
letters[i] = ("" + (char)('a' + i));
}
// The correct answers
HashSet<string>[] dents = new HashSet<string>[SIZE];
HashSet<string>[] dees = new HashSet<string>[SIZE];
for (int i = 0; i < SIZE; i++)
{
dents[i] = new HashSet<string>();
dees[i] = new HashSet<string>();
}
// Add a bunch of dependencies
for (int i = 0; i < SIZE; i++)
{
for (int j = i + 1; j < SIZE; j++)
{
t.AddDependency(letters[i], letters[j]);
dents[i].Add(letters[j]);
dees[j].Add(letters[i]);
}
}
// Remove a bunch of dependencies
for (int i = 0; i < SIZE; i++)
{
for (int j = i + 2; j < SIZE; j += 2)
{
t.RemoveDependency(letters[i], letters[j]);
dents[i].Remove(letters[j]);
dees[j].Remove(letters[i]);
}
}
// Replace a bunch of dependees
for (int i = 0; i < SIZE; i += 4)
{
HashSet<string> newDees = new HashSet<String>();
for (int j = 0; j < SIZE; j += 7)
{
newDees.Add(letters[j]);
}
t.ReplaceDependees(letters[i], newDees);
foreach (string s in dees[i])
{
dents[s[0] - 'a'].Remove(letters[i]);
}
foreach (string s in newDees)
{
dents[s[0] - 'a'].Add(letters[i]);
}
dees[i] = newDees;
}
// Make sure everything is right
for (int i = 0; i < SIZE; i++)
{
Assert.IsTrue(dents[i].SetEquals(new HashSet<string>(t.GetDependents(letters[i]))));
Assert.IsTrue(dees[i].SetEquals(new HashSet<string>(t.GetDependees(letters[i]))));
}
}
示例2: EmptyTest4
public void EmptyTest4()
{
DependencyGraph t = new DependencyGraph();
Assert.IsFalse(t.GetDependees("a").GetEnumerator().MoveNext());
}
示例3: NonEmptyTest4
public void NonEmptyTest4()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
t.AddDependency("a", "c");
t.AddDependency("d", "c");
HashSet<String> aDents = new HashSet<String>(t.GetDependents("a"));
HashSet<String> bDents = new HashSet<String>(t.GetDependents("b"));
HashSet<String> cDents = new HashSet<String>(t.GetDependents("c"));
HashSet<String> dDents = new HashSet<String>(t.GetDependents("d"));
HashSet<String> eDents = new HashSet<String>(t.GetDependents("e"));
HashSet<String> aDees = new HashSet<String>(t.GetDependees("a"));
HashSet<String> bDees = new HashSet<String>(t.GetDependees("b"));
HashSet<String> cDees = new HashSet<String>(t.GetDependees("c"));
HashSet<String> dDees = new HashSet<String>(t.GetDependees("d"));
HashSet<String> eDees = new HashSet<String>(t.GetDependees("e"));
Assert.IsTrue(aDents.Count == 2 && aDents.Contains("b") && aDents.Contains("c"));
Assert.IsTrue(bDents.Count == 0);
Assert.IsTrue(cDents.Count == 0);
Assert.IsTrue(dDents.Count == 1 && dDents.Contains("c"));
Assert.IsTrue(eDents.Count == 0);
Assert.IsTrue(aDees.Count == 0);
Assert.IsTrue(bDees.Count == 1 && bDees.Contains("a"));
Assert.IsTrue(cDees.Count == 2 && cDees.Contains("a") && cDees.Contains("d"));
Assert.IsTrue(dDees.Count == 0);
Assert.IsTrue(dDees.Count == 0);
}
示例4: NonEmptyTest8
public void NonEmptyTest8()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
t.AddDependency("a", "c");
t.AddDependency("d", "c");
t.ReplaceDependees("c", new HashSet<string>() { "x", "y", "z" });
HashSet<String> cDees = new HashSet<string>(t.GetDependees("c"));
Assert.IsTrue(cDees.SetEquals(new HashSet<string>() { "x", "y", "z" }));
}
示例5: NonEmptyTest9
public void NonEmptyTest9()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
t.AddDependency("a", "c");
t.AddDependency("a", "b");
t.AddDependency("c", "b");
t.AddDependency("b", "d");
t.AddDependency("c", "b");
IEnumerator<string> e = t.GetDependees("a").GetEnumerator();
Assert.IsFalse(e.MoveNext());
e = t.GetDependees("b").GetEnumerator();
Assert.IsTrue(e.MoveNext());
String s1 = e.Current;
Assert.IsTrue(e.MoveNext());
String s2 = e.Current;
Assert.IsFalse(e.MoveNext());
Assert.IsTrue(((s1 == "a") && (s2 == "c")) || ((s1 == "c") && (s2 == "a")));
e = t.GetDependees("c").GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("a", e.Current);
Assert.IsFalse(e.MoveNext());
e = t.GetDependees("d").GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("b", e.Current);
Assert.IsFalse(e.MoveNext());
}
示例6: StressTest1
public void StressTest1()
{
// Dependency graph
DependencyGraph t = new DependencyGraph();
// A bunch of strings to use
const int SIZE = 200;
string[] letters = new string[SIZE];
for (int i = 0; i < SIZE; i++)
{
letters[i] = ("" + (char)('a' + i));
}
// The correct answers
HashSet<string>[] dents = new HashSet<string>[SIZE];
HashSet<string>[] dees = new HashSet<string>[SIZE];
for (int i = 0; i < SIZE; i++)
{
dents[i] = new HashSet<string>();
dees[i] = new HashSet<string>();
}
// Add a bunch of dependencies
for (int i = 0; i < SIZE; i++)
{
for (int j = i + 1; j < SIZE; j++)
{
t.AddDependency(letters[i], letters[j]);
dents[i].Add(letters[j]);
dees[j].Add(letters[i]);
}
}
// Remove a bunch of dependencies
for (int i = 0; i < SIZE; i++)
{
for (int j = i + 4; j < SIZE; j += 4)
{
t.RemoveDependency(letters[i], letters[j]);
dents[i].Remove(letters[j]);
dees[j].Remove(letters[i]);
}
}
// Add some back
for (int i = 0; i < SIZE; i++)
{
for (int j = i + 1; j < SIZE; j += 2)
{
t.AddDependency(letters[i], letters[j]);
dents[i].Add(letters[j]);
dees[j].Add(letters[i]);
}
}
// Remove some more
for (int i = 0; i < SIZE; i += 2)
{
for (int j = i + 3; j < SIZE; j += 3)
{
t.RemoveDependency(letters[i], letters[j]);
dents[i].Remove(letters[j]);
dees[j].Remove(letters[i]);
}
}
// Make sure everything is right
for (int i = 0; i < SIZE; i++)
{
Assert.IsTrue(dents[i].SetEquals(new HashSet<string>(t.GetDependents(letters[i]))));
Assert.IsTrue(dees[i].SetEquals(new HashSet<string>(t.GetDependees(letters[i]))));
}
}
示例7: NonEmptyTest19
public void NonEmptyTest19()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("x", "b");
t.AddDependency("a", "z");
t.ReplaceDependents("b", new HashSet<string>());
t.AddDependency("y", "b");
t.ReplaceDependents("a", new HashSet<string>() { "c" });
t.AddDependency("w", "d");
t.ReplaceDependees("b", new HashSet<string>() { "a", "c" });
t.ReplaceDependees("d", new HashSet<string>() { "b" });
IEnumerator<string> e = t.GetDependees("a").GetEnumerator();
Assert.IsFalse(e.MoveNext());
e = t.GetDependees("b").GetEnumerator();
Assert.IsTrue(e.MoveNext());
String s1 = e.Current;
Assert.IsTrue(e.MoveNext());
String s2 = e.Current;
Assert.IsFalse(e.MoveNext());
Assert.IsTrue(((s1 == "a") && (s2 == "c")) || ((s1 == "c") && (s2 == "a")));
e = t.GetDependees("c").GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("a", e.Current);
Assert.IsFalse(e.MoveNext());
e = t.GetDependees("d").GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.AreEqual("b", e.Current);
Assert.IsFalse(e.MoveNext());
}
示例8: EmptyTest9
public void EmptyTest9()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("x", "y");
IEnumerator<string> e1 = t.GetDependees("y").GetEnumerator();
Assert.IsTrue(e1.MoveNext());
Assert.AreEqual("x", e1.Current);
IEnumerator<string> e2 = t.GetDependents("x").GetEnumerator();
Assert.IsTrue(e2.MoveNext());
Assert.AreEqual("y", e2.Current);
t.RemoveDependency("x", "y");
Assert.IsFalse(t.GetDependees("y").GetEnumerator().MoveNext());
Assert.IsFalse(t.GetDependents("x").GetEnumerator().MoveNext());
}
示例9: EmptyReplaceDependeesWithSomething
public void EmptyReplaceDependeesWithSomething()
{
DependencyGraph t = new DependencyGraph();
t.ReplaceDependees("a", new HashSet<string>() { "x", "y", "z" });
foreach (string value in t.GetDependees("a"))
System.Diagnostics.Debug.Write(value + ", ");
foreach (string value in t.GetDependents("x"))
System.Diagnostics.Debug.WriteLine(value);
foreach (string value in t.GetDependents("y"))
System.Diagnostics.Debug.WriteLine(value);
foreach (string value in t.GetDependents("z"))
System.Diagnostics.Debug.WriteLine(value);
Assert.AreEqual(3, t.Size);
}
示例10: ReplaceWithSameDependees
public void ReplaceWithSameDependees()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
t.AddDependency("a", "c");
t.AddDependency("d", "c");
t.ReplaceDependees("c", new HashSet<string>() { "a", "d" });
HashSet<String> cDees = new HashSet<string>(t.GetDependees("c"));
Assert.IsTrue(cDees.SetEquals(new HashSet<string>() { "a", "d" }));
}
示例11: MyTest
public void MyTest()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
t.AddDependency("a", "c");
t.AddDependency("b", "d");
t.AddDependency("d", "d");
Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "b", "c" }));
Assert.IsTrue(t.GetDependents("b").ToHashSet().SetEquals(new HashSet<string>() { "d" }));
Assert.IsTrue(t.GetDependents("c").ToHashSet().SetEquals(new HashSet<string>() { }));
Assert.IsTrue(t.GetDependents("d").ToHashSet().SetEquals(new HashSet<string>() { "d" }));
Assert.IsTrue(t.GetDependees("a").ToHashSet().SetEquals(new HashSet<string>() { }));
Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() { "a" }));
Assert.AreEqual(1, t["b"]);
Assert.IsTrue(t.GetDependees("c").ToHashSet().SetEquals(new HashSet<string>() { "a" }));
Assert.IsTrue(t.GetDependees("d").ToHashSet().SetEquals(new HashSet<string>() { "b","d" }));
Assert.AreEqual(2, t["d"]);
Assert.AreEqual(0, t["h"]);
Assert.AreEqual(0, t["a"]);
Assert.IsFalse(t.HasDependees("a"));
Assert.IsFalse(t.HasDependees("f"));
Assert.IsFalse(t.HasDependents("c"));
Assert.IsTrue(t.HasDependents("a"));
Assert.IsFalse(t.HasDependents("h"));
Assert.IsTrue(t.HasDependents("d"));
Assert.IsTrue(t.HasDependees("b"));
Assert.IsTrue(t.HasDependees("c"));
Assert.IsTrue(t.HasDependees("d"));
Assert.AreEqual(4, t.Size);
t.RemoveDependency("a", "b");
Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "c" }));
Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() { }));
t.AddDependency("a", "b");
t.AddDependency("a", "b");
t.ReplaceDependents("a", new HashSet<string>() { "x", "y", "x", "y" ,"z"});
Assert.IsTrue(t.GetDependents("a").ToHashSet().SetEquals(new HashSet<string>() { "x", "y","z"}));
Assert.AreEqual(5, t.Size);
t.ReplaceDependees("b", new HashSet<string>() { "x", "y", "x", "y" });
Assert.IsTrue(t.GetDependees("b").ToHashSet().SetEquals(new HashSet<string>() { "x", "y" }));
Assert.AreEqual(7, t.Size);
Assert.AreEqual(2, t["b"]);
//Assert.AreEqual(4, t.Size);
}