Inserts a value to the set. Returns true if the set did not already contain the specified element. :type val: int :rtype: bool
(self, val)
| 78 | self.length = 0 |
| 79 | |
| 80 | def insert(self, val): |
| 81 | """ |
| 82 | Inserts a value to the set. Returns true if the set did not already contain the specified element. |
| 83 | :type val: int |
| 84 | :rtype: bool |
| 85 | """ |
| 86 | if self.data_dict.get(val) is not None: |
| 87 | return False |
| 88 | |
| 89 | self.data_dict[val] = self.length |
| 90 | self.length += 1 |
| 91 | self.data_list.append(val) |
| 92 | |
| 93 | return True |
| 94 | |
| 95 | def remove(self, val): |
| 96 | """ |