Exemplo n.º 1
0
        private HashNodeMap <TData> CreateNode(TKey key, TData data)
        {
            int hashCode = key.GetHashCode();
            HashNodeMap <TData> newNodeMap = new HashNodeMap <TData>();

            newNodeMap.data = new Node <TData>(data);
            newNodeMap.key  = hashCode;
            return(newNodeMap);
        }
Exemplo n.º 2
0
        public void Add(TKey key, TData data)
        {
            HashNodeMap <TData> current = null;

            if (hashNode == null)
            {
                hashNode = CreateNode(key, data);
            }
            else
            {
                current = hashNode;
                while (current.next != null)
                {
                    current = current.next;
                }
                current.next = CreateNode(key, data);
            }
            Count++;
        }
Exemplo n.º 3
0
        private Node <TData> FindHashCode(TKey key)
        {
            Node <TData>        data     = null;
            int                 hashCode = key.GetHashCode();
            HashNodeMap <TData> current  = hashNode;

            while (current != null)
            {
                if (current.key == hashCode)
                {
                    data = current.data;
                    break;
                }
                if (current.next != null)
                {
                    current = current.next;
                }
            }
            return(data);
        }