Пример #1
0
 private void growHeap()
 {
     capacity = (capacity * 2) + 1;
     HeapEntry[] newHeap = new HeapEntry[capacity];
     System.Array.Copy(heap, 0, newHeap, 0, count);
     heap = newHeap;
 }
Пример #2
0
        private void GrowHeap()
        {
            capacity = (capacity * 2) + 1;
            var newHeap = new HeapEntry <TA> [capacity];

            Array.Copy(heap, 0, newHeap, 0, count);
            heap = newHeap;
        }
Пример #3
0
 void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
 {
     info.AddValue(capacityName, capacity);
     info.AddValue(countName, count);
     HeapEntry[] heapCopy = new HeapEntry[count];
     Array.Copy(heap, 0, heapCopy, 0, count);
     info.AddValue(heapName, heapCopy, typeof(HeapEntry[]));
 }
Пример #4
0
        private void bubbleUp(int index, HeapEntry he)
        {
            int parent = getParent(index);

            // note: (index > 0) means there is a parent
            while ((index > 0) && (heap[parent].Priority < he.Priority))
            {
                heap[index] = heap[parent];
                index       = parent;
                parent      = getParent(index);
            }
            heap[index] = he;
        }
Пример #5
0
        private void BubbleUp(int index, HeapEntry <TA> he)
        {
            int parent = GetParent(index);

            // note: (index > 0) means there is a parent
            while ((index > 0) &&
                   (heap[parent].Priority.CompareTo(he.Priority) < 0))
            {
                heap[index] = heap[parent];
                index       = parent;
                parent      = GetParent(index);
            }
            heap[index] = he;
        }
Пример #6
0
        private void TrickleDown(int index, HeapEntry <TA> he)
        {
            int child = GetLeftChild(index);

            while (child < count)
            {
                if (((child + 1) < count) &&
                    (heap[child].Priority.CompareTo(heap[child + 1].Priority) < 0))
                {
                    child++;
                }
                heap[index] = heap[child];
                index       = child;
                child       = GetLeftChild(index);
            }
            BubbleUp(index, he);
        }
Пример #7
0
        private void trickleDown(int index, HeapEntry he)
        {
            int child = getLeftChild(index);

            while (child < count)
            {
                if (((child + 1) < count) &&
                    (heap[child].Priority < heap[child + 1].Priority))
                {
                    child++;
                }
                heap[index] = heap[child];
                index       = child;
                child       = getLeftChild(index);
            }
            bubbleUp(index, he);
        }
Пример #8
0
 private void trickleDown(int index, HeapEntry he)
 {
     int child = getLeftChild(index);
     while (child < count) {
         if (((child + 1) < count) &&
             (heap[child].Priority.CompareTo(heap[child + 1].Priority) < 0)) {
             child++;
         }
         heap[index] = heap[child];
         index = child;
         child = getLeftChild(index);
     }
     bubbleUp(index, he);
 }
Пример #9
0
 private void growHeap()
 {
     capacity = (capacity * 2) + 1;
     HeapEntry[] newHeap = new HeapEntry[capacity];
     System.Array.Copy(heap, 0, newHeap, 0, count);
     heap = newHeap;
 }
Пример #10
0
 private void bubbleUp(int index, HeapEntry he)
 {
     int parent = getParent(index);
     // note: (index > 0) means there is a parent
     while ((index > 0) &&
           (heap[parent].Priority.CompareTo(he.Priority) < 0)) {
         heap[index] = heap[parent];
         index = parent;
         parent = getParent(index);
     }
     heap[index] = he;
 }
Пример #11
0
 void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
 {
     info.AddValue(capacityName, capacity);
     info.AddValue(countName, count);
     HeapEntry[] heapCopy = new HeapEntry[count];
     Array.Copy(heap, 0, heapCopy, 0, count);
     info.AddValue(heapName, heapCopy, typeof(HeapEntry[]));
 }