using System; namespace KdTree { // Token: 0x0200000D RID: 13 public class PriorityQueue : IPriorityQueue { // Token: 0x06000054 RID: 84 RVA: 0x00002DB2 File Offset: 0x00000FB2 public PriorityQueue(int capacity, ITypeMath priorityMath) { if (capacity <= 0) { throw new ArgumentException("Capacity must be greater than zero"); } this.capacity = capacity; this.queue = new ItemPriority[capacity]; this.priorityMath = priorityMath; } // Token: 0x17000013 RID: 19 // (get) Token: 0x06000055 RID: 85 RVA: 0x00002DE3 File Offset: 0x00000FE3 public int Count { get { return this.count; } } // Token: 0x06000056 RID: 86 RVA: 0x00002DEC File Offset: 0x00000FEC private void ExpandCapacity() { this.capacity *= 2; ItemPriority[] array = new ItemPriority[this.capacity]; Array.Copy(this.queue, array, this.queue.Length); this.queue = array; } // Token: 0x06000057 RID: 87 RVA: 0x00002E30 File Offset: 0x00001030 public void Enqueue(TItem item, TPriority priority) { int num = this.count + 1; this.count = num; if (num > this.capacity) { this.ExpandCapacity(); } int num2 = this.count - 1; this.queue[num2] = new ItemPriority { Item = item, Priority = priority }; this.ReorderItem(num2, -1); } // Token: 0x06000058 RID: 88 RVA: 0x00002E94 File Offset: 0x00001094 public TItem Dequeue() { TItem item = this.queue[0].Item; this.queue[0].Item = default(TItem); this.queue[0].Priority = this.priorityMath.MinValue; this.ReorderItem(0, 1); this.count--; return item; } // Token: 0x06000059 RID: 89 RVA: 0x00002EFC File Offset: 0x000010FC private void ReorderItem(int index, int direction) { if (direction != -1 && direction != 1) { throw new ArgumentException("Invalid Direction"); } ItemPriority itemPriority = this.queue[index]; int num = index + direction; while (num >= 0 && num < this.count) { ItemPriority itemPriority2 = this.queue[num]; int num2 = this.priorityMath.Compare(itemPriority.Priority, itemPriority2.Priority); if ((direction != -1 || num2 <= 0) && (direction != 1 || num2 >= 0)) { break; } this.queue[index] = itemPriority2; this.queue[num] = itemPriority; index += direction; num += direction; } } // Token: 0x0600005A RID: 90 RVA: 0x00002F94 File Offset: 0x00001194 public TItem GetHighest() { if (this.count == 0) { throw new Exception("Queue is empty"); } return this.queue[0].Item; } // Token: 0x0600005B RID: 91 RVA: 0x00002FBA File Offset: 0x000011BA public TPriority GetHighestPriority() { if (this.count == 0) { throw new Exception("Queue is empty"); } return this.queue[0].Priority; } // Token: 0x04000017 RID: 23 private ITypeMath priorityMath; // Token: 0x04000018 RID: 24 private ItemPriority[] queue; // Token: 0x04000019 RID: 25 private int capacity; // Token: 0x0400001A RID: 26 private int count; } }