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


C# SortedList.Select方法代码示例

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


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

示例1: InsertBlock

        public InsertBlock(Tuple<int, int> enumerationInfo, List<SentenceElement> sentenceElements)
        {
            _elements = new SortedList<int, SentenceElement>();
            _mainWord = null;

            foreach (var element in sentenceElements.FindAll(x => (x.Order >= enumerationInfo.Item1 && x.Order <= enumerationInfo.Item2)))
                _elements.Add(element.Order, element);
            var elementsList = _elements.Select(x => x.Value).ToList();

            foreach (var element in _elements)
            {
                var mainWordElement = sentenceElements.Find(x => elementsList.Find(y => y.Id == x.Id) == null && elementsList.Find(y => y.Id == x.ConjuctedWithId) != null);
                if (mainWordElement != null)
                    _mainWord = mainWordElement;
            }
        }
开发者ID:Ogonik,项目名称:LWS,代码行数:16,代码来源:InsertBlock.cs

示例2: CreateMapFromString

        public static IEnumerable<Waypoint> CreateMapFromString(IEnumerable<string> entries)
        {
            var waypoints = new SortedList<int, Waypoint>();

            foreach (string entryPassage in entries)
            {
                var data = entryPassage.Split(' ');
                var startPosition = int.Parse(data[0]);
                var endPosition = int.Parse(data[1]);
                var cost = int.Parse(data[2]);

                var startWaypoint = GetOrCreate(startPosition, waypoints);
                var destWaypoint = GetOrCreate(endPosition, waypoints);

                startWaypoint.Routes.Add(new Passage(destWaypoint, cost));
            }

            return waypoints.Select(x => x.Value);
        }
开发者ID:nlhans,项目名称:NWERC-2012,代码行数:19,代码来源:AdmiralSolver.cs

示例3: GetNextBoard

 public List<int> GetNextBoard(List<Card> board, SortedList<int, Card> deck)
 {
     return GetNextBoard(board.Select(c => c.Id).ToList(), deck.Select(c => c.Value.Id).ToList());
 }
开发者ID:nurdyguy,项目名称:MDU,代码行数:4,代码来源:IterationCalculator.cs

示例4: SortChildren

        /// <summary>
        /// Sorts the child nodes so that folders come first, then children, both in Alphabetical order.
        /// </summary>
        public void SortChildren()
        {
            SortedList<string, ProjectFileTreeNode> directoryChildren = new SortedList<string, ProjectFileTreeNode>();
            SortedList<string, ProjectFileTreeNode> fileChildren = new SortedList<string, ProjectFileTreeNode>();

            foreach (var child in childNodes)
            {
                if (child.IsFolder)
                    directoryChildren[child.Text] = child;
                else
                    fileChildren[child.Text] = child;
            }

            childNodes.Clear();

            childNodes.AddRange(directoryChildren.Select(c => c.Value));
            childNodes.AddRange(fileChildren.Select(c => c.Value));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:21,代码来源:ProjectFileTree.cs

示例5: FindNearestSystem

 public static ISystem FindNearestSystem(double x, double y, double z, bool removezerodiststar = false, double maxdist = 1000, SQLiteConnectionSystem cn = null)
 {
     SortedList<double, ISystem> distlist = new SortedList<double, ISystem>();
     GetSystemSqDistancesFrom(distlist, x, y, z, 1, removezerodiststar, maxdist,cn);
     return distlist.Select(v => v.Value).FirstOrDefault();
 }
开发者ID:amatos,项目名称:EDDiscovery,代码行数:6,代码来源:SystemClass.cs

示例6: SetRegistryToInstances

 public void SetRegistryToInstances(SortedList<string, CKAN.KSP> instances, string auto_start_instance)
 {
     Instances =
         instances.Select(kvpair => new Tuple<string, string>(kvpair.Key, kvpair.Value.GameDir())).ToList();
     AutoStartInstance = auto_start_instance;
 }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:6,代码来源:KSPManager.cs

示例7: TextMatches

        public virtual IEnumerable<IMatch> TextMatches(string text)
        {
            var tags = GetTags(text);

            // return to speed-up
            if (tags.Count == 0)
            {
                return new List<IMatch>();
            }

            var sortedList = new SortedList<int, ITagMatch>();
            
            foreach (var tag in tags)
            {
                sortedList.Add(tag.Index, tag);
            }

            sortedList = DeleteOverlapping(sortedList);

            var matchedPairs = new List<Tuple<ITagMatch, ITagMatch>>();
            var startsStack = new Stack<ITagMatch>();

            foreach (var tag in sortedList.Select(pair => pair.Value))
            {
                if (tag is IStartOrEndTagMatch)
                {
                    var startOrEndTag = tag as IStartOrEndTagMatch;

                    if (startOrEndTag.IsStart)
                    {
                        var start = startOrEndTag as IStartTagMatch;
                        if (start.HasEnding)
                        {
                            startsStack.Push(start);
                        }
                        else if (startsStack.Count == 0)
                        {
                            matchedPairs.Add(new Tuple<ITagMatch, ITagMatch>(start, start));
                        }
                    }
                    else
                    {
                        if (startsStack.Count > 0)
                        {
                            ITagMatch start;
                            var end = startOrEndTag as IEndTagMatch;

                            if (ignoreNoClosingError)
                            {
                                start = NonstrickStartTagSearch(startsStack, end, text);

                                if(start == null)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                start = startsStack.Pop();

                                if (!VerifyMatch(text, start, end))
                                {
                                    throw CreateParsingErrorExceptionAtPosition(Language.Message("TagMismatch", GetErrorString(start), GetErrorString(end)), start.Index);
                                }
                            }

                            matchedPairs.Add(new Tuple<ITagMatch, ITagMatch>(start, end));
                        }
                        else if (!ignoreNoClosingError)
                        {
                            throw CreateParsingErrorExceptionAtPosition(Language.Message("RedundantEndingTag", GetErrorString(tag)), tag.Index);
                        }
                    }
                }
                else
                {
                    startsStack.Push(tag);
                }
            }

            // non-StartOrEnd tags parsing e.g. **bold**
            var nonStartEndStartsStack = new Stack<ITagMatch>();
            var potentialEnds = startsStack.Where(e => !(e is IStartOrEndTagMatch)).ToList();
            potentialEnds.Reverse();

            foreach (var potentialEnd in potentialEnds)
            {
                var start = NonstrickStartTagSearch(nonStartEndStartsStack, potentialEnd, text);

                if (start != null && nonStartEndStartsStack.Count == 0)
                {
                    matchedPairs.Add(new Tuple<ITagMatch, ITagMatch>(start, potentialEnd));
                }
                else
                {
                    nonStartEndStartsStack.Push(potentialEnd);
                }
            }

            if (!ignoreNoClosingError && startsStack.Count > 0)
//.........这里部分代码省略.........
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:101,代码来源:EMTaggedElementsParser.cs

示例8: WriteRow

        public static void WriteRow(StreamWriter writer, SortedList<string, RelationalField> schema, RelationalEvent evt)
        {
            var values = new string[] {
                RelationalEvent.Serialize(evt._Id_),
                RelationalEvent.Serialize(evt._ParentId_),
                RelationalEvent.Serialize(evt._At_)
            }.Concat(
                schema.Select(x => evt[x.Key])
            );

            writer.WriteLine(string.Join("\t", values.Select(x => x)));
            writer.Flush();
        }
开发者ID:GrowingData,项目名称:Mung,代码行数:13,代码来源:RelationalEventFile.cs

示例9: ValidateCharacteristics

		/// <summary>
		/// The whole variables must be the same type.
		/// </summary>
		/// <param name="entities">object id,variable id, variable description</param>
		/// <returns></returns>
		private Return<object> ValidateCharacteristics(SortedList<int, SortedList<int, ICharacteristic>> entities)
		{
			Return<object> _answer = new Return<object>();
			try
			{
				int _minKey = entities.SelectMany(e => e.Value.Select(sl => sl.Key)).Min(k => k)
					, _maxKey = entities.SelectMany(e => e.Value.Select(sl => sl.Key)).Max(k => k);

				for (int _i = _minKey; _i <= _maxKey; _i++)
				{//characteristic to characteristic
					IEnumerable<SortedList<int, ICharacteristic>> _entitiesAll = entities.Select(e => e.Value);
					IEnumerable<SortedList<int, ICharacteristic>> _entitiesWithCharacteristic = _entitiesAll.Where(e => e.ContainsKey(_i));
					if (_entitiesWithCharacteristic.Any())
					{
						IEnumerable<ICharacteristic> _listOfCharacteristic = _entitiesWithCharacteristic.Select(e => e[_i]);
						IEnumerable<IGrouping<Type, ICharacteristic>> _groupByType = _listOfCharacteristic.GroupBy(c => c.GetType());
						if (_groupByType.Count() > 1)
						{
							string _message = string.Format("There are different types in characteristic {1}{0} ", Environment.NewLine, Convert.ToString(_i));
							_answer.theresError = true;
							_answer.error = Utility.GetError(new Exception(_message), this.GetType());
						}
					}

					if (_answer.theresError)
						break;
				}//characteristic to characteristic
			}
			catch (Exception _ex)
			{
				_answer.theresError = true;
				_answer.error = Utility.GetError(_ex, this.GetType());
			}
			return _answer;
		}
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:40,代码来源:GroupingUtility.cs

示例10: FillHoles

		/// <summary>
		/// 
		/// </summary>
		/// <param name="entities">object id,variable id, variable description</param>
		/// <returns></returns>
		private Return<object> FillHoles(SortedList<int, SortedList<int, ICharacteristic>> entities)
		{
			Return<object> _answer = new Return<object>();
			try
			{
				int _minKey = entities.SelectMany(e => e.Value.Select(sl => sl.Key)).Min(k => k)
					, _maxKey = entities.SelectMany(e => e.Value.Select(sl => sl.Key)).Max(k => k);

				for (int _i = _minKey; _i <= _maxKey; _i++)
				{//characteristic to characteristic
					IEnumerable<SortedList<int, ICharacteristic>> _entitiesAll = entities.Select(e => e.Value);
					IEnumerable<SortedList<int, ICharacteristic>> _entitiesWithCharacteristic = _entitiesAll.Where(e => e.ContainsKey(_i));
					IEnumerable<SortedList<int, ICharacteristic>> _entitiesWithoutTheCharacteristic = _entitiesAll.Except(_entitiesWithCharacteristic);

					if (_entitiesWithCharacteristic.Any())
					{
						IEnumerable<ICharacteristic> _listOfCharacteristic = _entitiesWithCharacteristic.SelectMany(o => o.Values);
						ICharacteristic _characteristic = _listOfCharacteristic.First();
						ICharacteristic _filler = _characteristic.FillHole(_listOfCharacteristic);
						foreach (SortedList<int, ICharacteristic> _list in _entitiesWithoutTheCharacteristic)
							_list.Add(_i, _filler.Clone());
					}
				}//characteristic to characteristic
			}
			catch (Exception _ex)
			{
				_answer.theresError = true;
				_answer.error = Utility.GetError(_ex, this.GetType());
			}
			return _answer;
		}
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:36,代码来源:GroupingUtility.cs

示例11: SelectFilesToKeep

        static bool SelectFilesToKeep(HashPointers ptr, out List<int> toKeep)
        {
            bool selectionSuccess = false;
            toKeep = new List<int>(Enumerable.Range(1, ptr.FileEntries.Count));
            bool decided = false;
            int choice = 0;

            bool canAutoSelect = false;
            List<int> oldestIDs = new List<int>();
            List<int> newestIDs = new List<int>();
            {
                // Read and register the timestamp when the files were last accessed
                // The oldest file (lowest timestamp) will be on the top of the list
                SortedList<DateTime, List<int>> timeStamps = new SortedList<DateTime, List<int>>(ptr.FileEntries.Count);
                PathEntry entry = new PathEntry();
                int currentID = 1;
                foreach (long offset in ptr.FileEntries)
                {
                    PathsFile.GetRecordAt(offset, out entry);
                    FileInfo fi = new FileInfo(entry.Path);

                    IEnumerable<DateTime> tsRegistered = timeStamps.Select(ts => ts.Key)
                        .Where(ts => ts.Date == fi.LastAccessTime.Date
                            && ts.Hour == fi.LastAccessTime.Hour
                            && ts.Minute == fi.LastAccessTime.Minute
                            && ts.Second == fi.LastAccessTime.Second);
                    if (tsRegistered.Count() == 1)
                        timeStamps[tsRegistered.First()].Add(currentID);
                    else
                    {
                        List<int> idList = new List<int>(1);
                        idList.Add(currentID);
                        timeStamps.Add(fi.LastAccessTime, idList);
                    }
                    ++currentID;
                }

                // If the oldest and newest files are the same, don't select any of them
                if (timeStamps.Count == 1 && (AutoOldest || AutoNewest))
                    Console.WriteLine("The files' age are equal. Unable to select oldest and newest ones.");
                else
                {
                    oldestIDs.AddRange(timeStamps.First().Value);
                    newestIDs.AddRange(timeStamps.Last().Value);
                    canAutoSelect = true;
                }
            }

            while (!selectionSuccess)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(new String('-', Console.WindowWidth - 1));
                DuplicateFileLog.WriteLine(new String('-', 24));
                Console.WriteLine("The following " + ptr.FileEntries.Count + " files are duplicate of each other");
                DuplicateFileLog.WriteLine("The following " + ptr.FileEntries.Count + " files are duplicate of each other");
                Console.ResetColor();
                if (Verbose)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Hash: " + ptr.Hash);
                    DuplicateFileLog.WriteLine("Hash: " + ptr.Hash);
                    Console.ResetColor();
                }

                if (!DryRun)
                {
                    Console.Write("Files marked ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("[ KEEP ]");
                    Console.ResetColor();
                    Console.Write(" will be kept. Files marked ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("[DELETE]");
                    Console.ResetColor();
                    Console.WriteLine(" will be deleted.");

                    if (!AutoNewest && !AutoOldest)
                        Console.WriteLine("Please select the files you wish to keep or delete.");
                    else
                        if (!canAutoSelect)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Was unable to automatically select " + (AutoOldest ? "oldest" : "newest") + " file to keep");
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Automatically selecting the " + (AutoOldest ? "OLDEST" : "NEWEST") + " file to keep");
                            Console.ResetColor();
                            toKeep.Clear();

                            if (AutoOldest)
                                toKeep.AddRange(oldestIDs);
                            else if (AutoNewest)
                                toKeep.AddRange(newestIDs);
                        }
                }

                // Print the file list with a choice
//.........这里部分代码省略.........
开发者ID:whisperity,项目名称:DuplicateDestroyer,代码行数:101,代码来源:Program.cs


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