Anonymous user
Doubly-linked list/Element definition: Difference between revisions
Doubly-linked list/Element definition (view source)
Revision as of 12:47, 16 May 2009
, 15 years ago→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>
<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}}
|