-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedSet.py
57 lines (37 loc) · 1.2 KB
/
linkedSet.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
"""
Author: Harry Pinkerton, James Lawson, Laurie Jones
File: linkedSet.py
Project: 5
"""
from linkedBag import LinkedBag
from abstractCollection import AbstractCollection
from abstractSet import AbstractSet
from node import Node
class LinkedSet(AbstractSet, LinkedBag):
"""stuff goes here"""
#Constructor
def __init__(self, sourceCollection = None):
"""Sets the initial state of self,
which includes the contents of sourceCollection,
if it is present."""
self._items = None
super().__init__(sourceCollection)
# Accessor Methods
## def __eq__(self,other):
## AbstractCollection.__eq__(self, other)
def __eq__(self, other):
if self is other: return True
if type(self) != type(other): return False
if len(self) != len(other): return False
for item in self:
if item not in other:
return False
for item in other:
if not item in self:
return False
return True
# Mutator Methods
def add (self, item):
if item not in self:
#LinkedBag
super().add(item)