public HashTableNode[] Set(string key, int value) { int address = this._Hash(key); if (this.data[address] == null) { this.data[address] = new HashTableNode(); this.data[address].key = key; this.data[address].value = value; } else { HashTableNode currentItem = this.data[address]; HashTableNode nextItem = this.data[address].next; while (nextItem != null) { currentItem = nextItem; nextItem = nextItem.next; } nextItem = new HashTableNode(); nextItem.key = key; nextItem.value = value; currentItem.next = nextItem; } return(this.data); }
public List <string> keys() { List <string> Keys = new List <string>(); foreach (HashTableNode dataItem in this.data) { HashTableNode item = dataItem; while (item != null) { Keys.Add(item.key); item = item.next; } } return(Keys); }
public HashTableNode Get(string key) { int address = this._Hash(key); if (this.data[address] != null) { HashTableNode item = this.data[address]; while (item.key != key) { item = item.next; if (item.key == key) { return(item); } } } return(null); }