Singly-linked list/Element insertion: Difference between revisions
Content added Content deleted
(→{{header|ooRexx}}: Add example for ooRexx) |
(→{{header|ooRexx}}: Better version of this and a reference to full class definition.) |
||
Line 677: | Line 677: | ||
=={{header|ooRexx}}== |
=={{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> |
<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> |
</lang> |
||
=={{header|Pascal}}== |
=={{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<<]" |
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<<]" |