/// <inheritdoc/> public PriorityQueue(PriorityQueueType queueType, IComparer<TPriority> comparer) { if ((queueType != PriorityQueueType.Minimum) && (queueType != PriorityQueueType.Maximum)) { throw new ArgumentOutOfRangeException("queueType"); } this.queueType = queueType; tree = new RedBlackTreeList<TPriority, TValue>(comparer); }
int count; //T[]内存在的实际元素个数 /// <summary> /// 初始化PriorityQueue /// </summary> /// <param name="type">优先队列类型</param> public PriorityQueue(PriorityQueueType type) { this.type = type; this.count = 0; //第[0]个不存,从[1]开始,所以size + 1 this.queue = new T[QUEUE_MAXSIZE + 1]; }
/// <summary> /// Initializes a new instance of the <see cref="PriorityQueue<T>"/> class. /// </summary> /// <param name="queueType">Type of the queue.</param> /// <param name="capacity">The initial capacity of the Priority Queue.</param> public PriorityQueue(PriorityQueueType queueType, int capacity) { if (queueType == PriorityQueueType.MaxPriorityQueue) { heap = new Heap <Association <int, T> >(HeapType.MaxHeap, capacity, new AssociationKeyComparer <int, T>()); } else { heap = new Heap <Association <int, T> >(HeapType.MaxHeap, capacity, new AssociationKeyComparer <int, T>()); } }
public FibonacciHeap(PriorityQueueType type, IComparer <TPriority> comparer = null) { if (comparer == null) { throw new ArgumentNullException("comparer"); } switch (type) { case PriorityQueueType.Minimum: Compare = (x, y) => comparer.Compare(x, y); break; case PriorityQueueType.Maximum: Compare = (x, y) => comparer.Compare(y, x); break; default: throw new ArgumentException(string.Format("Unknown priority queue type: {0}", type)); } identifier = Guid.NewGuid(); }
/// <summary> /// Initializes a new instance of the <see cref="ClassicPriorityQueue<T>"/> class. /// </summary> /// <param name="queueType">Type of the queue.</param> /// <example> /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Queues\PriorityQueueExamples.cs" region="Constructor" lang="cs" title="The following example shows how to use the default constructor."/> /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Queues\PriorityQueueExamples.vb" region="Constructor" lang="vbnet" title="The following example shows how to use the default constructor."/> /// </example> public ClassicPriorityQueue(PriorityQueueType queueType) : base(queueType) { // Do nothing }
public PriorityQueueHeap(PriorityQueueType queueType) { _queueType = queueType; }
public PriorityQueueHeap() { _queueType = PriorityQueueType.Min; }
public IndexedPriorityQueueHeap(PriorityQueueType queueType) : base(queueType) { }
/// <summary> /// Initializes a new instance of the <see cref="PriorityQueue<TValue, TPriority>"/> class. /// </summary> /// <param name="queueType">Type of the queue.</param> /// <param name="comparison">The comparison.</param> /// <inheritdoc/> public PriorityQueue(PriorityQueueType queueType, Comparison<TPriority> comparison) : this(queueType, new ComparisonComparer<TPriority>(comparison)) { }
/// <param name="queueType">Type of the queue.</param> /// <example> /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\Queues\PriorityQueueExamples.cs" region="Constructor" lang="cs" title="The following example shows how to use the default constructor."/> /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\Queues\PriorityQueueExamples.vb" region="Constructor" lang="vbnet" title="The following example shows how to use the default constructor."/> /// </example> public PriorityQueue(PriorityQueueType queueType) : this(queueType, Comparer<TPriority>.Default) { }
public PriorityQueue(PriorityQueueType type) { this.type = type; }
public FibonacciHeap(PriorityQueueType type) : this(type, Comparer <TPriority> .Default) { }
public BinaryHeap(PriorityQueueType type) : this(type, Comparer <TPriority> .Default) { }