Doubly-linked list/Element definition: Difference between revisions

→‎Tcl: Added implementation
m (→‎{{header|Ruby}}: formatting)
(→‎Tcl: Added implementation)
Line 312:
include Enumerable
end</lang>
 
=={{header|Tcl}}==
While it is highly unusual to implement linked lists in Tcl, since the language has a built-in list type (that internally uses arrays of references), it is possible to simulate it with objects.
<br>
{{Omitworks Fromwith|Tcl|8.6}}
<lang tcl>oo::class create List {
variable content next prev
constructor {value {list ""}} {
set content $value
set next $list
set prev ""
$next previous [self]
}
method value args {
set content {*}$args
}
method next args {
set next {*}$args
}
method previous args {
set prev {*}$args
}
}</lang>
 
=={{header|Visual Basic .NET}}==
Line 320 ⟶ 343:
Public Previous As Node(Of T)
End Class
 
 
{{Omit From|Tcl}}
Anonymous user