-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestStackAndQueue.py
77 lines (66 loc) · 2.01 KB
/
testStackAndQueue.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import time
from customQueue import DefaultQueue
from customQueue import InterfaceQueue
from customQueue import StackQueue
from customStack import CustomStack
from customStack import LinkedListStack
def test_all():
q = DefaultQueue(6)
test(q, False)
q = StackQueue(6)
test(q, False)
s = CustomStack(6)
test(s, False)
s = LinkedListStack(6)
test(s, False)
# initList = [15, 6, 2, 9]
# [s.push(x) for x in initList]
# print('Initialer Zustand Stack:', s)
# s.print_push(17)
# s.print_push(13)
# s.print_pop()
# s.print_push(18)
# s.print_detailed()
def test(test_object, prnt=True):
if isinstance(test_object, InterfaceQueue):
if prnt:
test_object.print_enqueue(4)
test_object.print_enqueue(1)
test_object.print_enqueue(3)
test_object.print_dequeue()
test_object.print_enqueue(8)
test_object.print_dequeue()
test_object.print_detailed()
print()
else:
start = time.time()
test_object.enqueue(4)
test_object.enqueue(1)
test_object.enqueue(3)
test_object.dequeue()
test_object.enqueue(8)
test_object.dequeue()
end = time.time()
print(f'{type(test_object).__name__}Time: {end - start:5.20f}s')
else:
if prnt:
test_object.print_push(4)
test_object.print_push(1)
test_object.print_push(3)
test_object.print_pop()
test_object.print_push(8)
test_object.print_pop()
test_object.print_detailed()
print()
else:
start = time.time()
test_object.push(4)
test_object.push(1)
test_object.push(3)
test_object.pop()
test_object.push(8)
test_object.pop()
end = time.time()
print(f'{type(test_object).__name__}Time: {end - start:5.20f}s')
pass
test_all()