Просмотр исходного кода

temporarily completed list.go

master
extra1563 4 лет назад
Родитель
Сommit
98d2314989
1 измененных файлов: 57 добавлений и 14 удалений
  1. 57
    14
      modules/list.go

+ 57
- 14
modules/list.go Просмотреть файл

@@ -11,9 +11,10 @@ type NameList struct {
11 11
 }
12 12
 
13 13
 type NameNode struct {
14
-	name []int64 // Encrypt된 name
15
-	next *NameNode
16
-	list List
14
+	topic []int64 // Encrypt된 topic
15
+	next  *NameNode
16
+	prev  *NameNode
17
+	list  List
17 18
 }
18 19
 
19 20
 type List struct {
@@ -25,6 +26,7 @@ type List struct {
25 26
 type Node struct {
26 27
 	val  []int64 // Encrypt된 value
27 28
 	next *Node
29
+	prev *Node
28 30
 
29 31
 	// single //
30 32
 	single2sub_s  []int // (val < x) sub#
@@ -41,8 +43,49 @@ type Node struct {
41 43
 }
42 44
 
43 45
 // ### To delete slice Array
44
-func remove(s []int, i int) []int {
45
-	return append(s[:i], s[i+1:]...)
46
+func remove(ary []int, i int) []int {
47
+	return append(ary[:i], ary[i+1:]...)
48
+}
49
+
50
+func findSub(ary []int, sub int) int {
51
+	for i := 0; i < len(ary); i++ {
52
+		if ary[i] == sub {
53
+			return i
54
+		}
55
+	}
56
+	return -1
57
+}
58
+
59
+func (n *Node) isempty() bool {
60
+	empty := true
61
+	if len(n.single2sub_s) != 0 {
62
+		empty = false
63
+	}
64
+	if len(n.single2sub_es) != 0 {
65
+		empty = false
66
+	}
67
+	if len(n.single2sub_b) != 0 {
68
+		empty = false
69
+	}
70
+	if len(n.single2sub_eb) != 0 {
71
+		empty = false
72
+	}
73
+	if len(n.single2sub_e) != 0 {
74
+		empty = false
75
+	}
76
+	if len(n.range2sub_s) != 0 {
77
+		empty = false
78
+	}
79
+	if len(n.range2sub_es) != 0 {
80
+		empty = false
81
+	}
82
+	if len(n.range2sub_b) != 0 {
83
+		empty = false
84
+	}
85
+	if len(n.range2sub_eb) != 0 {
86
+		empty = false
87
+	}
88
+	return empty
46 89
 }
47 90
 
48 91
 // 노드의 operator리스트에 sub#을 in
@@ -74,21 +117,21 @@ func (l *Node) insert_Sub(op string, sub int, issingle bool) {
74 117
 	}
75 118
 }
76 119
 
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)
120
+func (l *List) add_ValueNode(value []int64) {
121
+	newValNode := &Node{value, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
81 122
 	l.tail.next = newValNode
82 123
 	l.tail = newValNode
83 124
 	l.size++
84 125
 }
85 126
 
86
-func (l * List)getPos(value []int64) *Node{
127
+func (l *List) getPos(value []int64) *Node {
87 128
 	valptr := l.head
88
-	for valptr != nil{
89
-		if compare(valptr.val, value) == 1 { // value와 같은 val을 갖는 노드가 존재한다면
129
+	for valptr != nil {
130
+		// * compare 완성된다면 다시보기
131
+		if compare(valptr.val, value) == 0 { // value와 같은 val을 갖는 노드가 존재한다면
90 132
 			return valptr
91
-		} 
133
+		}
134
+		valptr = valptr.next
92 135
 	}
93 136
 	return nil
94
-}
137
+}

Загрузка…
Отмена
Сохранить