~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/lxc/lxd/shared/stringset.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// That this code needs to exist is kind of dumb, but I'm not sure how else to
 
2
// do it.
 
3
package shared
 
4
 
 
5
type StringSet map[string]bool
 
6
 
 
7
func (ss StringSet) IsSubset(oss StringSet) bool {
 
8
        for k, _ := range map[string]bool(ss) {
 
9
                if _, ok := map[string]bool(oss)[k]; !ok {
 
10
                        return false
 
11
                }
 
12
        }
 
13
 
 
14
        return true
 
15
}
 
16
 
 
17
func NewStringSet(strings []string) StringSet {
 
18
        ret := map[string]bool{}
 
19
        for _, s := range strings {
 
20
                ret[s] = true
 
21
        }
 
22
 
 
23
        return StringSet(ret)
 
24
}