mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 04:16:32 +01:00
ahhhhhhhh
This commit is contained in:
274
ALGA/03_Tomb.cs
274
ALGA/03_Tomb.cs
@@ -1,274 +0,0 @@
|
|||||||
// using System;
|
|
||||||
// using System.Collections;
|
|
||||||
// using System.Collections.Generic;
|
|
||||||
|
|
||||||
// namespace OE.ALGA.Adatszerkezetek
|
|
||||||
// {
|
|
||||||
// public class TombVerem<T> : Verem<T>
|
|
||||||
// {
|
|
||||||
// T[] tomb;
|
|
||||||
// int n = 0;
|
|
||||||
// public TombVerem(int l)
|
|
||||||
// {
|
|
||||||
// tomb = new T[l];
|
|
||||||
// }
|
|
||||||
// public bool Ures
|
|
||||||
// {
|
|
||||||
// get { return n == 0; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Felso()
|
|
||||||
// {
|
|
||||||
// return tomb[n - 1];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Verembe(T ertek)
|
|
||||||
// {
|
|
||||||
// if (n < tomb.Length)
|
|
||||||
// {
|
|
||||||
// tomb[n] = ertek;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// throw new NincsHelyKivetel();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Verembol()
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T ertek = tomb[n - 1];
|
|
||||||
// n--;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class TombSor<T> : Sor<T>
|
|
||||||
// {
|
|
||||||
// T[] tomb;
|
|
||||||
// int n = 0;
|
|
||||||
// public TombSor(int l)
|
|
||||||
// {
|
|
||||||
// tomb = new T[l];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public bool Ures
|
|
||||||
// {
|
|
||||||
// get { return n == 0; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Elso()
|
|
||||||
// {
|
|
||||||
// return tomb[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Sorba(T ertek)
|
|
||||||
// {
|
|
||||||
// if (n < tomb.Length)
|
|
||||||
// {
|
|
||||||
// tomb[n] = ertek;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// throw new NincsHelyKivetel();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Sorbol()
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T ertek = tomb[0];
|
|
||||||
// T[] tmp = new T[tomb.Length];
|
|
||||||
// n--;
|
|
||||||
// for (int i = 1; i < tomb.Length; i++)
|
|
||||||
// {
|
|
||||||
// tmp[i - 1] = tomb[i];
|
|
||||||
// }
|
|
||||||
// tomb = tmp;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class TombLista<T> : Lista<T>, IEnumerable<T>
|
|
||||||
// {
|
|
||||||
// T[] tomb;
|
|
||||||
// int n = 0;
|
|
||||||
|
|
||||||
// public bool Ures
|
|
||||||
// {
|
|
||||||
// get { return n <= 0; }
|
|
||||||
// }
|
|
||||||
// public TombLista()
|
|
||||||
// {
|
|
||||||
// tomb = new T[1];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public int Elemszam
|
|
||||||
// {
|
|
||||||
// get { return n; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Bejar(Action<T> muvelet)
|
|
||||||
// {
|
|
||||||
// for (int i = 0; i < n; i++)
|
|
||||||
// {
|
|
||||||
// muvelet?.Invoke(tomb[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Beszur(int index, T ertek)
|
|
||||||
// {
|
|
||||||
// if (index < 0)
|
|
||||||
// {
|
|
||||||
// throw new HibasIndexKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T[] tmp = new T[tomb.Length * 2];
|
|
||||||
// for (int i = 0; i < index; i++)
|
|
||||||
// {
|
|
||||||
// tmp[i] = tomb[i];
|
|
||||||
// }
|
|
||||||
// tmp[index] = ertek;
|
|
||||||
// for (int i = index + 1; i < tomb.Length; i++)
|
|
||||||
// {
|
|
||||||
// tmp[i] = tomb[i - 1];
|
|
||||||
// }
|
|
||||||
// tomb = tmp;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public IEnumerator<T> GetEnumerator()
|
|
||||||
// {
|
|
||||||
// foreach (T t in tomb)
|
|
||||||
// {
|
|
||||||
// if (t != null)
|
|
||||||
// {
|
|
||||||
// yield return t;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Hozzafuz(T ertek)
|
|
||||||
// {
|
|
||||||
// if (n < tomb.Length)
|
|
||||||
// {
|
|
||||||
// tomb[n] = ertek;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T[] tmp = new T[tomb.Length * 2];
|
|
||||||
// for (int i = 0; i < tomb.Length; i++)
|
|
||||||
// {
|
|
||||||
// tmp[i] = tomb[i];
|
|
||||||
// }
|
|
||||||
// tmp[n] = ertek;
|
|
||||||
// tomb = tmp;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Kiolvas(int index)
|
|
||||||
// {
|
|
||||||
// if (index < 0 || index >= tomb.Length)
|
|
||||||
// {
|
|
||||||
// throw new HibasIndexKivetel();
|
|
||||||
// }
|
|
||||||
// return tomb[index];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Modosit(int index, T ertek)
|
|
||||||
// {
|
|
||||||
// if (index < 0 && index < tomb.Length)
|
|
||||||
// {
|
|
||||||
// throw new HibasIndexKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// tomb[index] = ertek;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Torol(T ertek)
|
|
||||||
// {
|
|
||||||
// int m = n;
|
|
||||||
// T[] tmp = new T[tomb.Length];
|
|
||||||
// int index = 0;
|
|
||||||
// for (int i = 0; i < m; i++)
|
|
||||||
// {
|
|
||||||
// if (ertek.Equals(tomb[i]))
|
|
||||||
// {
|
|
||||||
// n--;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// tmp[index] = tomb[i];
|
|
||||||
// index++;
|
|
||||||
// }
|
|
||||||
// tomb = tmp;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
// {
|
|
||||||
// TombListaBejaro<T> bejaro = new TombListaBejaro<T>(tomb, n);
|
|
||||||
// return bejaro;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class TombListaBejaro<T> : IEnumerator<T>
|
|
||||||
// {
|
|
||||||
// T[] e;
|
|
||||||
// int n;
|
|
||||||
// int aktualisindex;
|
|
||||||
// T current;
|
|
||||||
// public T Current
|
|
||||||
// {
|
|
||||||
// get { return current; }
|
|
||||||
// }
|
|
||||||
// public TombListaBejaro(T[] e, int n)
|
|
||||||
// {
|
|
||||||
// this.n = n;
|
|
||||||
// this.e = e;
|
|
||||||
// aktualisindex = 0;
|
|
||||||
// current = e[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// object IEnumerator.Current => Current;
|
|
||||||
|
|
||||||
// public void Dispose()
|
|
||||||
// {
|
|
||||||
// throw new NotImplementedException();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public bool MoveNext()
|
|
||||||
// {
|
|
||||||
// if (aktualisindex < n - 1)
|
|
||||||
// {
|
|
||||||
// aktualisindex++;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Reset()
|
|
||||||
// {
|
|
||||||
// aktualisindex = -1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,325 +0,0 @@
|
|||||||
// using System;
|
|
||||||
// using System.Collections;
|
|
||||||
// using System.Collections.Generic;
|
|
||||||
// using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
// namespace OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
// public class LancElem<T>
|
|
||||||
// {
|
|
||||||
// public T tart;
|
|
||||||
// public LancElem<T>? kov;
|
|
||||||
// public LancElem<T>? elozo;
|
|
||||||
|
|
||||||
// public LancElem(T tart, LancElem<T>? kov, LancElem<T>? elozo)
|
|
||||||
// {
|
|
||||||
// this.tart = tart;
|
|
||||||
// this.kov = kov;
|
|
||||||
// this.elozo = elozo;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class LancoltVerem<T> : Verem<T>
|
|
||||||
// {
|
|
||||||
// LancElem<T>? fej;
|
|
||||||
// LancElem<T>? teteje;
|
|
||||||
// public LancoltVerem()
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// public void Felszabadit()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// public bool Ures
|
|
||||||
// {
|
|
||||||
// get { return fej == null; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Felso()
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LancElem<T>? tmp = fej;
|
|
||||||
// while (tmp.kov != null)
|
|
||||||
// {
|
|
||||||
// tmp = tmp.kov;
|
|
||||||
// }
|
|
||||||
// teteje = tmp;
|
|
||||||
// return tmp.tart;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Verembe(T ertek)
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// fej = new LancElem<T>(ertek, null, null);
|
|
||||||
// teteje = fej;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// teteje.kov = new LancElem<T>(ertek, null, teteje);
|
|
||||||
// teteje = teteje.kov;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Verembol()
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (teteje.elozo == null)
|
|
||||||
// {
|
|
||||||
// T ertek = fej.tart;
|
|
||||||
// fej = null;
|
|
||||||
// teteje = fej;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T ertek = Felso();
|
|
||||||
// teteje.elozo.kov = null;
|
|
||||||
// teteje = teteje.elozo;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class LancoltSor<T> : Sor<T>
|
|
||||||
// {
|
|
||||||
// LancElem<T>? fej;
|
|
||||||
// LancElem<T>? vege;
|
|
||||||
// public bool Ures
|
|
||||||
// {
|
|
||||||
// get { return ( vege == null); }
|
|
||||||
// }
|
|
||||||
// public LancoltSor()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// public void Felszabadit()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// public T Elso()
|
|
||||||
// {
|
|
||||||
// return fej.tart;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Sorba(T ertek)
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// fej = new LancElem<T>(ertek, null, null);
|
|
||||||
// vege = fej;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LancElem<T>? tmp = fej;
|
|
||||||
// while (tmp.kov != null)
|
|
||||||
// {
|
|
||||||
// tmp = tmp.kov;
|
|
||||||
// }
|
|
||||||
// tmp.kov = new LancElem<T>(ertek, null, tmp);
|
|
||||||
// vege = tmp.kov;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Sorbol()
|
|
||||||
// {
|
|
||||||
// if (Ures)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (vege.elozo == null)
|
|
||||||
// {
|
|
||||||
// T ertek = vege.tart;
|
|
||||||
// vege = null;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// T ertek = fej.tart;
|
|
||||||
// fej = fej.kov;
|
|
||||||
// fej.elozo = null;
|
|
||||||
// return ertek;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class LancoltLista<T> : Lista<T>, IEnumerable<T>
|
|
||||||
// {
|
|
||||||
// int n;
|
|
||||||
// LancElem<T>? fej;
|
|
||||||
|
|
||||||
// public int Elemszam
|
|
||||||
// {
|
|
||||||
// get { return n; }
|
|
||||||
// }
|
|
||||||
// public LancoltLista()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// public void Felszabadit()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Bejar(Action<T> muvelet)
|
|
||||||
// {
|
|
||||||
// for (int i = 0; i < n; i++)
|
|
||||||
// {
|
|
||||||
// muvelet(Indexedik(i).tart);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Beszur(int index, T ertek)
|
|
||||||
// {
|
|
||||||
// if (fej == null)
|
|
||||||
// {
|
|
||||||
// if (index == 0)
|
|
||||||
// {
|
|
||||||
// Hozzafuz(ertek);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// throw new HibasIndexKivetel();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (index == 0)
|
|
||||||
// {
|
|
||||||
// fej.elozo = new LancElem<T>(ertek, fej, null);
|
|
||||||
// fej = fej.elozo;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else if (index == n)
|
|
||||||
// {
|
|
||||||
// Hozzafuz(ertek);
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LancElem<T>? xd = Indexedik(index).elozo;
|
|
||||||
// xd.kov = new LancElem<T>(ertek, Indexedik(index), xd.kov);
|
|
||||||
// xd.kov.kov.elozo = xd.kov;
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Hozzafuz(T ertek)
|
|
||||||
// {
|
|
||||||
// if (Elemszam < 1)
|
|
||||||
// {
|
|
||||||
// fej = new LancElem<T>(ertek, null, null);
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LancElem<T> asd = Indexedik(n-1);
|
|
||||||
// asd.kov = new LancElem<T>(ertek, null, asd);
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public T Kiolvas(int index)
|
|
||||||
// {
|
|
||||||
// return Indexedik(index).tart;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Modosit(int index, T ertek)
|
|
||||||
// {
|
|
||||||
// Indexedik(index).tart = ertek;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Torol(T ertek)
|
|
||||||
// {
|
|
||||||
// LancElem<T> tmp = fej;
|
|
||||||
// while (tmp.kov != null)
|
|
||||||
// {
|
|
||||||
// if (ertek.Equals(tmp.tart))
|
|
||||||
// {
|
|
||||||
// tmp.elozo.kov = tmp.kov;
|
|
||||||
// tmp.kov.elozo = tmp.elozo;
|
|
||||||
|
|
||||||
// }
|
|
||||||
// tmp = tmp.kov;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// private LancElem<T> Indexedik(int index)
|
|
||||||
// {
|
|
||||||
// LancElem<T>? tmp = fej;
|
|
||||||
// for (int i = 0; i < index; i++)
|
|
||||||
// {
|
|
||||||
// tmp = tmp.kov;
|
|
||||||
// }
|
|
||||||
// return tmp;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public IEnumerator<T> GetEnumerator()
|
|
||||||
// {
|
|
||||||
// LancElem<T> tmp = fej;
|
|
||||||
// while(tmp != null)
|
|
||||||
// {
|
|
||||||
// if (tmp.tart != null)
|
|
||||||
// {
|
|
||||||
// yield return tmp.tart;
|
|
||||||
// }
|
|
||||||
// tmp = tmp.kov;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
// {
|
|
||||||
// LancoltListaBejaro<T> bejaro = new LancoltListaBejaro<T>(this.fej);
|
|
||||||
// return bejaro;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// class LancoltListaBejaro<T> : IEnumerator<T>
|
|
||||||
// {
|
|
||||||
// LancElem<T> fej;
|
|
||||||
// LancElem<T> aktualisElem;
|
|
||||||
// public T Current
|
|
||||||
// {
|
|
||||||
// get{ return aktualisElem.tart; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// object IEnumerator.Current => Current;
|
|
||||||
// public LancoltListaBejaro(LancElem<T> fej)
|
|
||||||
// {
|
|
||||||
// this.fej = fej;
|
|
||||||
// aktualisElem = fej;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Dispose()
|
|
||||||
// {
|
|
||||||
// throw new NotImplementedException();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public bool MoveNext()
|
|
||||||
// {
|
|
||||||
// if (aktualisElem.kov == null)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// aktualisElem = aktualisElem.kov;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Reset()
|
|
||||||
// {
|
|
||||||
// aktualisElem = fej;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
// using System;
|
|
||||||
// using System.Drawing;
|
|
||||||
|
|
||||||
// namespace OE.ALGA;
|
|
||||||
|
|
||||||
// internal class FaElem<T> where T : IComparable
|
|
||||||
// {
|
|
||||||
// public T? tart;
|
|
||||||
// public FaElem<T>? bal;
|
|
||||||
// public FaElem<T>? jobb;
|
|
||||||
|
|
||||||
// public FaElem(T? tart, FaElem<T>? bal, FaElem<T>? jobb)
|
|
||||||
// {
|
|
||||||
// this.tart = tart;
|
|
||||||
// this.bal = bal;
|
|
||||||
// this.jobb = jobb;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public class FaHalmaz<T> : Halmaz<T> where T : IComparable
|
|
||||||
// {
|
|
||||||
// FaElem<T>? gyoker;
|
|
||||||
// public void Bejar(Action<T> muvelet)
|
|
||||||
// {
|
|
||||||
// throw new NotImplementedException();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static FaElem<T> ReszfabaBeszur(FaElem<T> p, T ertek)
|
|
||||||
// {
|
|
||||||
// if (p == null)
|
|
||||||
// {
|
|
||||||
// FaElem<T> uj = new FaElem<T>(ertek, null, null);
|
|
||||||
// return uj;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (p.tart.CompareTo(ertek) > 0)
|
|
||||||
// {
|
|
||||||
// p.bal = ReszfabaBeszur(p.bal, ertek);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (p.tart.CompareTo(ertek) < 0)
|
|
||||||
// {
|
|
||||||
// p.jobb = ReszfabaBeszur(p.jobb, ertek);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return p;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public void Beszur(T ertek)
|
|
||||||
// {
|
|
||||||
// gyoker = ReszfabaBeszur(gyoker, ertek);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static FaElem<T> ReszfaEleme(FaElem<T> p, T ertek)
|
|
||||||
// {
|
|
||||||
// FaElem<T>? tmp = null;
|
|
||||||
// if (p == null)
|
|
||||||
// {
|
|
||||||
// return tmp;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (p.tart.CompareTo(ertek) > 0)
|
|
||||||
// {
|
|
||||||
// tmp = ReszfaEleme(p.bal, ertek);
|
|
||||||
// }
|
|
||||||
// else if (p.tart.CompareTo(ertek) < 0)
|
|
||||||
// {
|
|
||||||
// tmp = ReszfabaBeszur(p.jobb, ertek);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return tmp;
|
|
||||||
// }
|
|
||||||
// return tmp;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// public bool Eleme(T ertek)
|
|
||||||
// {
|
|
||||||
// return !(ReszfaEleme(gyoker, ertek) == null);
|
|
||||||
// }
|
|
||||||
// private static FaElem<T> KetGyerekesTorles(FaElem<T> p, FaElem<T> ertek)
|
|
||||||
// {
|
|
||||||
// if (p.jobb != null)
|
|
||||||
// {
|
|
||||||
// p.jobb = KetGyerekesTorles(p.jobb, ertek);
|
|
||||||
// return p;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// ertek.tart = p.tart;
|
|
||||||
// p = p.bal;
|
|
||||||
// return p;
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// private static FaElem<T> ReszfabolTorol(FaElem<T> p, T ertek)
|
|
||||||
// {
|
|
||||||
// if (p == null)
|
|
||||||
// {
|
|
||||||
// throw new NincsElemKivetel();
|
|
||||||
// }
|
|
||||||
// if (p.tart.CompareTo(ertek) < 0)
|
|
||||||
// {
|
|
||||||
// p.bal = ReszfabolTorol(p.bal, ertek);
|
|
||||||
// }
|
|
||||||
// else if (p.tart.CompareTo(ertek) > 0)
|
|
||||||
// {
|
|
||||||
// p.jobb = ReszfabolTorol(p.jobb, ertek);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (p.jobb == null && p.bal == null)
|
|
||||||
// {
|
|
||||||
// p = null;
|
|
||||||
// }
|
|
||||||
// else if (p.jobb == null && p.bal != null)
|
|
||||||
// {
|
|
||||||
// p = p.bal;
|
|
||||||
// }
|
|
||||||
// else if (p.jobb != null && p.bal == null)
|
|
||||||
// {
|
|
||||||
// p = p.jobb;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// p = KetGyerekesTorles(p, p);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return p;
|
|
||||||
// }
|
|
||||||
// public void Torol(T ertek)
|
|
||||||
// {
|
|
||||||
// ReszfabolTorol(gyoker, ertek);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
Reference in New Issue
Block a user