Пример #1
0
    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");
    }
Пример #2
0
    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);
    }
Пример #3
0
    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;
    }
Пример #4
0
    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;
        }
    }
Пример #5
0
 public Slownik()
 {
     glowa          = new rekord();
     AktualnyRekord = glowa;
 }