Linklist.getposition

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

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.

See Also