lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Depends if child nodes need to be ordered.

Not ordered:

parent.nodes[ node ] = node


table.insert( parent.nodes, node )

The first is better in terms of insert/find/remove efficiency, but child
nodes are not in any dependable order.


> I need to implement a DAG structure(or rather a tree where 
> each node can have an arbitrary number of children) using lua 
> tables. The table will be traversed from C during every frame 
> so it should be as fast as possible to do so. It should also 
> be relatively fast and easy to add and remove nodes from the 
> DAG. I have thought of a couple of ways to do that but some 
> people here have much more experience with LUA so they might 
> know of a better/more efficient way to implement a DAG.
> Dimitris