-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_list.py
62 lines (49 loc) · 1.43 KB
/
class_list.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
from class_state import *
#seznam
class List:
array = []
#konstr.
def __init__(self, size):
self.size = size
self.array = [None for i in range(size)]
def print(self):
print(self.array)
#vložit do seznamu
def insert(self, item):
i = 0
while self.array[i] != None:
if i == self.size - 1:
return False #seznam je plný
i += 1
self.array[i] = item
return True
#najít v seznamu
def find(self, item):
if not isinstance(item, State):
return False
found = False
i = 0
while not found:
if i == self.size - 1:
return False #nenalezeno
if self.array[i] == None:
i += 1
continue
if statecmp(self.array[i], item):
found = True
return i
i += 1
#najít a vyjmout ze seznamu
def remove(self, item):
if not isinstance(item, State):
return False
i = 0
while not statecmp(self.array[i], item):
if i == self.size - 1:
return False #nenalezeno
i = i + 1
self.array[i] = None
return True
#vyjmout ze seznamu
def remove_at(self, index):
self.array[index] = None