Combining two repos
This commit is contained in:
113
luprex/core/cpp/table.hpp
Normal file
113
luprex/core/cpp/table.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TABLE
|
||||
//
|
||||
// This module contains a library of lua functions
|
||||
// for manipulating tables. Some of the functions only
|
||||
// work on vectors (ie, tables with integer keys starting
|
||||
// at one). When a function only works on vectors, it
|
||||
// is noted.
|
||||
//
|
||||
// QUEUE
|
||||
//
|
||||
// This module contains a library of lua functions for
|
||||
// manipulating queues. Queues are represented as a table
|
||||
// with a "head" and a "tail", and with integer-keyed values.
|
||||
// For example:
|
||||
//
|
||||
// {
|
||||
// "tail": 100,
|
||||
// "head": 103,
|
||||
// 100: "a",
|
||||
// 101: "b",
|
||||
// 102: "c"
|
||||
// }
|
||||
//
|
||||
// Values are pushed onto the head, and values are popped
|
||||
// from the tail.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef TABLE_HPP
|
||||
#define TABLE_HPP
|
||||
|
||||
#include "luastack.hpp"
|
||||
|
||||
// table_equal
|
||||
//
|
||||
// True if two tables contain the same key/value pairs.
|
||||
//
|
||||
int table_equal(lua_State *L);
|
||||
|
||||
// table_findremove
|
||||
//
|
||||
// Given a vector and a value, remove the specified value from
|
||||
// the vector, and shift elements downward to fill the gaps.
|
||||
//
|
||||
int table_findremove(lua_State *L);
|
||||
|
||||
// table_push
|
||||
//
|
||||
// Given a vector and a value, push the value onto the end.
|
||||
//
|
||||
int 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 table_find(lua_State *L);
|
||||
|
||||
// table_empty
|
||||
//
|
||||
// Return true if the table has no key/value pairs.
|
||||
//
|
||||
int table_empty(lua_State *L);
|
||||
|
||||
// table_count
|
||||
//
|
||||
// Return the number of key/value pairs in the table.
|
||||
//
|
||||
int table_count(lua_State *L);
|
||||
|
||||
// table_clear
|
||||
//
|
||||
// Remove all key/value pairs from the table. Does not
|
||||
// remove the metatable.
|
||||
//
|
||||
int table_clear(lua_State *L);
|
||||
|
||||
// queue_create
|
||||
//
|
||||
// Create and return an empty queue.
|
||||
//
|
||||
int queue_create(lua_State *L);
|
||||
|
||||
// queue_push
|
||||
//
|
||||
// Given a queue and a value, pushes the value onto the queue.
|
||||
//
|
||||
int queue_push(lua_State *L);
|
||||
|
||||
// queue_pop
|
||||
//
|
||||
// Given a queue, pop and return a value. If the queue is empty,
|
||||
// returns nil.
|
||||
//
|
||||
int queue_pop(lua_State *L);
|
||||
|
||||
// queue_size
|
||||
//
|
||||
// Return the number of values in the queue.
|
||||
//
|
||||
int queue_size(lua_State *L);
|
||||
|
||||
// queue_nth
|
||||
//
|
||||
// Return the nth element in the queue.
|
||||
//
|
||||
int queue_nth(lua_State *L);
|
||||
|
||||
#endif // TABLE_HPP
|
||||
Reference in New Issue
Block a user