-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabelaHash.py
56 lines (41 loc) · 1.2 KB
/
TabelaHash.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class No:
def __init__(self,idNo,ListaDados):
self.idNo=idNo
self.ListaDados=ListaDados
def getIdNo(self):
return self.idNo
def setIdNo(self,novoId):
self.idNo=novoId
def getListaDados(self):
return self.ListaDados
def setListaDados(self,novaLista):
self.ListaDados=novaLista
class TabelaHash:
def __init__(self,funcao,N):
self.funcao=funcao
self.Tabela=[]
for i in range(N):
self.Tabela.append([])
def Inserir(self,no):
id_no=no.getIdNo()
Dad=no.getListaDados()
Pos=self.funcao(id_no)
self.Tabela[Pos].append(Dad)
def imprime(self):
return self.Tabela
def Deletar(self,IDNoh):
Posi=self.funcao(IDNoh)
if Daw!="None" and Daw!=[]:
self.Tabela[Posi]=[]
else:
return ""
def imprimeDados(self,IDNoh):
Posi=self.funcao(IDNoh)
Daw=self.Tabela[Posi][0]
if Daw!="None" and Daw!=[]:
return Daw
else:
return ""
def Atualiza(self,IDNoh,ListaNova):
Posi=self.funcao(IDNoh)
self.Tabela[Posi]=[ListaNova]