Collections

Vector

typedef CowlAny *CowlObjectPtr

Pointer to any CowlObject.

typedef UVec_CowlObjectPtr UVec_CowlObjectPtr

UVec(T) of CowlObject * elements.

struct CowlVector

Vector of CowlObject elements.

Pseudo-extends: CowlObject

CowlVector *cowl_vector(UVec_CowlObjectPtr *vec)

Returns a vector.

Note

You must not use the raw vector after passing it to this function.

Note

Elements in the raw vector are retained by this constructor.

Note

You must release the returned object via cowl_release().

Parameters:
  • vec – Underlying raw vector.

Returns:

Vector, or NULL on error.

CowlVector *cowl_vector_empty(void)

Returns a vector with no elements.

Note

You must release the returned object via cowl_release().

Returns:

Vector, or NULL on error.

UVec_CowlObjectPtr const *cowl_vector_get_data(CowlVector *vec)

Returns the underlying raw vector.

Parameters:
  • vec – The vector.

Returns:

Underlying raw vector.

ulib_uint cowl_vector_count(CowlVector *vec)

Returns the number of elements in the vector.

Parameters:
  • vec – The vector.

Returns:

Number of elements in the vector.

CowlAny *cowl_vector_get_item(CowlVector *vec, ulib_uint idx)

Returns the element at the specified index.

Parameters:
  • vec – The vector.

  • idx – The index.

Returns:

The element at the specified index.

bool cowl_vector_contains(CowlVector *vec, CowlAny *object)

Checks whether the vector contains the specified element.

Parameters:
  • vec – The vector.

  • object – The object.

Returns:

True if the vector contains the specified element, false otherwise.

cowl_vector_foreach(vec, obj)

Iterates over the vector, executing the specified code block for each element.

Parameters:
  • vecCowlVector * The vector.

  • objsymbol Name of the variable holding the current item and its index.

Hash table

typedef UHash_CowlObjectTable UHash_CowlObjectTable

UHash(T) of CowlObject * elements.

struct CowlTable

Hash table of CowlObject elements.

Pseudo-extends: CowlObject

CowlTable *cowl_table(UHash_CowlObjectTable *table)

Returns an hash table.

Note

You must not use the raw hash table after passing it to this function.

Note

Keys and values in the raw table are retained by this constructor.

Note

You must release the returned object via cowl_release().

Parameters:
  • table – Underlying raw hash table.

Returns:

Hash table, or NULL on error.

CowlTable *cowl_table_empty(void)

Returns an hash table with no elements.

Returns:

Hash table, or NULL on error.

UHash_CowlObjectTable const *cowl_table_get_data(CowlTable *table)

Returns the underlying raw hash table.

Parameters:
  • table – The hash table.

Returns:

Underlying raw hash table.

ulib_uint cowl_table_count(CowlTable *table)

Returns the number of elements in the hash table.

Parameters:
  • table – The hash table.

Returns:

Number of elements in The hash table.

CowlAny *cowl_table_get_value(CowlTable *table, CowlAny *key)

Returns the value associated with the specified key.

Parameters:
  • table – The hash table.

  • key – The key.

Returns:

Value associated with the key, or NULL if the key is not present.

CowlAny *cowl_table_get_any(CowlTable *table)

Returns one of the keys in the hash table.

Parameters:
  • table – The hash table.

Returns:

One of the keys in the hash table.

bool cowl_table_contains(CowlTable *table, CowlAny *key)

Checks whether the hash table contains the specified key.

Parameters:
  • table – The hash table.

  • key – The key.

Returns:

True if the object is contained in the hash table, false otherwise.

cowl_table_foreach(table, obj)

Iterates over the entries in the hash table.

Parameters:
  • tableCowlTable * The hash table.

  • objsymbol Name of the variable holding the current index, key and value.