Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
array_utils.c File Reference

Utility functions for operating on Value arrays. More...

#include "value.h"
Include dependency graph for array_utils.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int array_contains (const Value *v, const Value *needle)
 Check if an array Value contains a given element.
int array_index_of (const Value *v, const Value *needle)
 Find the index of the first occurrence of an element in an array.
void array_clear (Value *v)
 Remove all elements from an array Value, freeing their contents.

Detailed Description

Utility functions for operating on Value arrays.

Definition in file array_utils.c.

Function Documentation

◆ array_clear()

void array_clear(Value *v)

Remove all elements from an array Value, freeing their contents.

Uses array_pop() repeatedly to clear the array.

Parameters
vArray Value to clear (in place). No-op if not an array.

Definition at line 68 of file array_utils.c.

Here is the call graph for this function:

◆ array_contains()

int array_contains(const Value *v,
const Value *needle )

Check if an array Value contains a given element.

Performs linear search using value_equals() on copied elements.

Parameters
vArray Value to inspect (may be NULL).
needleValue to search for.
Returns
1 if found, 0 otherwise or if v is not an array.

Definition at line 26 of file array_utils.c.

Here is the call graph for this function:

◆ array_index_of()

int array_index_of(const Value *v,
const Value *needle )

Find the index of the first occurrence of an element in an array.

Parameters
vArray Value to search (may be NULL).
needleValue to look for.
Returns
Zero-based index when found; -1 if not found or if v is not an array.

Definition at line 47 of file array_utils.c.

Here is the call graph for this function: