本文整理汇总了C#中Set.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# Set.AddElement方法的具体用法?C# Set.AddElement怎么用?C# Set.AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.AddElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethodAddElement
public void TestMethodAddElement()
{
Set<int> s = new Set<int>();
s.AddElement(0);
s.AddElement(1);
Assert.AreEqual(s.FindElement(1), true);
}
示例2: TestMethodRemoveElement
public void TestMethodRemoveElement()
{
Set<int> s = new Set<int>();
s.AddElement(0);
s.AddElement(1);
s.AddElement(1);
s.RemoveElement(1);
Assert.AreEqual(s.FindElement(1), false);
}
示例3: IntersectionTest
public void IntersectionTest()
{
Set<int> newSet = new Set<int>();
set.AddElement(1);
set.AddElement(2);
newSet.AddElement(0);
newSet.AddElement(1);
newSet = set.SetIntersection(newSet);
List<int> expectedList = new List<int> { 1 };
CollectionAssert.AreEqual(newSet.elementSet, expectedList);
}
示例4: TestMethodDifferenceWithSet
public void TestMethodDifferenceWithSet()
{
Set<int> s1 = new Set<int>();
s1.AddElement(0);
s1.AddElement(1);
s1.AddElement(2);
Set<int> s2 = new Set<int>();
s2.AddElement(1);
s2.AddElement(2);
s2.AddElement(3);
Set<int> s3 = new Set<int>();
s3.AddElement(0);
Assert.IsTrue(s3 == s1.DifferenceWithSet(s2));
}
示例5: TestMethodIntersectionWithSet
public void TestMethodIntersectionWithSet()
{
Set<int> s1 = new Set<int>();
s1.AddElement(0);
s1.AddElement(1);
s1.AddElement(2);
Set<int> s2 = new Set<int>();
s2.AddElement(1);
s2.AddElement(2);
s2.AddElement(3);
Set<int> s3 = new Set<int>();
s3.AddElement(1);
s3.AddElement(2);
Assert.IsTrue(s3 == s1.IntersectionWithSet(s2));
}
示例6: TestMethodUnionWithSet
public void TestMethodUnionWithSet()
{
Set<int> s1 = new Set<int>();
s1.AddElement(0);
s1.AddElement(1);
Set<int> s2 = new Set<int>();
s2.AddElement(1);
s2.AddElement(2);
s2.AddElement(3);
Set<int> s3 = new Set<int>();
for (int i = 0; i < 4; i++)
{
s3.AddElement(i);
}
Assert.IsTrue(s3 == s1.UnionWithSet(s2));
}
示例7: BuildStructuring
public override Structuring BuildStructuring()
{
if (Structurings == null || Set == null)
throw new NullReferenceException();
if (IContainerProgressBar != null)
{
IContainerProgressBar.ResetProgressBar(1, 1, true);
IContainerProgressBar.UpdateProgressBar(0, "Running QMI algorithm...", true);
}
List<Attribute> list_att = new List<Attribute>();
int cont = 0;
foreach (Structuring s in Structurings)
{
foreach (Cluster c in s.Clusters.Values)
{
Attribute att = new Attribute("x" + cont, null);
cont++;
att.AttributeType = AttributeType.Numeric;
list_att.Add(att);
}
}
Set newset = new Set("Artificial");
newset.Attributes = new Attributes(list_att);
newset.ElementType = ElementType.Numeric;
foreach (Element e in Set.Elements)
{
List<object> values = new List<object>();
foreach (Structuring s in Structurings)
{
foreach (Cluster c in s.Clusters.Values)
{
double temp = c.HaveElement(e) ? 1 : 0;
temp = temp - ((double)c.ElementsCount / (double)Set.ElementsCount);
values.Add(temp);
}
}
Element newelement = new Element(newset, values);
newelement.Name = e.Name;
newelement.Index = e.Index;
newset.AddElement(newelement);
}
KMeans kms = new KMeans(newset, new EuclideanDistance() { AttributesToCalculateProximity = newset.Attributes.Values });
kms.ClustersCount = ClusterCount;
kms.IterationsCount = IterationsCount;
kms.Seed = Environment.TickCount;
kms.IContainerProgressBar = IContainerProgressBar;
Structuring art_struct = kms.BuildStructuring();
List<Cluster> clusters = new List<Cluster>();
cont = 0;
foreach (Cluster c in art_struct.Clusters.Values)
{
Cluster temp = new Cluster("C-" + cont);
cont++;
foreach (Element item in c.Elements)
{
temp.AddElement(Set[item.Index]);
}
clusters.Add(temp);
}
Dictionary<string, Cluster> temp_dic=new Dictionary<string,Cluster>();
foreach (Cluster item in clusters)
{
temp_dic.Add(item.Name, item);
}
Structuring real_struct = new Partition() { Clusters = temp_dic };
return real_struct;
}