示例#1
0
        public override void Remove(Object key)
        {
            int hashCode = comparator.hashCodeOf(key);
            int index    = indexOf(hashCode, entryArray.Length);

            ObjectEntry previous = (ObjectEntry)entryArray[index];
            ObjectEntry current  = previous;

            while (current != null)
            {
                ObjectEntry next = (ObjectEntry)current.Next;
                if (hashCode == current.GetHashCode() && comparator.equal(key, current.Key))
                {
                    if (previous == current)
                    {
                        entryArray[index] = next;
                    }
                    else
                    {
                        previous.Next = next;
                    }
                    current.Next = null;
                    currentSize--;
                }
                previous = current;
                current  = next;
            }
        }
示例#2
0
        public override Object Get(Object key)
        {
            int hashCode = comparator.hashCodeOf(key);
            int index    = indexOf(hashCode, entryArray.Length);

            ObjectEntry current = (ObjectEntry)entryArray[index];

            while (current != null)
            {
                if (hashCode == current.GetHashCode() && comparator.equal(key, current.Key))
                {
                    return(current.Value);
                }
                current = (ObjectEntry)current.Next;
            }
            return(null);
        }