[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to create multi-dimensional table in C?
- From: Peter Cawley <lua@...>
- Date: Tue, 11 Aug 2009 01:15:31 +0100
On Tue, Aug 11, 2009 at 1:11 AM, Michael
Newberry<mnewberry@mirametrics.com> wrote:
> // Now stack looks like -2: RowTable, -1: ColumnTable
> // How do I do the equivalent of RT[ j ] = CT?
lua_rawseti(L, -2, j);
That'll set the item on the top of the stack (CT) to index j of the
table at -2 (RT).
lua_newtable( L ); // push a Row Table (the main table) onto the stack
for ( int j = 1; j <= nRows; j++ )
{
lua_newtable( L ); // push a Column Table onto the stack
for ( int i = 1; i <= nCols; i++ )
{
lua_pushnumber( L, i );
lua_pushstring( L, sValue );
lua_settable( L, -3 );
}
lua_rawseti(L, -2, j); // RT[j] = CT
}
- References:
- LuaJIT performance, John C. Turnbull
- Re: LuaJIT performance, Asko Kauppi
- Re: LuaJIT performance, Alexander Gladysh
- Re: LuaJIT performance, Mike Pall
- Re: LuaJIT performance, Alexander Gladysh
- Re: LuaJIT performance, Mike Pall
- Re: LuaJIT performance, Mark Hamburg
- Re: LuaJIT performance, Tony Finch
- Re: LuaJIT performance, Mark Hamburg
- How to create multi-dimensional table in C?, Michael Newberry