Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
 public void Delete(K key)
 {
     if (key.CompareTo(this.next.key) == 0)
     {
         Console.WriteLine("element usuwany - {0}", this.next.key);
         this.next = this.next.next;
     }
     else
     {
         if (this.next != null)
         {
             this.next.Delete(key);
         }
     }
 }
Esempio n. 3
0
        public V Find(K key)
        {
            slownik <K, V> current = this;

            // while(current.key != key)
            while (key.CompareTo(current.key) != 0)
            {
                Console.WriteLine("sprawdzany key - {0}", current.key);
                current = current.next;
                if (current == null)
                {
                    return(default(V));
                }
            }
            Console.WriteLine("Znaleziony key - {0}", current.key);
            return(current.val);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var Dictionary = new slownik <int, string>();

            Dictionary.Add(13, "maciek");
            Dictionary.Add(2, "marta");
            Dictionary.Add(32, "wojtek");

            Dictionary.print();

            Dictionary.Delete(13);

            Dictionary.print();

            Dictionary.Find(13);
            Dictionary.Find(32);
            Console.ReadKey();
        }
Esempio n. 5
0
 public slownik()
 {
     next = null;
     key  = default(K);
     val  = default(V);
 }