Doubly-linked list/Definition: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(Added Kotlin)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,424:
=={{header|Kotlin}}==
Rather than use the java.util.LinkedList<E> class, we will write our own simple LinkedList<E> class for this task:
<lang scala>// version 1.1.12
 
class LinkedList<E> {
Line 1,468:
fun insert(after: Node<E>?, value: E) {
if (after == null)
addFirst(value)
else if (after == last)
addLast(value)
else {
val next = after.next
val new = Node(value, after, next)
after.next = new
Line 1,479:
}
 
override fun toString() = first.toString()
}