public class DefaultTable extends Table
Constructor and Description |
---|
DefaultTable()
Constructs a new empty table.
|
Modifier and Type | Method and Description |
---|---|
static TableFactory |
factory()
Returns the table factory for constructing instances of
DefaultTable . |
Object |
initialKey()
Returns the initial key for iterating through the set of keys in this table.
|
Object |
rawget(Object key)
Retrieves the value associated with the given
key , returning null
when key has no value associated with it. |
void |
rawset(Object key,
Object value)
Sets the value associated with the key
key to value . |
protected void |
setMode(boolean weakKeys,
boolean weakValues)
Sets the weakness of this table.
|
Object |
successorKeyOf(Object key)
Returns the next key for iterating through the set of keys in this table.
|
getMetatable, rawget, rawlen, rawset, setMetatable, updateBasetableModes
public static TableFactory factory()
DefaultTable
.DefaultTable
spublic Object rawget(Object key)
Table
key
, returning null
when key
has no value associated with it.
Implementations of this method must ensure that the Lua rules for valid
table keys are honoured, e.g. by normalising keys using
Conversions.normaliseKey(Object)
.
This method provides raw access to the table. For non-raw access
(i.e., handling the __index
metamethod), use
Dispatch.index(ExecutionContext, Table, Object)
.
public void rawset(Object key, Object value)
Table
key
to value
. When value
is null
, removes key
from the table.
When key
is null
(i.e., a nil) or a NaN,
an IllegalArgumentException
is thrown.
This method provides raw access to the table. For non-raw access
(i.e., handling the __newindex
metamethod), use
Dispatch.setindex(ExecutionContext, Table, Object, Object)
.
Implementation notes: Implementations of this method must ensure that the behaviour of this method conforms to the Lua semantics as delineated in the Lua Reference Manual. In particular:
Conversions.normaliseKey(Object)
;"__mode"
must call Table.updateBasetableModes(Object, Object)
.public Object initialKey()
Table
Conceptually speaking, all keys in this table are totally ordered; this method returns the minimal key.
The key returned by this method, together with the subsequent calls
to Table.successorKeyOf(Object)
will visit all keys in this table exactly once
(in an unspecified order):
Object k = table.initialIndex(); while (k != null) { // process the key k k = table.nextIndex(k); } // at this point, we visited all keys in table exactly once
initialKey
in class Table
public Object successorKeyOf(Object key)
Table
Conceptually speaking, all keys in this table are totally ordered; this method
returns the immediate successor of key
, or null
if key
is
the maximal key.
When no value is associated with the key key
in this table,
an IllegalArgumentException
is thrown.
To retrieve the initial key for iterating through this table, use
Table.initialKey()
.
successorKeyOf
in class Table
key
- the key to get the immediate successor of, must not be null
key
in this tableprotected void setMode(boolean weakKeys, boolean weakValues)
Table
weakKeys
is true
, the table will have
weak keys (otherwise, the table will have non-weak keys). Similarly, if weakValues
is true
, the table will have weak values (and non-weak values if false
).
This method is not meant to be called directly: according to ยง2.5.2 of the Lua
Reference Manual, the weakness of a table is fully determined by the value of the
"__mode"
field of its metatable. It is, however, meant to be called as part
of maintenance of this requirement by Table.setMetatable(Table)
and
Table.updateBasetableModes(Object, Object)
.
Copyright © 2016. All rights reserved.