108 lines
2.4 KiB
C++
108 lines
2.4 KiB
C++
////////////////////////////////////////////////////////////
|
|
//
|
|
// This module contains a library of lua functions
|
|
// for manipulating tables. It also provides a library
|
|
// of useful classes based on tables.
|
|
//
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
#ifndef TABLE_HPP
|
|
#define TABLE_HPP
|
|
|
|
#include "luastack.hpp"
|
|
|
|
// table_equal
|
|
//
|
|
// True if two tables contain the same key/value pairs.
|
|
//
|
|
bool table_equal(LuaStack &LS0, LuaSlot tab1, LuaSlot tab2);
|
|
|
|
// table_getpairs
|
|
//
|
|
// Get a table containing the key-value pairs in tab. Optionally sort
|
|
// the pairs. Return true if all keys were sortable.
|
|
//
|
|
bool table_getpairs(LuaStack &LS0, LuaSlot tab, LuaSlot pairs, bool sort);
|
|
|
|
// table_findremove
|
|
//
|
|
// Given a vector and a value, remove the specified value from
|
|
// the vector, and shift elements downward to fill the gaps.
|
|
//
|
|
int lfn_table_findremove(lua_State *L);
|
|
|
|
// table_push
|
|
//
|
|
// Given a vector and a value, push the value onto the end.
|
|
//
|
|
int lfn_table_push(lua_State *L);
|
|
|
|
// table_find
|
|
//
|
|
// Given a vector and a value, search for the first occurrence
|
|
// of that value. Return the index.
|
|
//
|
|
int lfn_table_find(lua_State *L);
|
|
|
|
// table_empty
|
|
//
|
|
// Return true if the table has no key/value pairs.
|
|
//
|
|
int lfn_table_empty(lua_State *L);
|
|
|
|
// table_count
|
|
//
|
|
// Return the number of key/value pairs in the table.
|
|
//
|
|
int lfn_table_count(lua_State *L);
|
|
|
|
//
|
|
// Create and return an empty deque. Queues are implemented
|
|
// as tables which are used as dynamically-expandable circular
|
|
// buffers.
|
|
//
|
|
int lfn_deque_create(lua_State *L);
|
|
|
|
//
|
|
// Given a deque and a value, pushes the value onto the
|
|
// left or right end.
|
|
//
|
|
int lfn_deque_pushl(lua_State *L);
|
|
int lfn_deque_pushr(lua_State *L);
|
|
|
|
//
|
|
// Given a deque, pop from the left or right end. Returns the
|
|
// value and removes it from the deque. If the deque is
|
|
// empty, returns nil.
|
|
//
|
|
int lfn_deque_popl(lua_State *L);
|
|
int lfn_deque_popr(lua_State *L);
|
|
|
|
//
|
|
// Return the nth element from the left or right end of a deque.
|
|
//
|
|
int lfn_deque_nthl(lua_State *L);
|
|
int lfn_deque_nthr(lua_State *L);
|
|
|
|
// Set (overwrite) the nth element in a deque.
|
|
//
|
|
int lfn_deque_setl(lua_State *L);
|
|
int lfn_deque_setr(lua_State *L);
|
|
|
|
//
|
|
// Search a deque for a value.
|
|
//
|
|
// Search starts on the specified end and indices are relative
|
|
// to specified end.
|
|
//
|
|
int lfn_deque_findl(lua_State *L);
|
|
int lfn_deque_findr(lua_State *L);
|
|
|
|
//
|
|
// Return the number of values in the deque.
|
|
//
|
|
int lfn_deque_size(lua_State *L);
|
|
|
|
#endif // TABLE_HPP
|