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


C# Collections.Set类代码示例

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


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

示例1: SynchronizedSet

		/// <summary>
		/// Constructs a thread-safe <c>Set</c> wrapper.
		/// </summary>
		/// <param name="basisSet">The <c>Set</c> object that this object will wrap.</param>
		public SynchronizedSet(Set basisSet)
		{
			_basisSet = basisSet;
			_syncRoot = basisSet.SyncRoot;
			if(_syncRoot == null)
				throw new NullReferenceException("The Set you specified returned a null SyncRoot.");
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:11,代码来源:SynchronizedSet.cs

示例2: Union

		/// <summary>
		/// Performs a "union" of the two sets, where all the elements
		/// in both sets are present.  That is, the element is included if it is in either <c>a</c> or <c>b</c>.
		/// Neither this set nor the input set are modified during the operation.  The return value
		/// is a <c>Clone()</c> of this set with the extra elements added in.
		/// </summary>
		/// <param name="a">A collection of elements.</param>
		/// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
		/// Neither of the input objects is modified by the union.</returns>
		public Set Union(Set a)
		{
			Set resultSet = (Set)this.Clone();
			if(a != null)
				resultSet.AddAll(a);
			return resultSet;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:16,代码来源:Set.cs

示例3: Refine

 public BinaryDecisionTree Refine(string prop, Set<int> enabledStates)
 {
     // dont refine already added property
     if (this.property.Equals(prop))
         return this;
     if (states.IsEmpty)
         return this;
     Set<int> s1 = states.Intersect(enabledStates);
     Set<int> s2 = states.Difference(enabledStates);
     if (this.trueEdge != null) this.trueEdge.Refine(prop,s1);
     if (this.falseEdge != null) this.falseEdge.Refine(prop,s2);
     
     if (this.trueEdge == null && this.falseEdge == null)
     {
         //if (!s1.IsEmpty)
         //{
             this.trueEdge = new BinaryDecisionTree(prop, null, null,this.maxValue,this.minValue, s1);
         //}
         //else this.trueEdge = null;
         //if (!s2.IsEmpty)
         //{
            this.falseEdge = new BinaryDecisionTree(prop, null, null,this.maxValue,this.minValue, s2);
         //}
         //else this.falseEdge = null;
     }
     return this;
 }
开发者ID:juhan,项目名称:NModel,代码行数:27,代码来源:AbstractMDP.cs

示例4: CometServer

 public CometServer()
 {
     _clients = new Dictionary<string, CometClient>();
     _pathIndex = new Dictionary<string, List<CometClient>>();
     _usernameIndex = new Dictionary<string, List<CometClient>>();
     _requestPaths = new Set<string>();
 }
开发者ID:sidecut,项目名称:xaeios,代码行数:7,代码来源:CometServer.cs

示例5: getEdgesBetween

 /// <summary>
 /// Returns all Edges that connect the two nodes (which are assumed to be different).
 /// </summary>
 /// <param name="node0"></param>
 /// <param name="node1"></param>
 /// <returns></returns>
 public static IList getEdgesBetween(Node node0, Node node1)
 {
     IList edges0 = DirectedEdge.ToEdges(node0.OutEdges.Edges);
     Set<DirectedEdge> commonEdges = new Set<DirectedEdge>(edges0.Cast<DirectedEdge>());
     IList edges1 = DirectedEdge.ToEdges(node1.OutEdges.Edges);
     commonEdges.RemoveMany(edges1.Cast<DirectedEdge>());
     return new ArrayList(commonEdges);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:Node.cs

示例6: CreateSet

		/// <summary>Create the Set just once</summary>
		private static void CreateSet()
		{
			lock(typeof(MessageSequencer))
			{
				if (msgs != null)
					return;
				msgs = new Set<int>(s_seqMessages);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:10,代码来源:MessageSequencer.cs

示例7: BinaryDecisionTree

 public BinaryDecisionTree(string prop, BinaryDecisionTree t, BinaryDecisionTree f, double maxv, double minv, Set<int> setStates)
 {
     this.property = prop;
     this.trueEdge = t;
     this.falseEdge = f;
     this.maxValue = maxv;
     this.minValue = minv;
     this.states = setStates;
 }
开发者ID:juhan,项目名称:NModel,代码行数:9,代码来源:AbstractMDP.cs

示例8: UpdateFront

        void UpdateFront() {
            var newFrontEdges = new Set<CdtEdge>();
            foreach (var t in addedTriangles)
                foreach (var e in t.Edges)
                    if (e.CwTriangle == null || e.CcwTriangle == null)
                        newFrontEdges.Insert(e);

            foreach (var e in newFrontEdges)
                AddEdgeToFront(e);
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:10,代码来源:EdgeInserter.cs

示例9: Main

 static void Main(string[] args)
 {
     var stackOfValues = new Stack<string>();
     GetInitialValuesFromArgs(args, ref stackOfValues);
     var demoSet1 = new Set<string>(stackOfValues.ToArray());
     Console.WriteLine(demoSet1.ToString());
     var demoSet3 = new SortedSet(stackOfValues.ToArray());
     Console.WriteLine(demoSet3.ToString());
     Console.ReadKey();
 }
开发者ID:RavingRabbit,项目名称:Labs,代码行数:10,代码来源:Program.cs

示例10: TestSetDifference

 public void TestSetDifference(Set<string> setFirst, Set<string> setSecond, Set<string> resultSet)
 {
     setFirst.Difference(setSecond);
     var iteratorFirst = setFirst.GetEnumerator();
     var resultIterator = resultSet.GetEnumerator();
     while (iteratorFirst.MoveNext() && resultIterator.MoveNext())
     {
         Assert.AreEqual(iteratorFirst.Current, resultIterator.Current);
     }
 }
开发者ID:ZheldakArtem,项目名称:EPAM.Summer.Day10-11.Zheldak,代码行数:10,代码来源:SetTest.cs

示例11: NumberOfActiveNodesIsUnderThreshold

 internal static bool NumberOfActiveNodesIsUnderThreshold(List<Edge> inParentEdges, List<Edge> outParentEdges, int threshold) {
     var usedNodeSet = new Set<Node>();
     foreach (var edge in inParentEdges) 
         if(SetOfActiveNodesIsLargerThanThreshold((Cluster)edge.Target, edge.Source, usedNodeSet, threshold))
            return false;
     
     foreach (var edge in outParentEdges) 
         if(SetOfActiveNodesIsLargerThanThreshold((Cluster)edge.Source, edge.Target, usedNodeSet, threshold))
           return false;
     
     return true;
 }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:12,代码来源:ShapeCreatorForRoutingToParents.cs

示例12: IsSimple

 /// <summary>
 /// A MultiPoint is simple if it has no repeated points.
 /// </summary>
 public bool IsSimple(IMultiPoint mp)
 {
     if (mp.IsEmpty) 
         return true;
     Set<ICoordinate> points = new Set<ICoordinate>();
     for (int i = 0; i < mp.NumGeometries; i++)
     {
         IPoint pt = (IPoint) mp.GetGeometryN(i);
         ICoordinate p = pt.Coordinate;
         if (points.Contains(p))
             return false;
         points.Add(p);
     }
     return true;
 }   
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:IsSimpleOp.cs

示例13: SelectAction

        /// <summary>
        /// Select an action that is enabled in the current state
        /// and whose action symbol is in the set <paramref name="actionSymbols"/>.
        /// Use coverage points and reward policy.
        /// </summary>
        /// <param name="actionSymbols">set of candidate action symbols</param>
        /// <returns>the chosen action or null if no choice is possible</returns>
        public override Action SelectAction(Set<Symbol> actionSymbols)
        {
            if (actionSymbols == null)
                throw new ArgumentNullException("actionSymbols");

            if (actionSymbols.IsEmpty)
                return null;

            Sequence<Action> actions = new Sequence<Action>(this.GetEnabledActions(actionSymbols));
            if (actions.IsEmpty)
                return null;

            Action a = ChooseAction(actions, this.CurrentState); //choose a tester action
            //System.Console.WriteLine("Chosen Action " + a.ToString());
            return a;
        }
开发者ID:juhan,项目名称:NModel,代码行数:23,代码来源:Algorithms.cs

示例14: IntersectionTest

        public void IntersectionTest()
        {
            Set<int> a = new Set<int>();
            for(int i = 0; i < 16; i += 2)
                a.Add(i);

            Set<int> b = new Set<int>();
            for(int i = 0; i < 16; i += 3)
                b.Add(i);

            Set<int> inter = a.Intersect(b);

            Assert.AreEqual(3, inter.Count, "A01");
            Assert.AreEqual(0, inter[0], "A02");
            Assert.AreEqual(6, inter[1], "A03");
            Assert.AreEqual(12, inter[2], "A04");
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:17,代码来源:SetTest.cs

示例15: minusTest

        public void minusTest()
        {
            Collections.Set<int> s = new Collections.Set<int>();
            Collections.Set<int> s2 = new Collections.Set<int>();
            int[] a = { 1, 5, 6, 9 };
            int[] b = { 1, 4, 7, 9 };

            for (int i = 0; i < a.Length; i++)
            {
                s += (a[i]);
                s2 += (b[i]);
            }

            for (int i = 0; i < a.Length; i++)
            {
                s -= (a[i]);
                s2 -= (b[i]);
            }

            Assert.AreEqual(0, s.size());
            Assert.AreEqual(0, s2.size());
        }
开发者ID:sankosk,项目名称:TPP-University-subject-,代码行数:22,代码来源:SetTest.cs


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