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.

void cowl_table_release(CowlTable *table)

Releases the specified hash table.

Parameters

table – The hash table.

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.

bool cowl_table_equals(CowlTable *lhs, CowlTable *rhs)

Equality function.

Parameters
  • lhs – LHS of the equality relation.

  • rhs – RHS of the equality relation.

Returns

True if the equality relation holds, false otherwise.

ulib_uint cowl_table_hash(CowlTable *table)

Hash function.

Parameters

table – The hash table.

Returns

The hash value.

bool cowl_table_iterate_primitives(CowlTable *table, CowlPrimitiveFlags flags, CowlIterator *iter)

Iterates over the primitives referenced by the specified hash table.

Parameters
  • table – The hash table.

  • flags – Iteration flags.

  • iter – The iterator.

Returns

True if the iteration was completed, false if it was stopped.

Public Static Functions

static inline CowlTable *cowl_table_retain(CowlTable *table)

Retains the specified hash table.

Parameters

table – The hash table.

Returns

Retained hash table.

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.