-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsomething.py
More file actions
80 lines (51 loc) · 1.81 KB
/
Copy pathsomething.py
File metadata and controls
80 lines (51 loc) · 1.81 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class Node (object):
def __init__(self,initdata):
self.data = initdata
self.next = None # always do this – saves a lot
# of headaches later!
def getData (self):
return self.data # returns a POINTER
def getNext (self):
return self.next # returns a POINTER
def setData (self, newData):
self.data = newData # changes a POINTER
def setNext (self,newNext):
self.next = newNext # changes a POINTER
class CircularList():
def __init__(self):
self.head = None
def add(self, item):
temp = Node(item)
if self.head == None:
self.head = temp
self.head.setNext(self.head)
else:
temp.setNext(self.head.next)
self.head.setNext(temp)
def __str__ (self):
repre = self.head
pCount = 0
strrepre = ""
while True:
if pCount == 10:
strrepre += "\n"
pCount = 0
#if repre.getData() in itemCheck:
#allCounted = True
#itemCheck.append(repre.getData())
#print (repre.data)
if repre.getData () != self.head.data:
strrepre += repre.getData() + " "
pCount += 1
repre = repre.getNext()
if( repre == self.head) :
break
return strrepre
def main():
listy = CircularList()
count = 0
for i in range (10):
listy.add(str(count))
count += 1
print(listy)
main()