質問編集履歴
2
ナイーブツリーに勝者情報も追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
```
|
85
|
+
```Scala3
|
86
86
|
|
87
87
|
|
88
88
|
|
@@ -138,6 +138,12 @@
|
|
138
138
|
|
139
139
|
|
140
140
|
|
141
|
+
WINNER = 1
|
142
|
+
|
143
|
+
LOSER = 2
|
144
|
+
|
145
|
+
|
146
|
+
|
141
147
|
@dataclass
|
142
148
|
|
143
149
|
class Node:
|
@@ -148,23 +154,25 @@
|
|
148
154
|
|
149
155
|
name: str
|
150
156
|
|
157
|
+
winner: int
|
158
|
+
|
151
159
|
|
152
160
|
|
153
161
|
[
|
154
162
|
|
155
|
-
Node("E1","M1","田中太郎"),
|
163
|
+
Node("E1","M1","田中太郎", WINNER),
|
156
|
-
|
164
|
+
|
157
|
-
Node("E2","M1","鈴木一郎"),
|
165
|
+
Node("E2","M1","鈴木一郎", LOSER),
|
158
|
-
|
166
|
+
|
159
|
-
Node("M1","M3","第一試合"),
|
167
|
+
Node("M1","M3","第一試合", 0),
|
160
|
-
|
168
|
+
|
161
|
-
Node("E3","M2","山田花子"),
|
169
|
+
Node("E3","M2","山田花子", 0),
|
162
|
-
|
170
|
+
|
163
|
-
Node("E4","M2","佐藤櫻子"),
|
171
|
+
Node("E4","M2","佐藤櫻子", 0),
|
164
|
-
|
172
|
+
|
165
|
-
Node("M2","M3","第二試合"),
|
173
|
+
Node("M2","M3","第二試合", 0),
|
166
|
-
|
174
|
+
|
167
|
-
Node("M3",None,"決勝")
|
175
|
+
Node("M3",None,"決勝", 0)
|
168
176
|
|
169
177
|
]
|
170
178
|
|
1
コメントに対応。例を増やしてみた
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,46 +82,152 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
```
|
85
|
+
```scala3
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
-
|
89
|
+
case class Entry(
|
90
|
-
|
90
|
+
|
91
|
-
id: string
|
91
|
+
id: string,
|
92
|
-
|
92
|
+
|
93
|
-
entryName: string
|
93
|
+
entryName: string,
|
94
94
|
|
95
95
|
matchId: string
|
96
96
|
|
97
|
-
|
97
|
+
)
|
98
|
-
|
98
|
+
|
99
|
-
|
99
|
+
case class Match(
|
100
|
-
|
100
|
+
|
101
|
-
id:
|
101
|
+
id: String
|
102
|
-
|
102
|
+
|
103
|
-
matchName:
|
103
|
+
matchName: String
|
104
|
-
|
104
|
+
|
105
|
-
nextMatchId
|
105
|
+
nextMatchId: Option[String]
|
106
|
-
|
106
|
+
|
107
|
-
|
107
|
+
)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
List[Entry | Match](
|
112
|
+
|
113
|
+
Entry("E1", "田中太郎", "M1"), Entry("E2", "鈴木一郎", "M1"),
|
114
|
+
|
115
|
+
Match("M1", "第一試合", Some("M3")),
|
116
|
+
|
117
|
+
Entry("E3", "山田花子", "M2") , Entry("E4", "佐藤櫻子", "M2"),
|
118
|
+
|
119
|
+
Match("M2", "第二試合", Some("M3")),
|
120
|
+
|
121
|
+
Match("M3", "決勝", None),
|
122
|
+
|
123
|
+
)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
```
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
### 例3: コメント頂いたナイーブツリー
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```python3
|
136
|
+
|
137
|
+
from dataclasses import dataclass
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
@dataclass
|
142
|
+
|
143
|
+
class Node:
|
144
|
+
|
145
|
+
id: str
|
146
|
+
|
147
|
+
nextId: str
|
148
|
+
|
149
|
+
name: str
|
108
150
|
|
109
151
|
|
110
152
|
|
111
153
|
[
|
112
154
|
|
155
|
+
Node("E1","M1","田中太郎"),
|
156
|
+
|
113
|
-
|
157
|
+
Node("E2","M1","鈴木一郎"),
|
114
|
-
|
158
|
+
|
115
|
-
|
159
|
+
Node("M1","M3","第一試合"),
|
160
|
+
|
116
|
-
|
161
|
+
Node("E3","M2","山田花子"),
|
162
|
+
|
117
|
-
|
163
|
+
Node("E4","M2","佐藤櫻子"),
|
118
|
-
|
164
|
+
|
119
|
-
|
165
|
+
Node("M2","M3","第二試合"),
|
120
|
-
|
166
|
+
|
121
|
-
|
167
|
+
Node("M3",None,"決勝")
|
122
168
|
|
123
169
|
]
|
124
170
|
|
125
171
|
|
126
172
|
|
127
173
|
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
### 例4: コメント頂いたそのままシリアライズ(型付き言語の場合)
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```c#
|
182
|
+
|
183
|
+
public class Match {
|
184
|
+
|
185
|
+
public string Name {get; set;}
|
186
|
+
|
187
|
+
public Match[] Entries {get; set;}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
new Match{
|
194
|
+
|
195
|
+
Name = "決勝",
|
196
|
+
|
197
|
+
Entries = new Match[]{
|
198
|
+
|
199
|
+
new Match {
|
200
|
+
|
201
|
+
Name = "第一試合",
|
202
|
+
|
203
|
+
Entries = new Match[]{
|
204
|
+
|
205
|
+
new Match {
|
206
|
+
|
207
|
+
Name = "田中太郎", Entries = new Match[0]
|
208
|
+
|
209
|
+
},
|
210
|
+
|
211
|
+
new Match {
|
212
|
+
|
213
|
+
Name = "鈴木一郎", Entries = new Match[0]
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
},
|
220
|
+
|
221
|
+
new Match {
|
222
|
+
|
223
|
+
// 略
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
```
|