Linklist.insertafter
From OpenEUO
Revision as of 13:54, 18 December 2010 by Ximan (Talk | contribs) (Created page with "== Calling Pattern == Call local k = sl.linklist() -- later local n = k.insertafter(a,b) Arguments a is a number b is any value Results n is a number == Example Usage ==...")
Calling Pattern
Call
local k = sl.linklist() -- later local n = k.insertafter(a,b)
Arguments
a is a number b is any value
Results
n is a number
Example Usage
local k = sl.linklist() local j = k.inserta(0,'one') local j0 = j j = k.inserta(j,'two') j = k.inserta(j,'three') print(k.getpos(j0)) print(k.getpos(j))
--> 1 3
Description
Calling insertafter creates a new link with value b and inserts it before the link with psuedo-index a. If the list is empty, a can be any number and the new link is also the head and tail of the list. If the list is non-empty and a is not a valid pseudo-index, then insertafter fails and returns 0.