Explorar el Código

Add func to manage node, sub ..

secure
extra1563 hace 4 años
padre
commit
e4a2437a10
Se han modificado 1 ficheros con 49 adiciones y 3 borrados
  1. 49
    3
      modules/list.go

+ 49
- 3
modules/list.go Ver fichero

@@ -13,7 +13,6 @@ type NameList struct {
13 13
 type NameNode struct {
14 14
 	name []int64 // Encrypt된 name
15 15
 	next *NameNode
16
-
17 16
 	list List
18 17
 }
19 18
 
@@ -43,6 +42,53 @@ type Node struct {
43 42
 
44 43
 // ### To delete slice Array
45 44
 func remove(s []int, i int) []int {
46
-	s[i] = s[len(s)-1]
47
-	return s[:len(s)-1]
45
+	return append(s[:i], s[i+1:]...)
46
+}
47
+
48
+// 노드의 operator리스트에 sub#을 in
49
+func (l *Node) insert_Sub(op string, sub int, issingle bool) {
50
+	if issingle == true {
51
+		switch op {
52
+		case "<":
53
+			l.single2sub_s = append(l.single2sub_s, sub)
54
+		case "<=":
55
+			l.single2sub_es = append(l.single2sub_es, sub)
56
+		case ">":
57
+			l.single2sub_b = append(l.single2sub_b, sub)
58
+		case ">=":
59
+			l.single2sub_eb = append(l.single2sub_eb, sub)
60
+		case "==":
61
+			l.single2sub_e = append(l.single2sub_e, sub)
62
+		}
63
+	} else {
64
+		switch op {
65
+		case "<":
66
+			l.range2sub_s = append(l.range2sub_s, sub)
67
+		case "<=":
68
+			l.range2sub_es = append(l.range2sub_es, sub)
69
+		case ">":
70
+			l.range2sub_b = append(l.range2sub_b, sub)
71
+		case ">=":
72
+			l.range2sub_eb = append(l.range2sub_eb, sub)
73
+		}
74
+	}
48 75
 }
76
+
77
+
78
+func (l *List) add_ValueNode(val string, op string, sub int, issingle bool) {
79
+	newValNode := &Node{conv(val), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
80
+	newValNode.insert_Sub(op, sub, true)
81
+	l.tail.next = newValNode
82
+	l.tail = newValNode
83
+	l.size++
84
+}
85
+
86
+func (l * List)getPos(value []int64) *Node{
87
+	valptr := l.head
88
+	for valptr != nil{
89
+		if compare(valptr.val, value) == 1 { // value와 같은 val을 갖는 노드가 존재한다면
90
+			return valptr
91
+		} 
92
+	}
93
+	return nil
94
+}

Loading…
Cancelar
Guardar