regify utility  2.0.0-0
List Collection

This section contains a list implementation. More...

Modules

 Object List API
 This API is useful for object value types including strings.
 
 Typed List API
 This API is useful for scalar types such as int, long or bool.
 

Macros

#define ruListAppend(rl, data)   ruListAppendPtr(rl, (perm_ptr)(data))
 Calls ruListAppendPtr but handles the void* cast. More...
 
#define ruListPush(rl, data)   ruListAppendPtr(rl, (perm_ptr)(data))
 Stack usage synonym for ruListAppend. More...
 
#define ruListIter(rl)   ruListHead(rl, NULL)
 Returns the first element in the given list to iterate over. More...
 

Typedefs

typedef void * ruList
 Opaque pointer to list object. See List Collection. More...
 
typedef void * ruListElmt
 Opaque pointer to list element object. See List Collection. More...
 
typedef void * ruIterator
 Opaque pointer to list iterator object. See List Collection. More...
 

Functions

RUAPI ruList ruListNew (ruType valueType)
 Creates a new list object. To be freed with ruListFree. More...
 
RUAPI ruList ruListFree (ruList rl)
 Frees the given list object. More...
 
RUAPI int32_t ruListClear (ruList rl)
 Clears the given list. More...
 
RUAPI int32_t ruListAppendPtr (ruList rl, perm_ptr data)
 Appends the given object to the list. More...
 
RUAPI int32_t ruListInsertIdx (ruList rl, int32_t index, perm_ptr data)
 Inserts given object at indexed position in list in given list element. More...
 
RUAPI int32_t ruListInsertBefore (ruList rl, ruListElmt rle, perm_ptr data)
 Inserts given object before given list element. More...
 
RUAPI int32_t ruListInsertAfter (ruList rl, ruListElmt rle, perm_ptr data)
 Inserts given object after given list element. More...
 
RUAPI uint32_t ruListSize (ruList rl, int32_t *code)
 Returns the number of elements in the list. More...
 
RUAPI alloc_chars ruListJoin (ruList rl, trans_chars delim, int32_t *code)
 Joins a list of char* item with given delim. More...
 
RUAPI int32_t ruListSort (ruList rl)
 Sorts the given list using the associated types comparator function. More...
 
RUAPI ruListElmt ruListHead (ruList rl, int32_t *code)
 Returns the first element in the given list. More...
 
RUAPI ruListElmt ruListTail (ruList rl, int32_t *code)
 Returns the last element in the given list. More...
 
RUAPI bool ruListElmtIsHead (ruListElmt re, int32_t *code)
 Indicates whether given element is the first in the given list. More...
 
RUAPI bool ruListElmtIsTail (ruListElmt re, int32_t *code)
 Indicates whether given element is the last in the given list. More...
 
RUAPI ruListElmt ruListNextElmt (ruListElmt re, int32_t *code)
 Return the next element following the given element from list. More...
 

Detailed Description

This section contains a list implementation.

The list has typed and non typed variants and can also be used as a queue. The list is made thread safe by a mutex that is locked during read and write operations.

Macro Definition Documentation

◆ ruListAppend

#define ruListAppend (   rl,
  data 
)    ruListAppendPtr(rl, (perm_ptr)(data))

Calls ruListAppendPtr but handles the void* cast.

Parameters
rlList to append object to.
dataObject to append.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListIter

#define ruListIter (   rl)    ruListHead(rl, NULL)

Returns the first element in the given list to iterate over.

Parameters
rlList to return element of.
Returns
The first element of the list or NULL on failure.

◆ ruListPush

#define ruListPush (   rl,
  data 
)    ruListAppendPtr(rl, (perm_ptr)(data))

Stack usage synonym for ruListAppend.

Parameters
rlList to append object to.
dataObject to append.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

Typedef Documentation

◆ ruIterator

typedef void* ruIterator

Opaque pointer to list iterator object. See List Collection.

◆ ruList

typedef void* ruList

Opaque pointer to list object. See List Collection.

◆ ruListElmt

typedef void* ruListElmt

Opaque pointer to list element object. See List Collection.

Function Documentation

◆ ruListAppendPtr()

RUAPI int32_t ruListAppendPtr ( ruList  rl,
perm_ptr  data 
)

Appends the given object to the list.

Parameters
rlList to append object to.
dataObject to append.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListClear()

RUAPI int32_t ruListClear ( ruList  rl)

Clears the given list.

Parameters
rllist to clear
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListElmtIsHead()

RUAPI bool ruListElmtIsHead ( ruListElmt  re,
int32_t *  code 
)

Indicates whether given element is the first in the given list.

Parameters
reList element in question
code(Optional) Stores RUE_OK on success or regify error code.
Returns
true if the element is the first in the list.

◆ ruListElmtIsTail()

RUAPI bool ruListElmtIsTail ( ruListElmt  re,
int32_t *  code 
)

Indicates whether given element is the last in the given list.

Parameters
reList element in question
code(Optional) Stores RUE_OK on success or regify error code.
Returns
true if the element is the last in the list.

◆ ruListFree()

RUAPI ruList ruListFree ( ruList  rl)

Frees the given list object.

Parameters
rllist to free.
Returns
NULL

◆ ruListHead()

RUAPI ruListElmt ruListHead ( ruList  rl,
int32_t *  code 
)

Returns the first element in the given list.

Parameters
rlList to return element of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
The first element of the list or NULL on failure.

◆ ruListInsertAfter()

RUAPI int32_t ruListInsertAfter ( ruList  rl,
ruListElmt  rle,
perm_ptr  data 
)

Inserts given object after given list element.

Parameters
rlList in which to insert object.
rleElement after which to insert object. NULL for first element.
dataObject to insert.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListInsertBefore()

RUAPI int32_t ruListInsertBefore ( ruList  rl,
ruListElmt  rle,
perm_ptr  data 
)

Inserts given object before given list element.

Parameters
rlList in which to insert object.
rleElement before which to insert object. NULL for first element.
dataObject to insert.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListInsertIdx()

RUAPI int32_t ruListInsertIdx ( ruList  rl,
int32_t  index,
perm_ptr  data 
)

Inserts given object at indexed position in list in given list element.

Parameters
rlList in which to insert object.
indexIndex at which to insert the object. 0(first)/-1(last) element. If index is > list size the item will be appended.
dataObject to insert.
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListJoin()

RUAPI alloc_chars ruListJoin ( ruList  rl,
trans_chars  delim,
int32_t *  code 
)

Joins a list of char* item with given delim.

This function should only be called with char* lists.

Parameters
rlList to join
delimDelimiter to join with or NULL for blank
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Joined string to be freed by the caller

◆ ruListNew()

RUAPI ruList ruListNew ( ruType  valueType)

Creates a new list object. To be freed with ruListFree.

Parameters
valueTypeA value specification. Will be freed by this call.
Returns
Guaranteed to return new list object, or process abort.

◆ ruListNextElmt()

RUAPI ruListElmt ruListNextElmt ( ruListElmt  re,
int32_t *  code 
)

Return the next element following the given element from list.

Parameters
reList element to return follower of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Next element or NULL if given element was the last or an error occured.

◆ ruListSize()

RUAPI uint32_t ruListSize ( ruList  rl,
int32_t *  code 
)

Returns the number of elements in the list.

Parameters
rlList to return size of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Number of elements in list or 0 on error.

◆ ruListSort()

RUAPI int32_t ruListSort ( ruList  rl)

Sorts the given list using the associated types comparator function.

Parameters
rlList to sort
Returns
RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListTail()

RUAPI ruListElmt ruListTail ( ruList  rl,
int32_t *  code 
)

Returns the last element in the given list.

Parameters
rlList to return element of.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
The last element of the list or NULL on failure.