Difference between revisions of "Linklist.insertbefore"
From OpenEUO
					
										
					
					|  (Created page with "== Calling Pattern == Call  local k = sl.linklist()  -- later  local n = k.insertbefore(a,b)  Arguments  a is a number  b is any value  Results  n is a number  == Example Usage =...") | 
| (No difference) | 
Latest revision as of 14:52, 18 December 2010
Calling Pattern
Call
local k = sl.linklist() -- later local n = k.insertbefore(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.insertb(0,'one') local j0 = j j = k.insertb(j,'two') j = k.insertb(j,'three') print(k.getpos(j0)) print(k.getpos(j))
--> 3
    1 
Description
Calling insertbefore 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 insertbefore fails and returns 0.
