Typedefs | Enumerations | Functions

Hash Table
[Utilities]

Collaboration diagram for Hash Table:

Typedefs

typedef enum _Itable_IndexTypes Itable_IndexTypes
typedef enum _Itable_Types Itable_Types

Enumerations

enum  _Itable_IndexTypes { IUPTABLE_POINTERINDEXED = 10, IUPTABLE_STRINGINDEXED }
enum  _Itable_Types { IUPTABLE_POINTER, IUPTABLE_STRING, IUPTABLE_FUNCPOINTER }

Functions

IUP_SDK_API Itable * iupTableCreate (Itable_IndexTypes indexType)
IUP_SDK_API Itable * iupTableCreateSized (Itable_IndexTypes indexType, unsigned int initialSizeIndex)
IUP_SDK_API void iupTableDestroy (Itable *it)
IUP_SDK_API void iupTableClear (Itable *it)
IUP_SDK_API int iupTableCount (Itable *it)
IUP_SDK_API void iupTableSet (Itable *it, const char *key, void *value, Itable_Types itemType)
IUP_SDK_API void iupTableSetFunc (Itable *it, const char *key, Ifunc func)
IUP_SDK_API void * iupTableGet (Itable *it, const char *key)
IUP_SDK_API Ifunc iupTableGetFunc (Itable *it, const char *key, void **value)
IUP_SDK_API void * iupTableGetTyped (Itable *it, const char *key, Itable_Types *itemType)
IUP_SDK_API void iupTableRemove (Itable *it, const char *key)
IUP_SDK_API char * iupTableFirst (Itable *it)
IUP_SDK_API char * iupTableNext (Itable *it)
IUP_SDK_API void * iupTableGetCurr (Itable *it)
IUP_SDK_API int iupTableGetCurrType (Itable *it)
IUP_SDK_API void iupTableSetCurr (Itable *it, void *value, Itable_Types itemType)
IUP_SDK_API char * iupTableRemoveCurr (Itable *it)

Detailed Description

The hash table can be indexed by strings or pointer address, and each value can contain strings, pointers or function pointers.
See iup_table.h

Typedef Documentation

How the table key is interpreted.

How the value is interpreted.


Enumeration Type Documentation

How the table key is interpreted.

Enumerator:
IUPTABLE_POINTERINDEXED 

a pointer address is used as key.

IUPTABLE_STRINGINDEXED 

a string as key

How the value is interpreted.

Enumerator:
IUPTABLE_POINTER 

regular pointer for strings and other pointers

IUPTABLE_STRING 

string duplicated internally

IUPTABLE_FUNCPOINTER 

function pointer


Function Documentation

IUP_SDK_API Itable* iupTableCreate ( Itable_IndexTypes  indexType  ) 

Creates a hash table with an initial default size. This function is equivalent to iupTableCreateSized(0);

IUP_SDK_API Itable* iupTableCreateSized ( Itable_IndexTypes  indexType,
unsigned int  initialSizeIndex 
)

Creates a hash table with the specified initial size. Use this function if you expect the table to become very large. initialSizeIndex is an array into the (internal) list of possible hash table sizes. Currently only indexes from 0 to 8 are supported. If you specify a higher value here, the maximum allowed value will be used.

IUP_SDK_API void iupTableDestroy ( Itable *  it  ) 

Destroys the Itable. Calls iupTableClear.

IUP_SDK_API void iupTableClear ( Itable *  it  ) 

Removes all items in the table. This function does also free the memory of strings contained in the table!!!!

IUP_SDK_API int iupTableCount ( Itable *  it  ) 

Returns the number of keys stored in the table.

IUP_SDK_API void iupTableSet ( Itable *  it,
const char *  key,
void *  value,
Itable_Types  itemType 
)

Store an element in the table.

IUP_SDK_API void iupTableSetFunc ( Itable *  it,
const char *  key,
Ifunc  func 
)

Store a function pointer in the table. Type is set to IUPTABLE_FUNCPOINTER.

IUP_SDK_API void* iupTableGet ( Itable *  it,
const char *  key 
)

Retrieves an element from the table. Returns NULL if not found.

IUP_SDK_API Ifunc iupTableGetFunc ( Itable *  it,
const char *  key,
void **  value 
)

Retrieves a function pointer from the table. If not a function or not found returns NULL. value always contains the element pointer.

IUP_SDK_API void* iupTableGetTyped ( Itable *  it,
const char *  key,
Itable_Types itemType 
)

Retrieves an element from the table and its type.

IUP_SDK_API void iupTableRemove ( Itable *  it,
const char *  key 
)

Removes the entry at the specified key from the hash table and frees the memory used by it if it is a string...

IUP_SDK_API char* iupTableFirst ( Itable *  it  ) 

Key iteration function. Returns a key. To iterate over all keys call iupTableFirst at the first and call iupTableNext in a loop until 0 is returned... Do NOT change the content of the hash table during iteration. During an iteration you can use context with iupTableGetCurr() to access the value of the key very fast.

IUP_SDK_API char* iupTableNext ( Itable *  it  ) 

Key iteration function. See iupTableNext.

IUP_SDK_API void* iupTableGetCurr ( Itable *  it  ) 

Returns the value at the current position.
The current context is an iterator that is filled by iupTableNext().
iupTableGetCur() is faster then iupTableGet(), so when you want to access an item stored at a key returned by iupTableNext(), use this function instead of iupTableGet().

IUP_SDK_API int iupTableGetCurrType ( Itable *  it  ) 

Returns the type at the current position.
Same as iupTableGetCurr but returns the type. Returns -1 if failed.

IUP_SDK_API void iupTableSetCurr ( Itable *  it,
void *  value,
Itable_Types  itemType 
)

Replaces the data at the current position.

IUP_SDK_API char* iupTableRemoveCurr ( Itable *  it  ) 

Removes the current element and returns the next key. Use this function to remove an element during an iteration.