示例#1
0
        public V Wyszukaj(K elem_szukany)
        {
            // Słownik<K, V> last = this;
            Słownik <K, V> self = this.next;

            while (self != null)
            {
                if (self.key.Equals(elem_szukany))
                {
                    return(self.value);
                }
                self = self.next;
            }
            return(default(V));
        }
示例#2
0
        public void Wydrukuj()
        {
            Słownik <K, V> self = this.next;

            if (self == null)
            {
                Console.WriteLine("Empty Dict");
                return;
            }
            while (self != null)
            {
                Console.WriteLine("Key = {0}, value = {1}", self.key, self.value);

                self = self.next;
            }
        }
示例#3
0
        public void Usun(K elem_szukany)
        {
            Słownik <K, V> self = this.next;
            Słownik <K, V> last = this;

            while (self != null)
            {
                if (self.key.Equals(elem_szukany))
                {
                    last.next = self.next;
                    return;
                }
                last = self;
                self = self.next;
            }
            Console.WriteLine("Nie znaleziono klucza");
        }
示例#4
0
        public void Dodaj(K key, V val)
        {
            Słownik <K, V> last = this;
            Słownik <K, V> self = this.next;

            while (self != null)
            {
                if (self.key.Equals(key))
                {
                    Console.WriteLine("Nie możesz użyc już istniejącego klucza!");
                    return;
                }
                last = self;
                self = self.next;
            }
            last.next = new Słownik <K, V>(key, val);
        }
示例#5
0
        static void Main(string[] args)
        {
            Słownik <int, string> dict = new Słownik <int, string>();

            Console.WriteLine("pumpumpum");
            dict.Dodaj(23, "nowy Patyczek1");

            dict.Wydrukuj();
            Console.WriteLine("pumpumpum");
            dict.Dodaj(23, "nowy Patyczek2");
            dict.Wydrukuj();
            Console.WriteLine("pumpumpum");
            dict.Dodaj(25, "nowy Patyczek3");
            dict.Wydrukuj();
            Console.WriteLine("pumpumpum");
            dict.Usun(25);
            dict.Wydrukuj();
            Console.WriteLine("pumpumpum");
        }
示例#6
0
 public Słownik()
 {
     this.key   = default(K);
     this.value = default(V);
     this.next  = null;
 }
示例#7
0
 Słownik(K key, V val)
 {
     this.key   = key;
     this.value = val;
     this.next  = null;
 }