[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to create multi-dimensional table in C?
- From: "Michael Newberry" <mnewberry@...>
- Date: Tue, 11 Aug 2009 07:57:09 -0700
Hi Peter,
Thank you very much for the help. That solved my problem!
Michael
----- Original Message -----
From: "Peter Cawley" <lua@corsix.org>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Monday, August 10, 2009 5:15 PM
Subject: Re: How to create multi-dimensional table in C?
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
- Re: How to create multi-dimensional table in C?, Peter Cawley