-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcap_c.py
36 lines (30 loc) · 892 Bytes
/
cap_c.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
class CAP:
def __init__(self):
self.CAP=[]
def adicionarE(self,e):
i=0
j=len(self.CAP)-1
while (i<=j):
m=(i+j)//2
if e.tempo()<self.CAP[m].tempo():
j=m-1
else:
i=m+1
self.CAP.insert(j+1,e)
def proxE(self):
assert len(self.CAP)>0
return self.CAP[0]
def retirarE(self):
assert len(self.CAP)>0
self.CAP=self.CAP[1:]
def eliminarID(self,ID):
i=len(self.CAP)-1
while i>=0:
if self.CAP[i].ID()==ID:
self.CAP.remove(self.CAP[i])
i=i-1
def tamC(self):
return len(self.CAP)
def mostraC(self):
for e in self.CAP:
print ('ID:', e.ID(),' ','Tipo:', e.tipo(),' ','Tempo:', e.tempo())