** Removes a value from the set. Returns true if the set contained the specified element. */
(val int)
| 36 | |
| 37 | /** Removes a value from the set. Returns true if the set contained the specified element. */ |
| 38 | func (this *RandomizedSet) Remove(val int) bool { |
| 39 | if setIt, ok := this.valsSet[val]; ok { |
| 40 | last := this.vals[len(this.vals)-1] |
| 41 | this.vals[setIt.ind] = last |
| 42 | this.vals = this.vals[:len(this.vals)-1] |
| 43 | this.valsSet[last] = valEl{last, setIt.ind} |
| 44 | delete(this.valsSet, val) |
| 45 | return true |
| 46 | } |
| 47 | return false |
| 48 | } |
| 49 | |
| 50 | /** Get a random element from the set. */ |
| 51 | func (this *RandomizedSet) GetRandom() int { |
nothing calls this directly
no outgoing calls
no test coverage detected