Esempio n. 1
0
        public Sirket GetSirket(int key)
        {
            int hash = (key % TABLE_SIZE);

            if (table1[hash] == null)
            {
                return(null);
            }
            else
            {
                HashChainEntrySirket entry = table1[hash];
                while (entry != null && entry.Anahtar != key)
                {
                    entry = entry.Next;
                }
                if (entry == null)
                {
                    return(null);
                }
                else
                {
                    return((Sirket)entry.Deger);
                }
            }
        }
Esempio n. 2
0
        public void AddSirket(int key, object value)
        {
            int hash = (key % TABLE_SIZE);

            if (table1[hash] == null)
            {
                table1[hash] = new HashChainEntrySirket(key, value);
            }
            else
            {
                HashChainEntrySirket entry = table1[hash];
                while (entry.Next != null && entry.Anahtar != key)
                {
                    entry = entry.Next;
                }
                if (entry.Anahtar == key)
                {
                    entry.Deger = value;
                }
                else
                {
                    entry.Next = new HashChainEntrySirket(key, value);
                }
            }
        }
Esempio n. 3
0
        public void RemoveSirket(int key)
        {
            int hash = (key % TABLE_SIZE);

            while (table1[hash] != null && table1[hash].Anahtar % TABLE_SIZE != key % TABLE_SIZE)
            {
                hash = (hash + 1) % TABLE_SIZE;
            }
            HashChainEntrySirket current = table1[hash];
            bool isRemoved = false;

            while (current != null)
            {
                if (current.Anahtar == key)
                {
                    table1[hash] = current.Next;
                    isRemoved    = true;
                    break;
                }

                if (current.Next != null)
                {
                    if (current.Next.Anahtar == key)
                    {
                        HashChainEntrySirket newNext = current.Next.Next;
                        current.Next = newNext;
                        isRemoved    = true;
                        break;
                    }
                    else
                    {
                        current = current.Next;
                    }
                }
            }

            if (!isRemoved)
            {
                Console.WriteLine("Silinecek bir şey bulunamadı");
                return;
            }
        }
 public HashChainEntrySirket(int anahtar, object deger)
 {
     this.anahtar = anahtar;
     this.deger   = deger;
     this.next    = null;
 }