Commit be9ea81
Cleanup DoublyLinkedList: fix API, simplify code, expand tests (williamfiset#1260)
* Cleanup DoublyLinkedList and expand test coverage
- Add proper import for java.util.Iterator instead of inline qualified names
- Change addAt to throw IndexOutOfBoundsException instead of checked Exception
- Remove pointless local variable assignments in clear() and remove(Node)
- Move trav declaration to point of use in remove(Object)
- Replace inline java.util imports with proper imports in tests
- Expand test suite from 18 to 30 tests covering contains, indexOf,
null handling, invalid indices, iterator, and forEach
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* Disallow null elements in DoublyLinkedList
- Reject null in addFirst/addLast with IllegalArgumentException
- Simplify remove(Object) and indexOf(Object) by removing null branches
- Replace null-related tests with testNullRejection
- Remove null entries from randomized test data generators
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 <[email protected]>1 parent d5dc0b8 commit be9ea81
File tree
2 files changed
+149
-61
lines changed- src
- main/java/com/williamfiset/algorithms/datastructures/linkedlist
- test/java/com/williamfiset/algorithms/datastructures/linkedlist
2 files changed
+149
-61
lines changedLines changed: 17 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | | - | |
| 85 | + | |
82 | 86 | | |
83 | | - | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
176 | | - | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
227 | 218 | | |
228 | 219 | | |
229 | 220 | | |
| |||
232 | 223 | | |
233 | 224 | | |
234 | 225 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
250 | 229 | | |
251 | 230 | | |
252 | 231 | | |
| |||
258 | 237 | | |
259 | 238 | | |
260 | 239 | | |
261 | | - | |
262 | | - | |
| 240 | + | |
| 241 | + | |
263 | 242 | | |
264 | 243 | | |
265 | 244 | | |
| |||
0 commit comments