-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.go
More file actions
67 lines (56 loc) · 1.28 KB
/
types.go
File metadata and controls
67 lines (56 loc) · 1.28 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package statloc
type (
component struct {
Title string
Prev *component
}
componentSet struct {
Tail *component
Elements map[string]struct{}
}
TableItem struct {
LOC uint64
Files uint64
}
Items map[string]*TableItem
Statistics struct {
Languages Items
Components Items
Total TableItem
}
)
func (s *componentSet) Add(title string) *component {
s.Elements[title] = struct{}{}
s.Tail = &component{Title: title, Prev: s.Tail}
return s.Tail
}
func (s *componentSet) Pop() {
delete(s.Elements, s.Tail.Title)
s.Tail = s.Tail.Prev
}
func (s *componentSet) In(title string) bool {
_, exists := s.Elements[title]
return exists
}
func (s *componentSet) Copy() componentSet {
elements := make(map[string]struct{})
tail := s.Tail.Copy(elements)
return componentSet{
Tail: tail,
Elements: elements,
}
}
func (c *component) Copy(elements map[string]struct{}) *component {
if c == nil {
return nil
}
elements[c.Title] = struct{}{}
return &component{
Title: c.Title,
Prev: c.Prev.Copy(elements),
}
}
func (t *TableItem) Append(LOC uint64, files uint64) {
t.LOC += LOC
t.Files += files
}