Beispiel #1
0
 /// <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);
 }
Beispiel #2
0
        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];
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriorityQueue&lt;T&gt;"/> 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>());
     }
 }
Beispiel #4
0
        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();
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassicPriorityQueue&lt;T&gt;"/> 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)
 {
 }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriorityQueue&lt;TValue, TPriority&gt;"/> 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)) {

        }
Beispiel #10
0
        /// <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) {

        }
Beispiel #11
0
 public PriorityQueue(PriorityQueueType type)
 {
     this.type = type;
 }
Beispiel #12
0
 public FibonacciHeap(PriorityQueueType type)
     : this(type, Comparer <TPriority> .Default)
 {
 }
Beispiel #13
0
 public BinaryHeap(PriorityQueueType type)
     : this(type, Comparer <TPriority> .Default)
 {
 }