Linklist.getposition

From OpenEUO
Revision as of 13:41, 18 December 2010 by Ximan (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Calling Pattern

Call

local k = sl.linklist()
-- later
local n = k.getposition(a[,b])

Arguments

a is a number
b optional, is a boolean

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 getposition returns the absolute position of a link psuedo-index relative to the head of the list. If b is specified and has a value of false then getposition returns the position relative to the tail of the list. Positions run from 1 to the length of the linked list. If the parameter supplied is an invalid pseudo-index, then getposition returns 0. ** There is an error in version 0.06 that will be corrected in later versions. If b is false, getposition will return the wrong values if the pseudo-index is either the head or tail of the list.**

See Also