Project Moscato Team Messaging Middleware Implemetation Message Middleware by Golang Operate as Secure, Effectively
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

list.go 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package modules
  2. /*
  3. Sub정보들을 관리할 list
  4. */
  5. type NameList struct {
  6. head *NameNode
  7. tail *NameNode
  8. size int
  9. }
  10. type NameNode struct {
  11. name []int64 // Encrypt된 name
  12. next *NameNode
  13. list List
  14. }
  15. type List struct {
  16. head *Node
  17. tail *Node
  18. size int
  19. }
  20. type Node struct {
  21. val []int64 // Encrypt된 value
  22. next *Node
  23. // single //
  24. single2sub_s []int // (val < x) sub#
  25. single2sub_es []int // (val <= x) sub#
  26. single2sub_b []int // (val > x) sub#
  27. single2sub_eb []int // (val >= x) sub#
  28. single2sub_e []int // (val == x) sub#
  29. // range //
  30. range2sub_s []int // (val < x and ...) sub#
  31. range2sub_es []int // (val <= x and ...) sub#
  32. range2sub_b []int // (val > x and ...) sub#
  33. range2sub_eb []int // (val >= x and ...) sub#
  34. }
  35. // ### To delete slice Array
  36. func remove(s []int, i int) []int {
  37. return append(s[:i], s[i+1:]...)
  38. }
  39. // 노드의 operator리스트에 sub#을 in
  40. func (l *Node) insert_Sub(op string, sub int, issingle bool) {
  41. if issingle == true {
  42. switch op {
  43. case "<":
  44. l.single2sub_s = append(l.single2sub_s, sub)
  45. case "<=":
  46. l.single2sub_es = append(l.single2sub_es, sub)
  47. case ">":
  48. l.single2sub_b = append(l.single2sub_b, sub)
  49. case ">=":
  50. l.single2sub_eb = append(l.single2sub_eb, sub)
  51. case "==":
  52. l.single2sub_e = append(l.single2sub_e, sub)
  53. }
  54. } else {
  55. switch op {
  56. case "<":
  57. l.range2sub_s = append(l.range2sub_s, sub)
  58. case "<=":
  59. l.range2sub_es = append(l.range2sub_es, sub)
  60. case ">":
  61. l.range2sub_b = append(l.range2sub_b, sub)
  62. case ">=":
  63. l.range2sub_eb = append(l.range2sub_eb, sub)
  64. }
  65. }
  66. }
  67. func (l *List) add_ValueNode(val string, op string, sub int, issingle bool) {
  68. newValNode := &Node{conv(val), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
  69. newValNode.insert_Sub(op, sub, true)
  70. l.tail.next = newValNode
  71. l.tail = newValNode
  72. l.size++
  73. }
  74. func (l * List)getPos(value []int64) *Node{
  75. valptr := l.head
  76. for valptr != nil{
  77. if compare(valptr.val, value) == 1 { // value와 같은 val을 갖는 노드가 존재한다면
  78. return valptr
  79. }
  80. }
  81. return nil
  82. }