nakedmudv3.3/
nakedmudv3.3/lib/
nakedmudv3.3/lib/logs/
nakedmudv3.3/lib/misc/
nakedmudv3.3/lib/players/
nakedmudv3.3/lib/txt/
nakedmudv3.3/lib/world/
nakedmudv3.3/lib/world/examples/
nakedmudv3.3/lib/world/examples/mproto/
nakedmudv3.3/lib/world/examples/oproto/
nakedmudv3.3/lib/world/examples/reset/
nakedmudv3.3/lib/world/examples/rproto/
nakedmudv3.3/lib/world/examples/trigger/
nakedmudv3.3/lib/world/limbo/
nakedmudv3.3/lib/world/limbo/room/
nakedmudv3.3/lib/world/limbo/rproto/
nakedmudv3.3/src/alias/
nakedmudv3.3/src/char_vars/
nakedmudv3.3/src/editor/
nakedmudv3.3/src/example_module/
nakedmudv3.3/src/help/
nakedmudv3.3/src/set_val/
nakedmudv3.3/src/socials/
nakedmudv3.3/src/time/
#ifndef __PROPERTY_TABLE_H
#define __PROPERTY_TABLE_H
//*****************************************************************************
//
// property_table.h
//
// A little idea I thought up, mainly for quick lookup of elements by vnum.
//
// Exactly like a hashtable, except the <key> component of some element is
// built into the element itself, and defined by a function that is passed
// in when the propery table is created. Currently, the property_table only
// allows one item per property value to be stored, but later on down the
// road we will expand this so that the table will collect -sets- of items
// with a given property.
//
// the main purpose for this table is to store obj/mob/script/etc prototypes,
// as well as rooms in the game.
//
//*****************************************************************************

typedef struct property_table             PROPERTY_TABLE;
typedef struct property_table_iterator    PROPERTY_TABLE_ITERATOR;


//
// Create a new property table with the specified number of buckets
// (more buckets = faster lookup, but more memory). The key function must
// be a function that returns a positive integer (no upper bound)
//
PROPERTY_TABLE *newPropertyTable(void *key_function, int buckets);


//
// Delete the property table, but not the elements housed within it.
//
void deletePropertyTable(PROPERTY_TABLE *table);


//
// Put an element in the table. Its key is determined by the
// function we have already passed in upon creating this table.
//
void propertyTablePut(PROPERTY_TABLE *table, void *elem);


//
// Remove and return the value assocciated with this key and our
// key-function. Return NULL if nothing exists.
//
void *propertyTableRemove(PROPERTY_TABLE *table, int key);


//
// Return the value assocciated with the key and our key-function.
// return NULL if nothing exists
//
void *propertyTableGet(PROPERTY_TABLE *table, int key);


//
// Return true if a value with the specified key exists
//
bool propertyTableIn(PROPERTY_TABLE *table, int key);



//*****************************************************************************
//
// property table iterator
//
// we may sometimes want to iterate across all of the elements in a table.
// this lets us do so.
//
//*****************************************************************************

//
// Create an iterator to go over the table
//
PROPERTY_TABLE_ITERATOR *newPropertyTableIterator(PROPERTY_TABLE *T);


//
// Delete the iterator (but not the contents)
//
void deletePropertyTableIterator(PROPERTY_TABLE_ITERATOR *I);


//
// Point the iterator back at the start of the table
//
void propertyTableIteratorReset(PROPERTY_TABLE_ITERATOR *I);


//
// Skip to the next element. Return the next element
// if one exists, and NULL otherwise.
//
void *propertyTableIteratorNext(PROPERTY_TABLE_ITERATOR *I);


//
// return a pointer to the current element
//
void *propertyTableIteratorCurrent(PROPERTY_TABLE_ITERATOR *I);

#endif // __PROPERTY_TABLE_H