Beispiel #1
0
 public void YenidenBoyutlandir(int yeniBoyut)
 {
     HeapDugumu[] newHeap = new HeapDugumu[yeniBoyut];
     for (int i = 0; i < maksBoyut; i++)
     {
         newHeap[i] = heap[i];
     }
     heap      = newHeap;
     maksBoyut = yeniBoyut;
 }
Beispiel #2
0
        public bool Insert(Urun3 deger)
        {
            if (gecerliBoyut == maksBoyut)
            {
                return(false);
            }
            HeapDugumu yeniHeapDugumu = new HeapDugumu(deger);

            heap[gecerliBoyut] = yeniHeapDugumu;
            MoveToUp(gecerliBoyut++);
            return(true);
        }
Beispiel #3
0
        public void MoveToUp(int index)
        {
            int        parent = (index - 1) / 2;
            HeapDugumu bottom = heap[index];

            while (index > 0 && Convert.ToDouble(((Urun3)heap[parent].Deger).FiyatAraligi) < Convert.ToDouble(((Urun3)bottom.Deger).FiyatAraligi))
            {
                heap[index] = heap[parent];
                index       = parent;
                parent      = (parent - 1) / 2;
            }
            heap[index] = bottom;
        }