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


C# Heap.Dequeue方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
          Heap<int> sampleHeap = new Heap<int>();

            sampleHeap.Enqueue(1);
            sampleHeap.Enqueue(2);
            sampleHeap.Enqueue(3);
            sampleHeap.Enqueue(4);
            sampleHeap.Enqueue(5);
            sampleHeap.Enqueue(3);


            Console.WriteLine(sampleHeap.Dequeue());
            Console.WriteLine(sampleHeap.Dequeue());
        }
开发者ID:vaster,项目名称:Telerik.vasko,代码行数:15,代码来源:Program.cs

示例2: MergePartialIndexes

		private void MergePartialIndexes()
		{
			for (int index = 0; index < _indexes.Count; index++)
			{
				var partialReaders = _options.GetAllPartialsFor(index)
					.Select(x => new SourceReader(x, _options.Encoding, new[] { 0, 1 }).ReadFromStream().GetEnumerator())
					.ToList();

				var heap = new Heap<HeapEntry>(partialReaders.Count, (x, y) => Utils.CompareIndexEntries(x.IndexEntry, y.IndexEntry));
				for (int i = 0; i < partialReaders.Count; i++)
				{
					var reader = partialReaders[i];
					if (reader.MoveNext() == false) // empty reader?
						continue;
					var heapEntry = new HeapEntry
					{
						Index = index,
						Reader = reader,
						IndexEntry = ReadIndexEntry(reader)
					};
					heap.Enqueue(heapEntry);
				}

				using (var stream = _options.Create(index))
				using (var builder = new IndexBuilder(stream, _options.Encoding))
				{
					while (heap.Count > 0)
					{
						var heapEntry = heap.Dequeue();
						builder.Add(heapEntry.IndexEntry);
						if (heapEntry.Reader.MoveNext() == false)
							continue;
						heapEntry.IndexEntry = ReadIndexEntry(heapEntry.Reader);
						heap.Enqueue(heapEntry);
					}
				}

				_options.DeleteAllPartialsFor(index);
			}
		}
开发者ID:modulexcite,项目名称:ExternalSorting,代码行数:40,代码来源:ExternalSorter.cs

示例3: QueryTop

        public QueryResults QueryTop(Query query, int take,
            IndexingConventions.ScorerCalc score = null,
            Sorter sortBy = null)
        {
            if (take < 0)
                throw new ArgumentException("Take must be non negative");

            var qr = new QueryResults();
            var heap = new Heap<QueryMatch>(take, GenerateComparisonFunction(sortBy));
            foreach (var match in Query(query, score))
            {
                heap.Enqueue(match);
                qr.TotalResults++;
            }
            qr.Results = new QueryMatch[heap.Count];
            int pos = 0;
            while (heap.Count > 0)
            {
                qr.Results[pos++] = heap.Dequeue();
            }
            return qr;
        }
开发者ID:votrongdao,项目名称:Corax,代码行数:22,代码来源:Searcher.cs


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