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


C# Set类代码示例

本文整理汇总了C#中Set的典型用法代码示例。如果您正苦于以下问题:C# Set类的具体用法?C# Set怎么用?C# Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Set类属于命名空间,在下文中一共展示了Set类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Graph_with_one_edge_has_size_1

 public void Graph_with_one_edge_has_size_1()
 {
     var vertices = 1.Upto(2).ToSet();
     var edges = new Set<IDirectedEdge<int>> { new DirectedEdge<int>(1, 2) };
     var graph = new DirectedGraph<int>(vertices, edges);
     graph.Size().ShouldEqual(1);
 }
开发者ID:drbatty,项目名称:maths-core,代码行数:7,代码来源:DirectedGraphTests.cs

示例2: When_Key_Exists_Append_Succeeds

        public void When_Key_Exists_Append_Succeeds()
        {
            const string key = "Hello";
            const string expected = "Hello!";

            //clean up old keys
            var deleteOperation = new Delete(key, GetVBucket(), Converter, Serializer);
            IOStrategy.Execute(deleteOperation);

            deleteOperation = new Delete(key + "!", GetVBucket(),  Converter, Serializer);
            IOStrategy.Execute(deleteOperation);

            //create the key
            var set = new Set<string>(key, "Hello", GetVBucket(), Converter);
            var addResult = IOStrategy.Execute(set);
            Assert.IsTrue(addResult.Success);

            var append = new Append<string>(key, "!", Serializer, GetVBucket(), Converter);
            var result = IOStrategy.Execute(append);

            
            Assert.IsTrue(result.Success);
            Assert.AreEqual(string.Empty, result.Value);

            var get = new Get<string>(key, GetVBucket(),  Converter, Serializer);
            var getResult = IOStrategy.Execute(get);
            Assert.AreEqual(expected, getResult.Value);
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:28,代码来源:AppendOperationTests.cs

示例3: FixRange

 // <summary>
 // Fixes the range of the restriction in accordance with <paramref name="range" />.
 // Member restriction must be complete for this operation.
 // </summary>
 internal override DomainBoolExpr FixRange(Set<Constant> range, MemberDomainMap memberDomainMap)
 {
     Debug.Assert(IsComplete, "Ranges are fixed only for complete scalar restrictions.");
     var newPossibleValues = memberDomainMap.GetDomain(RestrictedMemberSlot.MemberPath);
     BoolLiteral newLiteral = new ScalarRestriction(RestrictedMemberSlot, new Domain(range, newPossibleValues));
     return newLiteral.GetDomainBoolExpression(memberDomainMap);
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:ScalarRestriction.cs

示例4: Test_Timed_Execution

        public void Test_Timed_Execution()
        {
            var converter = new DefaultConverter();
            var transcoder = new DefaultTranscoder(converter);
            var vbucket = GetVBucket();
            int n = 1000; //set to a higher # if needed

            using (new OperationTimer())
            {
                var key = string.Format("key{0}", 111);

                for (var i = 0; i < n; i++)
                {
                    var set = new Set<int?>(key, 111, vbucket, transcoder, OperationLifespanTimeout);
                    var get = new Get<int?>(key, vbucket, transcoder, OperationLifespanTimeout);

                    var result = IOService.Execute(set);
                    Assert.IsTrue(result.Success);

                    var result1 = IOService.Execute(get);
                    Assert.IsTrue(result1.Success);
                    Assert.AreEqual(111, result1.Value);
                }
            }
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:25,代码来源:GetSetPerformanceTests.cs

示例5: GameDB

 public GameDB(params Type[] types)
 {
     if (types == null || types.Length == 0)
     throw new Exception("Need at least one type");
       foreach (Type type in types)
     entities[type] = new Set<object>();
 }
开发者ID:Felixdev,项目名称:dogfight2008,代码行数:7,代码来源:GameDB.cs

示例6: findClose

        /// <summary>
        ///  This function takes a set of peaks, a lookup mass, and 
        ///  finds the closest peak with in a certain tolerance. If 
        ///  multiple peaks exists with in the window, most closest peak
        ///  is selected
        /// </summary>
        /// <param name="peaks">A spectrum</param>
        /// <param name="mz">Look up m/z</param>
        /// <param name="tolerance">Mass tolerance for look-up</param>
        /// <returns>Peak if found</returns>
        public static Peak findClose(Set<Peak> peaks, double mz, double tolerance)
        {
            Set<Peak>.Enumerator cur, min, max;

            min = peaks.LowerBound(new Peak(mz - tolerance));
            max = peaks.LowerBound(new Peak(mz + tolerance));
            if (!min.IsValid && !max.IsValid)
                return null;
            if (!min.IsValid && max.IsValid)
                return max.Current;
            if (min.IsValid && !max.IsValid)
                return min.Current;
            if (min.Current == max.Current)
                return null;

            // If we found multiple matching peaks,
            // return the closest peak.
            Peak best = min.Current;

            //find the peak closest to the desired mz
            double minDiff = Math.Abs(mz - best.mz);
            for (cur = min; cur.Current != max.Current; cur.MoveNext())
            {
                double curDiff = Math.Abs(mz - cur.Current.mz);
                if (curDiff < minDiff)
                {
                    minDiff = curDiff;
                    best = cur.Current;
                }
            }
            return best;
        }
开发者ID:hap-adong,项目名称:IDPicker,代码行数:42,代码来源:Package.cs

示例7: TemplateOptions

        public TemplateOptions()
        {
            Usings = new Set<string>(new[] { "System", "System.IO", "System.Web", "NHaml", "NHaml.Utils", "System.Collections.Generic" });
            References = new Set<string>(new[]
            {
                typeof(TemplateEngine).Assembly.Location, // NHaml
                typeof(INotifyPropertyChanged).Assembly.Location, // System
                typeof(HttpUtility).Assembly.Location // System.Web
            });
            AutoClosingTags = new Set<string>(new[] { "META", "IMG", "LINK", "BR", "HR", "INPUT" });
            ReferencedTypeHandles = new List<RuntimeTypeHandle>();
            MarkupRules = new List<MarkupRule>();
            _indentSize = 2;
            _templateBaseType = typeof(Template);
            _templateCompiler = new CSharp3TemplateCompiler();
            TemplateContentProvider = new FileTemplateContentProvider();

            AddRule(new EofMarkupRule());
            AddRule(new MetaMarkupRule());
            AddRule(new DocTypeMarkupRule());
            AddRule(new TagMarkupRule());
            AddRule(new ClassMarkupRule());
            AddRule(new IdMarkupRule());
            AddRule(new EvalMarkupRule());
            AddRule(new EncodedEvalMarkupRule());
            AddRule(new SilentEvalMarkupRule());
            AddRule(new PreambleMarkupRule());
            AddRule(new CommentMarkupRule());
            AddRule(new EscapeMarkupRule());
            AddRule(new PartialMarkupRule());
            AddRule(new NotEncodedEvalMarkupRule());
        }
开发者ID:Jeff-Lewis,项目名称:nhaml,代码行数:32,代码来源:TemplateOptions.cs

示例8: SymmetricTest

        public void SymmetricTest()
        {
            var a = new Set<int>(1, 2, 3);
            var b = new Set<int>(2, 3, 4);

            Console.WriteLine(a.Symmetric(b));
        }
开发者ID:rodriada000,项目名称:Mathos-Project,代码行数:7,代码来源:SetTest.cs

示例9: AddSets

        public void AddSets()
        {
            var a = new Set<int>(1, 2, 3, 4, 5);
            var b = new Set<int>(6, 7, 8, 9, 10);

            Console.WriteLine(a.Add(b).ToString());
        }
开发者ID:rodriada000,项目名称:Mathos-Project,代码行数:7,代码来源:SetTest.cs

示例10: IntersectionTest

        public void IntersectionTest()
        {
            var a = new Set<int>(1, 2, 3);
            var b = new Set<int>(2, 3, 4);

            Console.WriteLine(a.Intersection(b));
        }
开发者ID:rodriada000,项目名称:Mathos-Project,代码行数:7,代码来源:SetTest.cs

示例11: TransformSet

        /// <summary>
        /// Given a Set, produces a CSS property. 
        /// Implementers can override this method to customize support for CSS properties given a Set.
        /// For example if you want a Setter of "Foo" to produce a CSS property "Bar", you can filter it here.
        /// You must call this methods for Setter properties you don't wish to filter, so that the default implementation
        /// can generate CSS.
        /// </summary>
        /// <param name="set">The target Set.</param>
        /// <returns>The CSS property, in string form.</returns>
        public virtual string TransformSet(Set set)
        {
            // TODO: Some more type checking. I really don't like this entire method.
            switch (set.Property.ToLower())
            {
                case "width":
                    int widthResult;

                    if (int.TryParse(set.To, out widthResult))
                        return string.Format("width: {0}px;", widthResult);

                    break;
                case "height":
                    int heightResult;

                    if (int.TryParse(set.To, out heightResult))
                        return string.Format("height: {0}px;", heightResult);

                    break;
                case "background":
                    return string.Format("background-color: {0};", set.To);

                case "foreground":
                    return string.Format("color: {0};", set.To);

                case "padding":
                    return string.Format("padding: {0}px;", set.To);

                case "margin":
                    return string.Format("margin: {0}px;", set.To);

            }

            return string.Empty;
        }
开发者ID:ncarrillo,项目名称:pantheon,代码行数:44,代码来源:GeneratorBlock.cs

示例12: TestDirectedGraphEmptyHasEdgeTrue

 public void TestDirectedGraphEmptyHasEdgeTrue()
 {
     var vertices = 1.Upto(3).ToSet();
     var edges = new Set<IDirectedEdge<int>> { new DirectedEdge<int>(1, 2) };
     var graph = new DirectedGraph<int>(vertices, edges);
     graph.HasEdge(1, 2).ShouldBeTrue();
 }
开发者ID:drbatty,项目名称:maths-core,代码行数:7,代码来源:DirectedGraphTests.cs

示例13: Graph_with_one_vertex_has_order_1

 public void Graph_with_one_vertex_has_order_1()
 {
     var vertices = 1.WrapInList().ToSet();
     var edges = new Set<IDirectedEdge<int>>();
     var graph = new DirectedGraph<int>(vertices, edges);
     graph.Order().ShouldEqual(1);
 }
开发者ID:drbatty,项目名称:maths-core,代码行数:7,代码来源:DirectedGraphTests.cs

示例14: AddColumns

        public void AddColumns()
        {
            Column[] columns = new Column[] {
                new Column("Name", ColumnType.String),
                new Column("Age", ColumnType.Integer)
            };

            Set set = new Set(columns);

            NameValues values = new NameValues();
            values.Add("Name", "Adam");
            values.Add("Age", 800);

            set = set.AddTuple(values);

            Column[] newcolumns = new Column[] {
                new Column("Height", ColumnType.Integer),
                new Column("Weight", ColumnType.Integer)
            };

            var result = set.AddColumns(newcolumns);

            Assert.AreNotEqual(result, set);
            Assert.IsNotNull(result.Tuples);
            Assert.AreEqual(1, result.Tuples.Count());
            Assert.AreEqual(4, result.Columns.Count());

            Tuple tuple = result.Tuples.First();
            Assert.AreEqual("Adam", tuple[0]);
            Assert.AreEqual(800, tuple[1]);
            Assert.IsNull(tuple[2]);
            Assert.IsNull(tuple[3]);
        }
开发者ID:ajlopez,项目名称:SetTuples,代码行数:33,代码来源:SetTests.cs

示例15: NameSupply

 public NameSupply(IImSet<string> globals, NameSupply parent)
 {
     this.globals = globals ?? Constants.EmptyStringSet;
     boundInThisScope = new Set<string>();
     boundInChildScope = new Set<string>();
     this.parent = parent;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:7,代码来源:NameSupply.cs


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