PEDN> Main Web>NPL>StandardTemplateLibrary (2008-02-29, LiXizhi) Change language en zh-cn? EditAttach

Standard Template Library in NPL

a similar simplementation as STL (Standard Libaray) in NPL

Title a similar simplementation as STL (Standard Libaray) in NPL
Author(s) LiXizhi
Date 2007/9/22 (stack), 2008/2/7(queue)
File script/ide/STL.lua

Description

Uses a table as stack, use :push(value) and
:pop() Lua 5.1 compatible

TIP Sample Code

NPL.load("(gl)script/ide/STL.lua");
-- create stack
stack = commonlib.Stack:Create()
-- push values on to the stack
stack:commonlib.push("a", "b")
-- pop values
commonlib.stack:pop(2)
-- queue example
local q = commonlib.Queue.new(); q:pushleft("A"); log(q:popright())

Member Functions

Stack:Create


stack
local Stack = {}; commonlib.Stack = Stack

Create a Table with stack functions

syntax

function Stack:Create()

Queue.new


queue: from official LUA site
local Queue = {}; commonlib.Queue = Queue

syntax

function Queue.new ()
Topic revision: r1 - 2008-02-29 - 15:26:12 - LiXizhi
 

ParaEngine Developer Network

This site is powered by the TWiki collaboration platformCopyright © 2004-2009 ParaEngine Corporation
Ideas, requests, problems regarding ParaEngine platform Send feedback