Hash table

struct CowlTable : public CowlObject

Hash table of CowlObject elements.

Public Functions

CowlTable *cowl_table(UHash_CowlObjectTable *table)

Returns a retained hash table.

Note

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

Parameters

table – Underlying raw hash table.

Returns

Retained 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.

Public Static Functions

static inline 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.

static inline 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.

static inline 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.

static inline 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_empty()

Returns a retained hash table with no elements.

Returns

[CowlTable*] Retained hash table, or NULL on error.

cowl_table_foreach(table, obj)

Iterates over the entries in the hash table.

Parameters
  • table – [CowlTable *] The hash table.

  • obj – [symbol] Name of the variable holding the current index, key and value.