-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbaginterface.py
47 lines (38 loc) · 1.18 KB
/
baginterface.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
class BagInterface(object):
"""Interface for all bag types."""
# Constructor
def __init__(self, sourceCollection=None):
"""Sets the initial state of self, which includes the
content of sourceCollection, if it's present."""
pass
# Accessor method
def isEmpty(self):
"""Return True if len(self) ==0,
or False otherwise."""
return True
def __len__(self):
"""Return the number of items in self."""
return 0
def __iter__(self):
"""Supports iteration over a view of self."""
return None
def __add__(self, other):
"""Return a new bag containing the contents
of self and other."""
return None
def __eq__(self, other):
"""Return True if self equals other,
or False otherwise."""
return False
# Mutator methods
def clear(self):
"""Makes self become empty."""
pass
def add(self, item):
"""add item to self."""
pass
def remove(self, item):
"""Precondition: item is in self.
Raises: KeyError if item in not in self.
Postcondition: item is removed from self."""
pass