| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- 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
- }
|