-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueues.py
More file actions
59 lines (49 loc) · 1.14 KB
/
queues.py
File metadata and controls
59 lines (49 loc) · 1.14 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
class Element:
def __init__(self, number):
self.channel = number
self.next = None
self.parent=None
class Element2:
def __init__(self, number,option,value):
self.channel = number
self.next = None
self.parent=None
self.option=option #Option 0: Polarity Change, Option 1: Enable/Disable
self.value=value #determines whether new polarity is positive/negative...
class DoubleQueue:
def __init__(self):
self.root=None
def add(self,element):
if self.root==None:
self.root=element
else:
current=self.root
while(current.next!=None):
current=current.next
current.next=element
element.parent=current
def remove(self,element):
if self.root==element:
if element.next!=None:
self.root=element.next
else:
self.root=None
element=None
else:
if element.next==None:
element.parent.next=None
element=None
else:
element.parent.next=element.next
element.next.parent=element.parent
element=None
def isEmpty(self):
if self.root==None:
return True
else:
return False
def Print(self):
current=self.root
while current!=None:
print(current.channel)
current=current.next