-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashTable.py
More file actions
32 lines (27 loc) · 833 Bytes
/
HashTable.py
File metadata and controls
32 lines (27 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from Node import Node
from SelfBalancingTree import AVLTree
import numpy as np
import sys
np.set_printoptions(threshold=sys.maxsize)
class HashTable:
def __init__(self) -> None:
self.Table = np.empty(10, dtype=Node)
def Hash(self,Key):
Hash = 0
for Char in Key:
Hash += ord(Char)
return Hash
def Insert(self,Node:Node):
Index = self.Hash(Node.Key)%10
if self.Table[Index] == None:
Tree = AVLTree()
self.Table[Index] = Tree
self.Table[Index].RecursiveInsert(Node)
def Delete(self,Key):
Index = self.Hash(Key)%10
self.Table[Index] = None
def Find(self,Key):
Index = self.Hash(Key)%10
if self.Table[Index] == None:
return None
return self.Table[Index].Search(Key)