소스 검색

[fin] add_subcription

secure
extra1563 4 년 전
부모
커밋
0e07810f18
1개의 변경된 파일8개의 추가작업 그리고 19개의 파일을 삭제
  1. 8
    19
      modules/subscription.go

+ 8
- 19
modules/subscription.go 파일 보기

46
 
46
 
47
 	//namelist에서 name찾고, 없으면 추가
47
 	//namelist에서 name찾고, 없으면 추가
48
 	for nameptr != nil {
48
 	for nameptr != nil {
49
-		// *  compare함수 구현되기 전 임시로 끼넣은 것 (이 부분은 secure.go 완성되면 다시 확인)
49
+		// *  compare함수 구현되기 전 임시로 끼넣은 것 (이 부분은 secure.go 완성되면 다시 확인)
50
 		if compare(nameptr.name, name) == 1 {
50
 		if compare(nameptr.name, name) == 1 {
51
 			findOk = true
51
 			findOk = true
52
 			break
52
 			break
73
 
73
 
74
 	// list[name]에 value추가
74
 	// list[name]에 value추가
75
 	if len(value) == 2 { // 단일 식이라면 (single)
75
 	if len(value) == 2 { // 단일 식이라면 (single)
76
-		valptr := nameptr.list.head
77
-		for valptr != nil {
78
-			// * 이 부분도 compare함수 구현하면 다시봐야함
79
-			if compare(valptr.val, conv(value[0])) == 1 { // value와 같은 val을 갖는 노드가 존재한다면
80
-				valptr.insert_Sub(value[1], subnumber, true)
81
-				return nil // add_subscription ok
82
-			}
83
-			valptr = valptr.next
76
+		valptr := nameptr.list.getPos(conv(value[0]))
77
+		if valptr == nil{
78
+			nameptr.list.add_ValueNode(value[0], value[1], subnumber, true)
79
+		} else{
80
+			valptr.insert_Sub(value[1], subnumber, true)
84
 		}
81
 		}
85
-
86
-		// value와 일치하는 노드가 x -> 추가
87
-		nameptr.list.add_ValueNode(value[0], value[1], subnumber, true)
88
-
89
 		return nil // add_subscription ok
82
 		return nil // add_subscription ok
90
 	} else {
83
 	} else {
91
-
92
 		// rangesub check
84
 		// rangesub check
93
 		manager.israngesub[subnumber] = true
85
 		manager.israngesub[subnumber] = true
94
 
86
 
110
 			if valptr2 == nil {
102
 			if valptr2 == nil {
111
 				nameptr.list.add_ValueNode(value[3], value[4], subnumber, false)
103
 				nameptr.list.add_ValueNode(value[3], value[4], subnumber, false)
112
 			}
104
 			}
113
-
114
 		} else {
105
 		} else {
115
-
116
 			// '||'로 묶여 있다면 두 식 모두 single로 처리가능
106
 			// '||'로 묶여 있다면 두 식 모두 single로 처리가능
117
-
118
 			if valptr1 != nil && valptr2 != nil { // val1, val2를 갖는 노드가 둘 다 존재
107
 			if valptr1 != nil && valptr2 != nil { // val1, val2를 갖는 노드가 둘 다 존재
119
 				valptr1.insert_Sub(value[1], subnumber, true)
108
 				valptr1.insert_Sub(value[1], subnumber, true)
120
 				valptr2.insert_Sub(value[4], subnumber, true)
109
 				valptr2.insert_Sub(value[4], subnumber, true)
126
 				nameptr.list.add_ValueNode(value[3], value[4], subnumber, true)
115
 				nameptr.list.add_ValueNode(value[3], value[4], subnumber, true)
127
 			}
116
 			}
128
 		}
117
 		}
129
-		return nil
118
+		return nil // add_subscription ok
130
 	}
119
 	}
131
 	return errors.New("Can't add_subscription")
120
 	return errors.New("Can't add_subscription")
132
 }
121
 }
146
 // * 암호화된 두 value 비교함수 (임시)
135
 // * 암호화된 두 value 비교함수 (임시)
147
 func compare(v1 []int64, v2 []int64) int {
136
 func compare(v1 []int64, v2 []int64) int {
148
 	return 1
137
 	return 1
149
-}
138
+}

Loading…
취소
저장