コード例 #1
0
 public void Delete(K key)
 {
     if (key.CompareTo(this.next.key) == 0)
     {
         Console.WriteLine("Usuwany element - {0}", this.next.key);
         this.next = this.next.next;
     }
     else if (this.next != null)
     {
         this.next.Delete(key);
     }
 }
コード例 #2
0
ファイル: slownik.cs プロジェクト: mnahajowski/OOP_UWr
 public void Add(K key, V val)
 {
     if (this.next != null)
     {
         this.next.Add(key, val);
     }
     else
     {
         this.next     = new slownik <K, V>();
         this.next.key = key;
         this.next.val = val;
     }
 }
コード例 #3
0
ファイル: slownik.cs プロジェクト: mnahajowski/OOP_UWr
 public void Delete(K key)
 {
     if (key.CompareTo(this.next.key) == 0) //jesli jest taki sam (znalezlismy), > 0 po this w porzadku, < 0 przed this w porzadku
     {
         Console.WriteLine("Usuwamy element - " + this.next.key);
         this.next = this.next.next; //przsuwamy wskaznik dalej
     }
     else
     {
         if (this.next != null) //uważać żeby nie wyleciec poza koniec slownika
         {
             this.next.Delete(key);
         }
     }
 }
コード例 #4
0
        public V Find(K key)
        {
            slownik <K, V> current = this;

            while (key.CompareTo(current.key) != 0)
            {
                Console.WriteLine("sprawdzany klucz - {0}", current.key);
                current = current.next;
                if (current == null)
                {
                    return(default(V));
                }
            }
            Console.WriteLine("Znaleziony klucz - {0}", current.key);
            return(current.value);
        }
コード例 #5
0
ファイル: main.cs プロジェクト: mnahajowski/OOP_UWr
        static void Main(string[] args)
        {
            var Dictionary = new slownik <int, string>();

            Dictionary.Add(13, "marcin");
            Dictionary.Add(2, "magda");
            Dictionary.Add(32, "dawid");

            Dictionary.Print();

            Dictionary.Delete(13);

            Dictionary.Find(13);
            Dictionary.Find(32);

            Console.ReadKey();
        }
コード例 #6
0
ファイル: slownik.cs プロジェクト: mnahajowski/OOP_UWr
        public V Find(K key)
        {
            slownik <K, V> current = this;

            while (key.CompareTo(current.key) != 0)
            {
                Console.WriteLine("Sprawdzany klucz - " + current.key);
                current = current.next;
                if (current == null)
                {
                    Console.WriteLine("Nie znaleziono podanego klucza");
                    Console.WriteLine();
                    return(default(V));
                }
            }
            Console.WriteLine("Znaleziony klucz - " + current.key);
            Console.WriteLine();
            return(current.val);
        }
コード例 #7
0
ファイル: slownik.cs プロジェクト: mnahajowski/OOP_UWr
 public slownik()
 {
     next = null;
     key  = default(K);
     val  = default(V);
 }