• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ClusterAlgorithm

 public ClusterAlgorithm(Set set, Proximity diss)
 {
     if (set == null || diss == null)
         throw new ArgumentNullException("Parametro Incorrecto en el constructor de la clase ClusterAlgorithm");
     this.Set = set;
     this.Proximity = diss;
 }
开发者ID:svegapons,项目名称:segmentation_ensemble_suite,代码行数:7,代码来源:ClusterAlgorithm.cs


示例17: PopulateChartSet

        public static ChartSet PopulateChartSet(Set set, IEnumerable<int> monthsInSetsData, IEnumerable<int> weeksInSetsData, DateTime startDate, DateTime endDate)
        {
            ChartSet chartSet = new ChartSet();

            chartSet.Name = set.Name;
            chartSet.Id = set.Id;
            //#######################################################################
            // Start Building the set month statistics (NOTICE: that the calculation is intended to calculate by aggregating all activities by month regardless of the year the month belongs to)
            //#######################################################################
            chartSet.ChartSetMonthsData = new List<ChartSetMonthData>();
            foreach (var month in monthsInSetsData)
            {
                chartSet.ChartSetMonthsData.Add(new ChartSetMonthData
                {
                    ActivityCount = set.Exercises.Where(o => o.ExerciseRecords.Any(m => m.Date.Month == month)).Count(),
                    StartDate = DateTime.Now.StartOfMonth(month),
                    EndDate = DateTime.Now.EndOfMonth(month),
                    MonthNumber = month
                });
            }
            //chartSet.ChartSetMonthsData.OrderBy(o => o.MonthNumber);
            //#######################################################################

            //#######################################################################
            // Start Building the set weeks statistics (NOTICE: that the calculation is intended to calculate by aggregating all activities by week regardless of the year the week belongs to)
            //#######################################################################
            chartSet.ChartSetWeeksData = new List<ChartSetWeekData>();
            foreach (var week in weeksInSetsData)
            {
                //var er = set.Exercises.Select(o => o.ExerciseRecords.Where(m => m.Date.WeekOfDate() == week && m.Date >= startDate && m.Date <= endDate)).ElementAtOrDefault(0);
                var er = set.Exercises.Select(o => o.ExerciseRecords.FirstOrDefault( m => m.Date.WeekOfDate() == week)).ElementAtOrDefault(0);

                chartSet.ChartSetWeeksData.Add(new ChartSetWeekData
                {
                    ActivityCount = set.Exercises.Where(o => o.ExerciseRecords.Any(m => m.Date.WeekOfDate() == week)).Count(),
                    StartDate = DateTimeExtensions.StartOfWeekNumber(er != null ? er.Date.Year : DateTime.Now.Year, week),
                    EndDate = DateTimeExtensions.EndOfWeekNumber(er != null ? er.Date.Year : DateTime.Now.Year, week),
                    WeekNumber = week
                });
            }
            //chartSet.ChartSetWeeksData.OrderBy(o => o.WeekNumber);
            chartSet.TotalActivityCount = chartSet.ChartSetMonthsData.Sum(ac => ac.ActivityCount);
            //#######################################################################

            //#######################################################################
            // Start creating chart data for excercises
            //#######################################################################
            chartSet.ChartSetExercises = new List<ChartExercise>();

            foreach (var exercise in set.Exercises)
            {
                ChartExercise chartExercise = ChartsHelper.PopulateChartExercise(exercise, monthsInSetsData, weeksInSetsData, startDate, endDate);
                // Final step is to add the loaded exercise data into the corresponding set that is to be returned to the client
                chartSet.ChartSetExercises.Add(chartExercise);
            }
            //#######################################################################

            // Final step is to add the loaded set data that is to be returned to the client
            return (chartSet);
        }
开发者ID:hguomin,项目名称:MyFitnessTracker,代码行数:60,代码来源:ChartsHelper.cs


示例18: ComputeContainingLoopMap

    public static Dictionary<CFGBlock, List<CFGBlock>> ComputeContainingLoopMap(ICFG cfg)
    {
      Contract.Requires(cfg != null);
      Contract.Ensures(Contract.Result<Dictionary<CFGBlock, List<CFGBlock>>>() != null);

      var result = new Dictionary<CFGBlock, List<CFGBlock>>();
      var visitedSubroutines = new Set<int>();
      var pendingSubroutines = new Stack<Subroutine>();
      var pendingAPCs = new Stack<APC>();

      var graph = cfg.AsBackwardGraph(includeExceptionEdges:false, skipContracts:true);
      foreach (var loophead in cfg.LoopHeads)
      {
        // push back-edge sources
        var loopPC = new APC(loophead, 0, null);
        foreach (var pred in cfg.Predecessors(loopPC))
        {
          if (cfg.IsForwardBackEdge(pred, loopPC))
          {
            var normalizedPred = new APC(pred.Block, 0, null);
            pendingAPCs.Push(normalizedPred);
          }
        }
        var visit = new DepthFirst.Visitor<APC, Unit>(graph,
          (APC pc) =>
          {
            if (pc.SubroutineContext != null)
            {
              // push continuation PC
              pendingAPCs.Push(new APC(pc.SubroutineContext.Head.One, 0, null));
              if (visitedSubroutines.AddQ(pc.Block.Subroutine.Id))
              {
                pendingSubroutines.Push(pc.Block.Subroutine);
              }
              return false; // stop exploration
            }
            return !pc.Equals(loopPC);
          });

        while (pendingAPCs.Count > 0)
        {
          var root = pendingAPCs.Pop();
          visit.VisitSubGraphNonRecursive(root);

          while (pendingSubroutines.Count > 0)
          {
            var sub = pendingSubroutines.Pop();
            pendingAPCs.Push(new APC(sub.Exit, 0, null));
          }
        }

        foreach (var visited in visit.Visited)
        {
          if (visited.SubroutineContext != null) continue; // ignore non-primary pcs
          MaterializeContainingLoop(result, visited.Block).AssumeNotNull().Add(loophead);
        }
      }

      return result;
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:60,代码来源:LoopUtils.cs


示例19: UpdateRegionsForPossibleJumpersAndInsertJumpers

        /// <summary>
        /// some other jumpers may stop being ones if the jump 
        /// was just in to their destination layer, so before the actual 
        /// jump we have to recheck if the jump makes sense
        /// 
        /// </summary>
        /// <param name="jumperLayer">old layer of jumper</param>
        /// <param name="jumper"></param>
        void UpdateRegionsForPossibleJumpersAndInsertJumpers(int jumperLayer, int jumper) {
            Set<int> neighborPossibleJumpers = new Set<int>();
            //update possible jumpers neighbors
            foreach (int v in new Pred(dag, jumper))
                if (IsJumper(v)) {
                    this.CalculateRegionAndInsertJumper(v);
                    neighborPossibleJumpers.Insert(v);
                }

            foreach (int v in new Succ(dag, jumper))
                if (IsJumper(v)) {
                    this.CalculateRegionAndInsertJumper(v);
                    neighborPossibleJumpers.Insert(v);
                }

            List<int> possibleJumpersToUpdate = new List<int>();

            foreach (KeyValuePair<int, IntPair> kv in this.possibleJumperFeasibleIntervals) {
                if (!neighborPossibleJumpers.Contains(kv.Key))
                    if (kv.Value.x > jumperLayer && kv.Value.y < jumperLayer)
                        possibleJumpersToUpdate.Add(kv.Key);
            }

            foreach (int v in possibleJumpersToUpdate)
                this.CalculateRegionAndInsertJumper(v);
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:34,代码来源:Balancing.cs


示例20: Merge

		/// <summary>
		/// This is the main entry point.
		/// </summary>
		public XmlNode Merge(XmlNode newMaster, XmlNode oldConfigured, XmlDocument dest, string oldLayoutSuffix)
		{
			// As a result of LT-14650, certain bits of logic regarding copied views and duplicated nodes
			// were brought inside of the Merge.
			m_newMaster = newMaster;
			m_oldConfigured = oldConfigured;
			m_dest = dest;
			m_insertedMissing = new Set<XmlNode>();
			m_output = m_dest.CreateElement(newMaster.Name);
			m_layoutParamAttrSuffix = oldLayoutSuffix;
			CopyAttributes(m_newMaster, m_output);
			int startIndex = 0;
			BuildOldConfiguredPartsDicts();
			while (startIndex < m_newMaster.ChildNodes.Count)
			{
				XmlNode currentChild = m_newMaster.ChildNodes[startIndex];
				if (IsMergeableNode(currentChild))
				{
					int limIndex = startIndex + 1;
					while (limIndex < m_newMaster.ChildNodes.Count && m_newMaster.ChildNodes[limIndex].Name == currentChild.Name)
						limIndex++;
					CopyParts(startIndex, limIndex);
					startIndex = limIndex;
				}
				else
				{
					CopyToOutput(currentChild);
					startIndex++;
				}
			}
			return m_output;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:35,代码来源:LayoutMerger.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SetPasswordViewModel类代码示例发布时间:2022-05-24
下一篇:
C# SessionStateItemExpireCallback类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap