-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistaencadeada.py
More file actions
56 lines (48 loc) · 1.44 KB
/
listaencadeada.py
File metadata and controls
56 lines (48 loc) · 1.44 KB
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
from no import No
from array import *
class ListaEncadeada:
raiz = None
def __init__ (self, No):
self.raiz = No
def insereNo(self,No):
aux = self.raiz
if(aux==None):
raiz = No
else:
while(aux.getProximo() != None):
if(aux.getValorX() >= No.getValorX()):
aux.getAnterior().setProximo(No)
No.setAnterior(aux.getAnterior())
No.setProximo(aux)
aux.setAnterior(No)
aux = aux.getProximo()
if(No.getValorX() > aux.getValorX()):
No.setAnterior(aux)
aux.setProximo(No)
def imprimeNo(self):
aux = self.raiz
while(aux!=None):
print "\nX:"
print aux.getValorX()
print "Y:"
print aux.getValorY()
aux = aux.getProximo()
print "Fim"
def SendVectorX(self):
aux= self.raiz
cont = 0
arrayX = array("f")
while(aux!=None):
arrayX.insert(cont,aux.getValorX())
cont = cont+1
aux = aux.getProximo()
return arrayX
def SendVectorY(self):
aux= self.raiz
cont = 0
arrayY = array("f")
while(aux!=None):
arrayY.insert(cont,aux.getValorY())
cont = cont+1
aux = aux.getProximo()
return arrayY