Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: impl/memory/stringset.go

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: stringSet everywhere Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « impl/memory/gkvlite_utils_test.go ('k') | impl/memory/taskqueue_data.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « impl/memory/gkvlite_utils_test.go ('k') | impl/memory/taskqueue_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698