| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package memory | |
| 6 | |
| 7 type stringSet map[string]struct{} | |
| 8 | |
| 9 func (s stringSet) has(value string) bool { | |
| 10 _, ret := s[value] | |
| 11 return ret | |
| 12 } | |
| 13 | |
| 14 // add adds to the set and returns true iff the value was not there before (i.e. | |
| 15 // it returns true if add actually modifies the stringSet). | |
| 16 func (s stringSet) add(value string) bool { | |
| 17 ret := !s.has(value) | |
| 18 s[value] = struct{}{} | |
| 19 return ret | |
| 20 } | |
| 21 | |
| 22 func (s stringSet) rm(value string) { | |
| 23 delete(s, value) | |
| 24 } | |
| 25 | |
| 26 func (s stringSet) dup() stringSet { | |
| 27 ret := make(stringSet, len(s)) | |
| 28 for v := range s { | |
| 29 ret.add(v) | |
| 30 } | |
| 31 return ret | |
| 32 } | |
| 33 | |
| 34 func (s stringSet) getOne() string { | |
| 35 for k := range s { | |
| 36 return k | |
| 37 } | |
| 38 return "" | |
| 39 } | |
| OLD | NEW |