using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kolejka
{
class Program
{
class Węzeł
{
public int dane;
public Węzeł next;
}
class Kolejka
{
Węzeł głowa = null;
Węzeł ogon = null;
public void Dodaj(int dana)
{
Węzeł tmp = new Węzeł();
tmp.dane = dana;
tmp.next = null;
if(głowa==null)
{
głowa = tmp;
ogon = tmp;
return;
}
ogon.next = tmp;
ogon = tmp;
}
public void Usuń()
{
if(głowa == null)
{
Console.WriteLine("Brak elementu do usuniecia");
return;
}
Węzeł tmp = głowa.next;
głowa = tmp;
}
public int Podejrzyj()
{
if (głowa != null) return głowa.dane;
else throw new Exception("Pusta kolejka");
}
public bool CzyPusta()
{
return głowa == null;
}
}
static void Main(string[] args)
{
Kolejka<int> k = new Kolejka<int>(); //Tu nie działa moja własna kolejka
List<int> l = new List<int>(); //Ta wbudowana struktura danych działa
k.Dodaj(3);
k.Dodaj(4);
k.Dodaj(46);
k.Dodaj(53);
Console.ReadKey();
}
}
}
Nie działa konkretnie w linijce gdzie deklaruję moją kolejkę, natomiast linijkę niżej deklaruję wbudowaną strunkturę danych która działa i jej kompilator sie nie czepia.