本文整理汇总了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());
}
示例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);
}
}
示例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;
}