|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaTable
org.luaj.vm2.WeakTable
public class WeakTable
Subclass of LuaTable that provides weak key and weak value semantics.
Normally these are not created directly, but indirectly when changing the mode
of a LuaTable as lua script executes.
However, calling the constructors directly when weak tables are required from Java will reduce overhead.
| Field Summary |
|---|
| Fields inherited from class org.luaj.vm2.LuaTable |
|---|
array, hashEntries, hashKeys, hashValues, m_metatable |
| Fields inherited from class org.luaj.vm2.LuaValue |
|---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO |
| Constructor Summary | |
|---|---|
|
WeakTable(boolean weakkeys,
boolean weakvalues)
Construct a table with weak keys, weak values, or both |
protected |
WeakTable(boolean weakkeys,
boolean weakvalues,
int narray,
int nhash)
Construct a table with weak keys, weak values, or both, and an initial capacity |
protected |
WeakTable(boolean weakkeys,
boolean weakvalues,
LuaTable source)
Construct a table with weak keys, weak values, or both, and a source of initial data |
| Method Summary | |
|---|---|
protected LuaTable |
changemode(boolean weakkeys,
boolean weakvalues)
Change the mode of a table |
protected int |
getArrayLength()
Get the length of the array part of the table. |
protected int |
getHashLength()
Get the length of the hash part of the table. |
int |
hashFindSlot(LuaValue key)
Find the hashtable slot to use |
protected LuaValue |
hashget(LuaValue key)
Get the hash value for a key key the key to look up |
int |
maxn()
Return table.maxn() as defined by lua 5.0. |
Varargs |
next(LuaValue key)
Get the next element after a particular key in the table |
void |
presize(int narray)
Preallocate the array part of a table to be a certain size, |
void |
presize(int narray,
int nhash)
Presize capacity of both array and hash parts. |
LuaValue |
rawget(int key)
Get a value in a table without metatag processing. |
LuaValue |
rawget(LuaValue key)
Get a value in a table without metatag processing. |
void |
rawset(int key,
LuaValue value)
Set a value in a table without metatag processing. |
void |
rawset(LuaValue key,
LuaValue value)
caller must ensure key is not nil |
void |
sort(LuaValue comparator)
Sort the table using a comparator. |
| Methods inherited from class org.luaj.vm2.LuaTable |
|---|
checktable, concat, eq_b, eq, foreach, foreachi, get, get, getmetatable, getn, hashClearSlot, hashset, inext, insert, istable, keyCount, keys, len, length, opttable, remove, set, set, setmetatable, type, typename |
| Methods inherited from class org.luaj.vm2.Varargs |
|---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WeakTable(boolean weakkeys,
boolean weakvalues)
weakkeys - true to let the table have weak keysweakvalues - true to let the table have weak values
protected WeakTable(boolean weakkeys,
boolean weakvalues,
int narray,
int nhash)
weakkeys - true to let the table have weak keysweakvalues - true to let the table have weak valuesnarray - capacity of array partnhash - capacity of hash part
protected WeakTable(boolean weakkeys,
boolean weakvalues,
LuaTable source)
weakkeys - true to let the table have weak keysweakvalues - true to let the table have weak valuessource - LuaTable containing the initial elements| Method Detail |
|---|
public void presize(int narray)
LuaValuePrimarily used internally in response to a SETLIST bytecode.
presize in class LuaTablenarray - the number of array slots to preallocate in the table.
public void presize(int narray,
int nhash)
presize in class LuaTablenarray - capacity of array partnhash - capacity of hash partprotected int getArrayLength()
LuaTable
getArrayLength in class LuaTableprotected int getHashLength()
LuaTable
getHashLength in class LuaTable
protected LuaTable changemode(boolean weakkeys,
boolean weakvalues)
LuaTable
changemode in class LuaTableweakkeys - true to make the table have weak keys going forwardweakvalues - true to make the table have weak values going forward
this or a new WeakTable if the mode change requires copying.
public void rawset(int key,
LuaValue value)
LuaValue
rawset in class LuaTablekey - the key to usevalue - the value to use, can be NIL, must not be null
public void rawset(LuaValue key,
LuaValue value)
LuaTable
rawset in class LuaTablekey - the key to use, must not be NIL or nullvalue - the value to use, can be NIL, must not be nullpublic LuaValue rawget(int key)
LuaValue
rawget in class LuaTablekey - the key to look up
LuaValue for that key, or NIL if not foundpublic LuaValue rawget(LuaValue key)
LuaValue
rawget in class LuaTablekey - the key to look up, must not be NIL or null
LuaValue for that key, or NIL if not foundprotected LuaValue hashget(LuaValue key)
hashget in class LuaTablepublic int hashFindSlot(LuaValue key)
LuaTable
hashFindSlot in class LuaTablekey - key to look for
public int maxn()
LuaTableProvided for compatibility, not a scalable operation.
maxn in class LuaTablepublic Varargs next(LuaValue key)
next in class LuaTablekey - LuaInteger value identifying a key to start from,
or NIL to start at the beginning
LuaTable,
#inext(),
LuaValue.valueOf(int),
Varargs.arg1(),
Varargs.arg(int),
LuaValue.isnil()public void sort(LuaValue comparator)
LuaTable
sort in class LuaTablecomparator - LuaValue to be called to compare elements.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||