lua-users home
lua-l archive

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



On 28 Oct 2010, at 17:02, spir wrote:

What method does, in your case, tuple.create use to check wether a given tuple _value_ already exists? Are they sorted -- how? For comparison, is there any other way than blindly comparing tuple- table content (when cardinals match)?


My tuples are nested tables. When you call 'tuple.create(a,b,c)' is the same thing as 'tuple.index[a][b][c]'. I use '__index' to create new tuples on demand, but the second time a tuple is recovered only simple table indexing are performed. Therefore, it is necessary to index n tables to retrieve an existing tuple of cardinality n. No sorting nor content comparisons are necessary. The implementation is rather small and simple, have a look if you get curious.

--
Renato Maia
Computer Scientist
Tecgraf/PUC-Rio
__________________________
http://www.inf.puc-rio.br/~maia/