-
Notifications
You must be signed in to change notification settings - Fork 0
/
setInterface.py
70 lines (55 loc) · 1.73 KB
/
setInterface.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
"""
Author: Harry Pinkerton, James Lawson, Laurie Jones
File: setInterface.py
Project: 5
"""
class SetInterface(object):
"""Interface for all set types."""
# Constructor
def __init__(self, sourceCollection = None):
"""Sets the initial state of self, which includes the
contents of sourceCollection, if it's present."""
pass
# Accessor methods
def isEmpty(self):
"""Returns True if len(self) == 0, or False otherwise."""
return True
def __len__(self):
"""-Returns the number of items in self."""
return 0
def __str__(self):
"""Returns the string representation of self."""
return ""
def __iter__(self):
"""Supports iteration over a view of self."""
return None
def __add__(self, other):
"""Returns a new instance of self's class
containing the contents of self and other."""
return None
def __eq__(self, other):
"""Returns True if self equals other,
or False otherwise."""
return False
# Set-specific methods
def __or__(self, other):
"""Returns the union of self and other."""
return None
def __and__(self, other):
"""Returns the intersection of self and other."""
return None
def __sub__(self, other):
"""Returns the difference of self and other."""
return None
# Mutator methods
def clear(self):
"""Makes self become empty."""
pass
def add(self, item):
"""Adds 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