当前位置: 首页>>代码示例>>C#>>正文


C# Set.AddElement方法代码示例

本文整理汇总了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);
 }
开发者ID:molochiy,项目名称:Education,代码行数:7,代码来源:UnitTest1.cs

示例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);
 }
开发者ID:molochiy,项目名称:Education,代码行数:9,代码来源:UnitTest1.cs

示例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);
 }
开发者ID:KudryavtsevAndrey,项目名称:SPBU-Studying,代码行数:11,代码来源:SetTests.cs

示例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));
 }
开发者ID:molochiy,项目名称:Education,代码行数:14,代码来源:UnitTest1.cs

示例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));
 }
开发者ID:molochiy,项目名称:Education,代码行数:15,代码来源:UnitTest1.cs

示例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));
 }
开发者ID:molochiy,项目名称:Education,代码行数:16,代码来源:UnitTest1.cs

示例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;            
        }
开发者ID:svegapons,项目名称:clustering_ensemble_suite,代码行数:80,代码来源:QMI.cs


注:本文中的Set.AddElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。