(codes ...int)
| 29 | } |
| 30 | |
| 31 | func (r *relation) Add(codes ...int) { |
| 32 | if len(codes) < 2 { |
| 33 | panic("codes length must be greater than 2") |
| 34 | } |
| 35 | for i := 1; i < len(codes); i++ { |
| 36 | parent := codes[i-1] |
| 37 | s, ok := r.m[parent] |
| 38 | if !ok { |
| 39 | s = make(map[int]struct{}) |
| 40 | r.m[parent] = s |
| 41 | } |
| 42 | for _, code := range codes[i:] { |
| 43 | s[code] = struct{}{} |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func (r *relation) Is(parent, child int) bool { |
| 49 | if parent == child { |
no outgoing calls