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


C# SortedSet.Remove方法代码示例

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


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

示例1: CountCirc

 public CountCirc(int el)
 {
     quantity = 2;
     primes = new SortedSet<int>(Sift(el));
     primes.Remove(2);
     primes.Remove(5);
 }
开发者ID:AlTTfT,项目名称:CircularPrime,代码行数:7,代码来源:CountCirc.cs

示例2: Remove

		public void Remove ()
		{
			var set = new SortedSet<int> ();
			Assert.IsTrue (set.Add (2));
			Assert.IsTrue (set.Add (4));
			Assert.AreEqual (2, set.Count);
			Assert.IsTrue (set.Remove (4));
			Assert.IsTrue (set.Remove (2));
			Assert.AreEqual (0, set.Count);
			Assert.IsFalse (set.Remove (4));
			Assert.IsFalse (set.Remove (2));
		}
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:12,代码来源:SortedSetTest.cs

示例3: Remove

        public void Remove(byte[] key)
        {
            AssertValidKey(key);
            //find the element while adding to moveCandidates
            SortedSet<HashTableElement> moveCandidates = new SortedSet<HashTableElement>();
            HashTableElement removingElement = null;
            foreach (var hashTableElement in GetElementWithKeyEnumerable(key))
            {
                Debug.Assert(moveCandidates.Add(hashTableElement));
                removingElement = hashTableElement;
            }
            Debug.Assert(removingElement != null, "GetElementWithKeyEnumberable() should have returned at least one element or thrown an exception");

            moveCandidates.Remove(removingElement);

            //null out the element
            WipeArrayAt(removingElement.Index);

            //rehash the elements between the hash and the removed element
            foreach (var moveCandidate in moveCandidates)
            {
                Debug.Assert(!moveCandidate.Key.EqualsBytes(NullKey), "GetElementWithKeyEnumerable() should not return any null elements");
                WipeArrayAt(moveCandidate.Index);
                Put(moveCandidate.Key, moveCandidate.Value);
            }
        }
开发者ID:glenwatson,项目名称:Distributed-Database,代码行数:26,代码来源:PersistentHashTable.cs

示例4: getAccesses

        /// <summary>
        ///     Provides all the function calls related to this namespace
        /// </summary>
        /// <param name="system">The system in which the calls should be gathered</param>
        /// <param name="container">If provided, indicates that the calls should be limited to a given container</param>
        /// <returns></returns>
        public static List<AccessMode> getAccesses(EFSSystem system, IEnclosesNameSpaces container = null)
        {
            SortedSet<ProcedureOrFunctionCall> procedureCalls = new SortedSet<ProcedureOrFunctionCall>();
            SortedSet<AccessToVariable> accessesToVariables = new SortedSet<AccessToVariable>();
            foreach (Usage usage in system.FindReferences(IsCallableOrIsVariable.INSTANCE))
            {
                ModelElement target = (ModelElement) usage.Referenced;
                ModelElement source = usage.User;

                NameSpace sourceNameSpace = getCorrespondingNameSpace(source, container, true);
                NameSpace targetNameSpace = getCorrespondingNameSpace(target, container, false);

                if (IsCallable.Predicate(usage.Referenced))
                {
                    if (considerCall(usage, container, sourceNameSpace, targetNameSpace))
                    {
                        procedureCalls.Add(new ProcedureOrFunctionCall(sourceNameSpace, targetNameSpace,
                            (ICallable) target));
                    }
                }
                else
                {
                    // IsVariable(usage.Referenced)
                    if (considerVariableReference(usage, container, sourceNameSpace, targetNameSpace))
                    {
                        Usage.ModeEnum mode = (Usage.ModeEnum) usage.Mode;

                        // Find a corresponding access to variable (same source and target namespaces, and same variable
                        AccessToVariable otherAccess = null;
                        foreach (AccessToVariable access in accessesToVariables)
                        {
                            if (access.Target == usage.Referenced && access.Source == sourceNameSpace &&
                                access.Target == targetNameSpace)
                            {
                                otherAccess = access;
                                break;
                            }
                        }

                        if (otherAccess != null)
                        {
                            if (otherAccess.AccessMode != mode)
                            {
                                // Since the access mode is different, one of them is either Read or ReadWrite and the other is ReadWrite or Write.
                                // So, in any case, the resulting access mode is ReadWrite
                                accessesToVariables.Remove(otherAccess);
                                accessesToVariables.Add(new AccessToVariable(sourceNameSpace, targetNameSpace,
                                    (IVariable) target, Usage.ModeEnum.ReadAndWrite));
                            }
                            else
                            {
                                // Already exists, do nothing
                            }
                        }
                        else
                        {
                            // Does not already exists, insert it in the list
                            accessesToVariables.Add(new AccessToVariable(sourceNameSpace, targetNameSpace,
                                (IVariable) target, mode));
                        }
                    }
                }
            }

            // Build the results based on the intermediate results
            List<AccessMode> retVal = new List<AccessMode>();
            retVal.AddRange(procedureCalls);
            retVal.AddRange(accessesToVariables);

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:77,代码来源:IEnclosesNameSpaces.cs

示例5: ViewCount

		public void ViewCount ()
		{
			var set = new SortedSet<int> { 1, 3, 4, 5, 6, 7, 8, 9 };
			var view = set.GetViewBetween (4, 8);

			Assert.AreEqual (5, view.Count);
			set.Remove (5);
			Assert.AreEqual (4, view.Count);
			set.Add (10);
			Assert.AreEqual (4, view.Count);
			set.Add (6);
			Assert.AreEqual (4, view.Count);
			set.Add (5);
			Assert.AreEqual (5, view.Count);
		}
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:15,代码来源:SortedSetTest.cs

示例6: GeneratePath

        private List<PathCoordinate> GeneratePath(PathCoordinate start, PathCoordinate end, Size size, double maxDistance)
        {
            SortedSet<PathCoordinate> sortedPath = new SortedSet<PathCoordinate>(new PathCoordinateDistanceToTargetComparer());

            List<PathCoordinate> path = new List<PathCoordinate>();
            _firstCoordinate = start;
            _firstCoordinate.DistanceToTarget = _firstCoordinate.DistanceTo(end);

            PathCoordinate currentCoordinate = start;
            int loopsLeft = 1000;
            while (currentCoordinate != null && currentCoordinate != end && loopsLeft > 0)
            {
                currentCoordinate.Checked = true;
                loopsLeft--;
                PathCoordinate[] pathOptions = GetPathOptions(currentCoordinate, end, size, maxDistance);

                foreach (var option in pathOptions)
                {
                    double distance = currentCoordinate.DistanceFromStart + currentCoordinate.DistanceTo(option);
                    bool existsInPath = sortedPath.Contains(option);

                    if (!existsInPath || distance < option.DistanceFromStart)
                    {
                        option.PreviousCoordinate = currentCoordinate;

                        if (existsInPath)
                        {
                            sortedPath.Remove(option);
                            option.SetDistanceFromStartAndTarget(distance, option.DistanceTo(end));
                            sortedPath.Add(option);
                        }
                        else
                        {
                            option.SetDistanceFromStartAndTarget(distance, option.DistanceTo(end));
                            sortedPath.Add(option);
                        }
                    }
                }
                sortedPath.Remove(currentCoordinate);
                if (sortedPath.Count > 0)
                    currentCoordinate = sortedPath.Min;
                else
                    break;
            }

            if (currentCoordinate == null || currentCoordinate == _firstCoordinate)
                return null;

            // currentCoordinate is destination so walk up previous coordinates and add to list, then reverse
            List<PathCoordinate> result = new List<PathCoordinate> {currentCoordinate};
            while (currentCoordinate.PreviousCoordinate != null)
            {
                result.Add(currentCoordinate.PreviousCoordinate);
                currentCoordinate = currentCoordinate.PreviousCoordinate;
            }

            result.Reverse();
            return result;
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:59,代码来源:PathFinder.cs


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