-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathFLS.py
42 lines (35 loc) · 812 Bytes
/
FLS.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
class FLS(object):
def __init__(self, max):
self._queue = []
self._max = max
def __iter__(self):
for _ in self._queue[::-1]:
yield _
def __str__(self):
return ",".join([str(_) for _ in self._queue[::-1]])
def push(self, item):
if len(self._queue) < self._max:
self._queue.append(item)
else:
print("Stack is full, cannot add any new value!")
def pop(self):
if len(self._queue) == 0:
print("Stack is empty, nothing to pop!")
else:
self._queue.remove(self._queue[-1])
def peek(self):
if len(self._queue) == 0:
print("Stack is EMPTY!")
return None
else:
return self._queue[-1]
def isFull(self):
if len(self._queue) == self._max:
return True
else:
return False
def isEmpty(self):
if len(self._queue) == 0:
return True
else:
return False