regify utility  2.0.0-0
Hash Set

This section contains a hash set implementation. More...

Macros

#define ruSetPut(rs, item)   ruSetPutItem(rs, (ptr)(item))
 Runs ruSetPutItem with a ptr cast. More...
 
#define ruSetRemove(rs, item)   ruSetRemoveItem(rs, (ptr)(item))
 Runs ruSetRemoveItem with a ptr cast. More...
 
#define ruSetHas(rs, item, code)   ruSetHasItem(rs, (trans_ptr)(item), code)
 Runs ruSetHasItem with a ptr casted item. More...
 
#define ruSetFirst(rs, item)   ruSetFirstSet(rs, (ptr*)(item))
 Runs ruSetFirstSet with a ptr cast. More...
 
#define ruSetNext(rs, item)   ruSetNextSet(rs, (ptr*)(item))
 Runs ruSetNextSet with a ptr cast. More...
 

Typedefs

typedef void * ruSet
 An opaque type representing a set object. More...
 

Functions

RUAPI ruSet ruSetNew (ruType keyType)
 Creates a new ruSet based on the given specifications. More...
 
RUAPI ruSet ruSetFree (ruSet rs)
 Frees the given set and its members. More...
 
RUAPI int32_t ruSetPutItem (ruSet rs, ptr item)
 Insert an item into the set. More...
 
RUAPI int32_t ruSetRemoveItem (ruMap rs, ptr item)
 Removes an entry from the map. More...
 
RUAPI bool ruSetHasItem (ruSet rs, trans_ptr item, int32_t *code)
 Tests whether set contains given item. More...
 
RUAPI int32_t ruSetFirstSet (ruSet rs, ptr *item)
 Initializes a set iterator and populates given parameter with the first item to serve as a for loop initializer. More...
 
RUAPI int32_t ruSetNextSet (ruSet rs, ptr *item)
 Retrieves the next item from the set. More...
 
RUAPI int32_t ruSetItemList (ruSet rs, ruList *items)
 Return an item list of the given set. More...
 
RUAPI int32_t ruSetRemoveAll (ruSet rs)
 Removes all items from the set. More...
 
RUAPI uint32_t ruSetSize (ruSet rs, int32_t *code)
 Returns the size of the set. More...
 

Detailed Description

This section contains a hash set implementation.

Macro Definition Documentation

◆ ruSetFirst

#define ruSetFirst (   rs,
  item 
)    ruSetFirstSet(rs, (ptr*)(item))

Runs ruSetFirstSet with a ptr cast.

Example:

int ret;
ptr item = NULL; // set values must be pointer sized
for (ret = ruSetFirst(set, &item); ret == RUE_OK;
ret = ruSetNext(set, &item)) {
// work with item
}
#define ruSetNext(rs, item)
Runs ruSetNextSet with a ptr cast.
Definition: map.h:375
#define ruSetFirst(rs, item)
Runs ruSetFirstSet with a ptr cast.
Definition: map.h:356
void * ptr
A generic pointer.
Definition: regify-util.h:304
#define RUE_OK
Definition: errors.h:66
Parameters
rsThe set to iterate over.
itemWhere to store the current item.
Returns
RUE_OK on success RUE_FILE_NOT_FOUND at the end of the set RUE_USER_ABORT when a threaded map has quit else a regify error code.

◆ ruSetHas

#define ruSetHas (   rs,
  item,
  code 
)    ruSetHasItem(rs, (trans_ptr)(item), code)

Runs ruSetHasItem with a ptr casted item.

Parameters
rsThe set to check.
itemThe item to be searched.
code(Optional) Stores RUE_OK on success RUE_USER_ABORT when a threaded set has quit else a regify error code.
Returns
true if item exists or false on error or if not.

◆ ruSetNext

#define ruSetNext (   rs,
  item 
)    ruSetNextSet(rs, (ptr*)(item))

Runs ruSetNextSet with a ptr cast.

◆ ruSetPut

#define ruSetPut (   rs,
  item 
)    ruSetPutItem(rs, (ptr)(item))

Runs ruSetPutItem with a ptr cast.

Parameters
rsSet to insert key into.
itemThe item to insert.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetRemove

#define ruSetRemove (   rs,
  item 
)    ruSetRemoveItem(rs, (ptr)(item))

Runs ruSetRemoveItem with a ptr cast.

Parameters
rsThe set to remove the entry from.
itemThe item to be removed.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded set has quit else a regify error code.

Typedef Documentation

◆ ruSet

typedef void* ruSet

An opaque type representing a set object.

Function Documentation

◆ ruSetFirstSet()

RUAPI int32_t ruSetFirstSet ( ruSet  rs,
ptr item 
)

Initializes a set iterator and populates given parameter with the first item to serve as a for loop initializer.

Parameters
rsThe set to iterate over.
itemWhere to store the current item.
Returns
RUE_OK on success RUE_FILE_NOT_FOUND at the end of the set RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetFree()

RUAPI ruSet ruSetFree ( ruSet  rs)

Frees the given set and its members.

Parameters
rsSet to free
Returns
NULL

◆ ruSetHasItem()

RUAPI bool ruSetHasItem ( ruSet  rs,
trans_ptr  item,
int32_t *  code 
)

Tests whether set contains given item.

Parameters
rsThe map to check.
itemThe item to be searched.
code(Optional) Stores RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code.
Returns
true if item exists or false on error or if not.

◆ ruSetItemList()

RUAPI int32_t ruSetItemList ( ruSet  rs,
ruList items 
)

Return an item list of the given set.

Parameters
rsThe set to get the item list from.
itemsWhere to store the resulting list.
Returns
RUE_OK on success, RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetNew()

RUAPI ruSet ruSetNew ( ruType  keyType)

Creates a new ruSet based on the given specifications.

Parameters
keyTypeA key specification. May be free after this call.
Returns
Newly create map. Caller m ust free with ruSetFree.

◆ ruSetNextSet()

RUAPI int32_t ruSetNextSet ( ruSet  rs,
ptr item 
)

Retrieves the next item from the set.

Parameters
rsThe set to retrieve the item from.
itemWhere to store the current item.
Returns
RUE_OK on success, RUE_FILE_NOT_FOUND at the end of the set RUE_INVALID_STATE if ruSetFirstSet hasn't been called or been invalidated. RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetPutItem()

RUAPI int32_t ruSetPutItem ( ruSet  rs,
ptr  item 
)

Insert an item into the set.

Parameters
rsSet to insert item into.
itemThe item to insert.
Returns
RUE_OK on success, RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetRemoveAll()

RUAPI int32_t ruSetRemoveAll ( ruSet  rs)

Removes all items from the set.

Parameters
rsThe set to remove the items from.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetRemoveItem()

RUAPI int32_t ruSetRemoveItem ( ruMap  rs,
ptr  item 
)

Removes an entry from the map.

Parameters
rsThe set to remove the item from.
itemThe item to be removed.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded set has quit else a regify error code.

◆ ruSetSize()

RUAPI uint32_t ruSetSize ( ruSet  rs,
int32_t *  code 
)

Returns the size of the set.

Parameters
rsSet to return the size of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Size of the set or 0 on error.