Esempio n. 1
0
        /// <summary>
        /// Swaps 2 elements in the heap
        /// </summary>
        /// <param name="a">index of first element</param>
        /// <param name="b">index of second element</param>
        private void Swap(int a, int b)
        {
            PrioCord c = _heapList[a];

            _heapList[a] = _heapList[b];
            _heapList[b] = c;
            _locations[c.Row][c.Column] = b;
            c = _heapList[a];
            _locations[c.Row][c.Column] = a;
        }
Esempio n. 2
0
        /// <summary>
        /// Raises the specified element to it's place
        /// </summary>
        /// <param name="i">index of element</param>
        private void Float(int i)
        {
            PrioCord pk = _heapList[i];

            while (i > 0 && Parent(i).Priority < pk.Priority)
            {
                _heapList[i] = Parent(i);
                _locations[_heapList[i].Row][_heapList[i].Column] = i;
                i = i / 2;
            }
            _heapList[i] = pk;
            _locations[pk.Row][pk.Column] = i;
        }