質問編集履歴
2
update
test
CHANGED
File without changes
|
test
CHANGED
@@ -242,6 +242,54 @@
|
|
242
242
|
|
243
243
|
}
|
244
244
|
|
245
|
+
|
246
|
+
|
247
|
+
public String getString() {
|
248
|
+
|
249
|
+
return t;
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
@Override
|
256
|
+
|
257
|
+
public boolean equals(Object other) {
|
258
|
+
|
259
|
+
if (this == other)
|
260
|
+
|
261
|
+
return true;
|
262
|
+
|
263
|
+
if (other == null)
|
264
|
+
|
265
|
+
return false;
|
266
|
+
|
267
|
+
if (!(other instanceof Node))
|
268
|
+
|
269
|
+
return false;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
return t.equals(((Node)other).getString());
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
@Override
|
280
|
+
|
281
|
+
public int hashCode() {
|
282
|
+
|
283
|
+
if ( t == null )
|
284
|
+
|
285
|
+
return 0;
|
286
|
+
|
287
|
+
return t.hashCode();
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
245
293
|
}
|
246
294
|
|
247
295
|
|
1
tuiki
test
CHANGED
File without changes
|
test
CHANGED
@@ -133,3 +133,117 @@
|
|
133
133
|
}
|
134
134
|
|
135
135
|
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
追記
|
142
|
+
|
143
|
+
上記の参照を参考にすると上記のdataは以下のコードの中でtになるかと思いました。
|
144
|
+
|
145
|
+
Node.java
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
public class Node {
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
public Node next;
|
154
|
+
|
155
|
+
public Node prev;
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
private String t;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
public Node(Node next, Node prev, String token) {
|
164
|
+
|
165
|
+
this.next = next;
|
166
|
+
|
167
|
+
this.prev = prev;
|
168
|
+
|
169
|
+
this.t = token;
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
test.java
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
public class DSEList implements List {
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
public Node head;
|
188
|
+
|
189
|
+
public Node tail; // ?original private?
|
190
|
+
|
191
|
+
// keeping track of size
|
192
|
+
|
193
|
+
public int size; // step one
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
public DSEList() {
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
public DSEList(Node head_) {
|
204
|
+
|
205
|
+
head = head_;
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
//Takes a list then adds each element into a new list
|
212
|
+
|
213
|
+
public DSEList(DSEList other) { // Copy constructor.
|
214
|
+
|
215
|
+
head = other.head;
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
public String get(int index) {
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
if(index < 0 || index >= size) {
|
226
|
+
|
227
|
+
throw new ArrayIndexOutOfBoundsException(Integer.toString(index));
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
Node current = head;
|
232
|
+
|
233
|
+
for(int i = 0; i < index; i++) {
|
234
|
+
|
235
|
+
current = current.next;
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
return current.t;
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
```
|