File: set.go

package info (click to toggle)
golang-go-systemd 2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 240 kB
  • ctags: 166
  • sloc: sh: 42; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 507 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dbus

type set struct {
	data map[string]bool
}

func (s *set) Add(value string) {
	s.data[value] = true
}

func (s *set) Remove(value string) {
	delete(s.data, value)
}

func (s *set) Contains(value string) (exists bool) {
	_, exists = s.data[value]
	return
}

func (s *set) Length() (int) {
	return len(s.data)
}

func (s *set) Values() (values []string) {
	 for val, _ := range s.data {
		values = append(values, val)
	 }
	 return
}

func newSet() (*set) {
	return &set{make(map[string] bool)}
}