public void Wypisz() { rekord teraz = glowa; while (teraz.Nast != null) { teraz = teraz.Nast; Console.WriteLine("Klucz : {0}, Hasło: {1}", teraz.Key, teraz.Value); } Console.Write("Koniec\n"); }
public bool Wyszukaj(K Klucz) { rekord teraz = glowa; while (teraz.Nast != null) { teraz = teraz.Nast; if (Compare(teraz.Key, Klucz)) { Console.WriteLine("W słowniku jest hasło o rekordzie: {0},to hasło to: {1}", Klucz, teraz.Value); return(true); } } return(false); }
public void Dodaj(K Klucz, V wartosc) { rekord teraz = glowa; while (teraz.Nast != null) { teraz = teraz.Nast; if (Compare(Klucz, teraz.Key)) { Console.WriteLine("Błąd : W słowniku już jest rekord o podanym kluczu"); return; } } rekord newrekord = new rekord(); newrekord.Value = wartosc; newrekord.Key = Klucz; AktualnyRekord.Nast = newrekord; AktualnyRekord = newrekord; }
public void Usun(K Klucz) { rekord teraz = glowa, x; while (teraz.Nast != null) { x = teraz.Nast; if (Compare(x.Key, Klucz)) { if (!(Compare(Klucz, glowa.Nast.Key))) { teraz.Nast = x.Nast; break; } else { glowa = new rekord(); AktualnyRekord = glowa; break; } } teraz = teraz.Nast; } }
public Slownik() { glowa = new rekord(); AktualnyRekord = glowa; }