Difference between revisions of "Linklist.getposition"

From OpenEUO
Jump to: navigation, search
(Created page with "== 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 == Exam...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 27: Line 27:
 
== Description ==
 
== 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.
+
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 ==
 
== See Also ==
Line 35: Line 35:
 
* [[deque]]
 
* [[deque]]
  
 +
* [[linklist]]
 
* [[linklist.head]]
 
* [[linklist.head]]
 
* [[linklist.insertafter]]
 
* [[linklist.insertafter]]

Latest revision as of 13:41, 18 December 2010

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