public final class TableLib extends Object
This library provides generic functions for table manipulation. It provides all its functions
inside the table table.
Remember that, whenever an operation needs the length of a table, the table must be a proper
sequence or have a __len metamethod (see §3.4.7 of the Lua Reference Manual).
All functions ignore non-numeric keys in the tables given as arguments.
| Modifier and Type | Method and Description |
|---|---|
static org.classdump.luna.runtime.LuaFunction |
concat()
Returns the function
table.concat. |
static org.classdump.luna.runtime.LuaFunction |
insert()
Returns the function
table.insert. |
static void |
installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
Installs the table library to the global environment
env in the state
context context. |
static org.classdump.luna.runtime.LuaFunction |
move()
Returns the function
table.move. |
static org.classdump.luna.runtime.LuaFunction |
pack()
Returns the function
table.pack. |
static org.classdump.luna.runtime.LuaFunction |
remove()
Returns the function
table.remove. |
static org.classdump.luna.runtime.LuaFunction |
sort()
Returns the function
table.sort. |
static org.classdump.luna.runtime.LuaFunction |
unpack()
Returns the function
table.unpack. |
public static org.classdump.luna.runtime.LuaFunction concat()
table.concat.
The following is the corresponding entry from the Lua Reference Manual:
table.concat (list [, sep [, i [, j]]])Given a list where all elements are strings or numbers, returns the string
list[i]..sep..list[i+1] ··· sep..list[j]. The default value forsepis the empty string, the default foriis 1, and the default forjis#list. Ifiis greater thanj, returns the empty string.
table.concat functiontable.concatpublic static org.classdump.luna.runtime.LuaFunction insert()
table.insert.
The following is the corresponding entry from the Lua Reference Manual:
table.insert (list, [pos,] value)Inserts element value at position
posinlist, shifting up the elementslist[pos], list[pos+1], ···, list[#list]. The default value forposis#list+1, so that a calltable.insert(t,x)insertsxat the end of listt.
table.insert functiontable.insertpublic static org.classdump.luna.runtime.LuaFunction move()
table.move.
The following is the corresponding entry from the Lua Reference Manual:
table.move (a1, f, e, t [,a2])Moves elements from table
a1to tablea2. This function performs the equivalent to the following multiple assignment:a2[t],··· = a1[f],···,a1[e]. The default fora2isa1. The destination range can overlap with the source range. The number of elements to be moved must fit in a Lua integer.
table.move functiontable.movepublic static org.classdump.luna.runtime.LuaFunction pack()
table.pack.
The following is the corresponding entry from the Lua Reference Manual:
table.pack (···)Returns a new table with all parameters stored into keys 1, 2, etc. and with a field
"n"with the total number of parameters. Note that the resulting table may not be a sequence.
table.pack functiontable.packpublic static org.classdump.luna.runtime.LuaFunction remove()
table.remove.
The following is the corresponding entry from the Lua Reference Manual:
table.remove (list [, pos])Removes from
listthe element at positionpos, returning the value of the removed element. Whenposis an integer between 1 and#list, it shifts down the elementslist[pos+1], list[pos+2], ···, list[#list]and erases elementlist[#list]; The index pos can also be 0 when#listis 0, or#list + 1; in those cases, the function erases the elementlist[pos].The default value for
posis#list, so that a calltable.remove(l)removes the last element of listl.
table.remove functiontable.removepublic static org.classdump.luna.runtime.LuaFunction sort()
table.sort.
The following is the corresponding entry from the Lua Reference Manual:
table.sort (list [, comp])Sorts list elements in a given order, in-place, from
list[1]tolist[#list]. Ifcompis given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that, after the sort,i < jimpliesnot comp(list[j],list[i])). Ifcompis not given, then the standard Lua operator<is used instead.Note that the
compfunction must define a strict partial order over the elements in the list; that is, it must be asymmetric and transitive. Otherwise, no valid sort may be possible.The sort algorithm is not stable; that is, elements not comparable by the given order (e.g., equal elements) may have their relative positions changed by the sort.
table.sort functiontable.sortpublic static org.classdump.luna.runtime.LuaFunction unpack()
table.unpack.
The following is the corresponding entry from the Lua Reference Manual:
table.unpack (list [, i [, j]])Returns the elements from the given list. This function is equivalent to
return list[i], list[i+1], ···, list[j]By default,
iis 1 andjis#list.
table.unpack functiontable.unpackpublic static void installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
env in the state
context context.
If env.package.loaded is a table, adds the library table
to it with the key "table", using raw access.
context - the state context, must not be nullenv - the global environment, must not be nullNullPointerException - if context or env is nullCopyright © 2016–2017. All rights reserved.