package modules /* Sub정보들을 관리할 list */ type NameList struct { head *NameNode tail *NameNode size int } type NameNode struct { topic []int64 // Encrypt된 topic next *NameNode prev *NameNode list List } type List struct { head *Node tail *Node size int } type Node struct { val []int64 // Encrypt된 value next *Node prev *Node // single // single2sub_s []int // (val < x) sub# single2sub_es []int // (val <= x) sub# single2sub_b []int // (val > x) sub# single2sub_eb []int // (val >= x) sub# single2sub_e []int // (val == x) sub# // range // range2sub_s []int // (val < x and ...) sub# range2sub_es []int // (val <= x and ...) sub# range2sub_b []int // (val > x and ...) sub# range2sub_eb []int // (val >= x and ...) sub# } // ### To delete slice Array func remove(ary []int, i int) []int { return append(ary[:i], ary[i+1:]...) } func findSub(ary []int, sub int) int { for i := 0; i < len(ary); i++ { if ary[i] == sub { return i } } return -1 } func (n *Node) isempty() bool { empty := true if len(n.single2sub_s) != 0 { empty = false } if len(n.single2sub_es) != 0 { empty = false } if len(n.single2sub_b) != 0 { empty = false } if len(n.single2sub_eb) != 0 { empty = false } if len(n.single2sub_e) != 0 { empty = false } if len(n.range2sub_s) != 0 { empty = false } if len(n.range2sub_es) != 0 { empty = false } if len(n.range2sub_b) != 0 { empty = false } if len(n.range2sub_eb) != 0 { empty = false } return empty } // 노드의 operator리스트에 sub#을 in func (l *Node) insert_Sub(op string, sub int, issingle bool) { if issingle == true { switch op { case "<": l.single2sub_s = append(l.single2sub_s, sub) case "<=": l.single2sub_es = append(l.single2sub_es, sub) case ">": l.single2sub_b = append(l.single2sub_b, sub) case ">=": l.single2sub_eb = append(l.single2sub_eb, sub) case "==": l.single2sub_e = append(l.single2sub_e, sub) } } else { switch op { case "<": l.range2sub_s = append(l.range2sub_s, sub) case "<=": l.range2sub_es = append(l.range2sub_es, sub) case ">": l.range2sub_b = append(l.range2sub_b, sub) case ">=": l.range2sub_eb = append(l.range2sub_eb, sub) } } } func (l *List) add_ValueNode(value []int64) { newValNode := &Node{value, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil} l.tail.next = newValNode l.tail = newValNode l.size++ } func (l *List) getPos(value []int64) *Node { valptr := l.head for valptr != nil { // * compare 완성된다면 다시보기 if compare(valptr.val, value) == 0 { // value와 같은 val을 갖는 노드가 존재한다면 return valptr } valptr = valptr.next } return nil }