18 lines
375 B
Text
18 lines
375 B
Text
enum NEXT,PREV,DATA
|
|
constant empty_dll = {{1,1}}
|
|
sequence dll = empty_dll
|
|
|
|
procedure insert_after(object data, integer pos=1)
|
|
integer prv = dll[pos][PREV]
|
|
dll = append(dll,{pos,prv,data})
|
|
if prv!=0 then
|
|
dll[prv][NEXT] = length(dll)
|
|
end if
|
|
dll[pos][PREV] = length(dll)
|
|
end procedure
|
|
|
|
insert_after("ONE")
|
|
insert_after("TWO")
|
|
insert_after("THREE")
|
|
|
|
?dll
|