Jump to content

Singly-linked list/Element insertion: Difference between revisions

→‎{{header|ooRexx}}: Better version of this and a reference to full class definition.
(→‎{{header|ooRexx}}: Add example for ooRexx)
(→‎{{header|ooRexx}}: Better version of this and a reference to full class definition.)
Line 677:
 
=={{header|ooRexx}}==
See [[Singly-linked_list/Element_definition#ooRexx|Single-linked list/Element definition]] for full class definition.
Extending [[Singly-Linked_List_(element)#ooRexx]]
<lang ooRexx>
list = .linkedlist~new
::method insert
index = list~insert("abc") -- insert a first item, keeping the index
expose next
list~insert("def") -- adds to the end
use strict newNode
list~insert("123", .nil) -- adds to the begining
newNode~next = next
list~insert("456", index) -- inserts between "abc" and "def"
next = newNode
list~remove(index) -- removes "abc"
</lang>
 
=={{header|Pascal}}==
Note: This code uses only Standard Pascal features. For code using features only available in modern Pascal versions, see above under "[Delphi / Object Pascal / >>Turbo Pascal<<]"
Cookies help us deliver our services. By using our services, you agree to our use of cookies.