mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 12:26:07 +01:00
ohnooooo
This commit is contained in:
@@ -13,19 +13,18 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
T[] tomb;
|
||||
int n = 0;
|
||||
bool ures = true;
|
||||
public TombVerem(int l)
|
||||
{
|
||||
tomb = new T[l];
|
||||
}
|
||||
public bool Ures
|
||||
{
|
||||
get { return ures; }
|
||||
get { return n == 0; }
|
||||
}
|
||||
|
||||
public T Felso()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return tomb[n - 1];
|
||||
}
|
||||
|
||||
public void Verembe(T ertek)
|
||||
@@ -34,7 +33,6 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
tomb[n] = ertek;
|
||||
n++;
|
||||
ures = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -44,22 +42,23 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
|
||||
public T Verembol()
|
||||
{
|
||||
for (int i = tomb.Length; i > 0; i--)
|
||||
if (Ures)
|
||||
{
|
||||
if (tomb[i] != null)
|
||||
{
|
||||
return tomb[i];//should i actually delete it, or we are just courious whats the valueidk
|
||||
}
|
||||
throw new NincsElemKivetel();
|
||||
}
|
||||
ures = true;
|
||||
throw new NincsElemKivetel();
|
||||
else
|
||||
{
|
||||
T ertek = tomb[n - 1];
|
||||
n--;
|
||||
return ertek;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public class TombSor<T> : Sor<T>
|
||||
{
|
||||
T[] tomb;
|
||||
int n = 0;
|
||||
bool ures = true;
|
||||
public TombSor(int l)
|
||||
{
|
||||
tomb = new T[l];
|
||||
@@ -67,7 +66,7 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
|
||||
public bool Ures
|
||||
{
|
||||
get { return ures; }
|
||||
get { return n == 0; }
|
||||
}
|
||||
|
||||
public T Elso()
|
||||
@@ -81,7 +80,6 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
tomb[n] = ertek;
|
||||
n++;
|
||||
ures = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -91,24 +89,31 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
|
||||
public T Sorbol()
|
||||
{
|
||||
for (int i = tomb.Length; i > 0; i--)
|
||||
if (Ures)
|
||||
{
|
||||
if (tomb[i] != null)
|
||||
{
|
||||
return tomb[i];//should i actually delete it, or we are just courious whats the valueidk
|
||||
}
|
||||
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;
|
||||
}
|
||||
ures = true;
|
||||
throw new NincsElemKivetel();
|
||||
}
|
||||
}
|
||||
public class TombLista<T> : Lista<T>, IEnumerable<T>
|
||||
public class TombLista<T> : Lista<T>, IEnumerable<T>
|
||||
{
|
||||
T[] tomb;
|
||||
int n = 0;
|
||||
public TombLista(int l)
|
||||
public TombLista()
|
||||
{
|
||||
tomb = new T[l];
|
||||
tomb = new T[n];
|
||||
}
|
||||
|
||||
public int Elemszam
|
||||
@@ -123,29 +128,32 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
|
||||
public void Beszur(int index, T ertek)
|
||||
{
|
||||
if (index < 0)
|
||||
if (index < 0 || index > tomb.Length)
|
||||
{
|
||||
throw new HibasIndexKivetel();
|
||||
}
|
||||
if (index < tomb.Length && tomb[index] == null)
|
||||
{
|
||||
tomb[index] = ertek;
|
||||
}
|
||||
else
|
||||
{
|
||||
T[] tmp = new T[tomb.Length * 2];
|
||||
for (int i = 0; i < index; i++)
|
||||
if (index < tomb.Length && tomb[index] == null)
|
||||
{
|
||||
tmp[i] = tomb[i];
|
||||
tomb[index] = ertek;
|
||||
}
|
||||
tmp[index] = ertek;
|
||||
for (int i = index+1; i < tomb.Length; i++)
|
||||
else
|
||||
{
|
||||
tmp[i] = tomb[i];
|
||||
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;
|
||||
}
|
||||
tomb = tmp;
|
||||
n++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
@@ -163,7 +171,7 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
if (n < tomb.Length)
|
||||
{
|
||||
tomb[n] = ertek;
|
||||
tomb[n-1] = ertek;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -172,7 +180,7 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
tmp[i] = tomb[i];
|
||||
}
|
||||
tmp[n] = ertek;
|
||||
tmp[n-1] = ertek;
|
||||
tomb = tmp;
|
||||
}
|
||||
n++;
|
||||
@@ -215,7 +223,7 @@ namespace OE.ALGA.Adatszerkezetek
|
||||
T[] tmp = new T[tomb.Length];
|
||||
for (int i = tomb.Length; i > 0; i--)
|
||||
{
|
||||
if (i > n)//(ertek == tomb[i])
|
||||
if (ertek.Equals(tomb[i]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user