Removes a value from the set. Returns true if the set contained the specified element. :type val: int :rtype: bool
(self, val)
| 93 | return True |
| 94 | |
| 95 | def remove(self, val): |
| 96 | """ |
| 97 | Removes a value from the set. Returns true if the set contained the specified element. |
| 98 | :type val: int |
| 99 | :rtype: bool |
| 100 | """ |
| 101 | |
| 102 | if self.data_dict.get(val) is not None: |
| 103 | x = self.data_dict.pop(val) |
| 104 | y = self.data_list[-1] |
| 105 | if y != val: |
| 106 | |
| 107 | self.data_dict[y] = x |
| 108 | self.data_list[-1], self.data_list[x] = self.data_list[x], self.data_list[-1] |
| 109 | |
| 110 | self.data_list.pop() |
| 111 | self.length -= 1 |
| 112 | |
| 113 | return True |
| 114 | |
| 115 | return False |
| 116 | |
| 117 | def getRandom(self): |
| 118 | """ |
no test coverage detected