myMPD
Internal API documentation
Loading...
Searching...
No Matches
sds_array.h File Reference

Array functions for sds strings. More...

#include "dist/sds/sds.h"
#include <stdbool.h>
Include dependency graph for sds_array.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  t_sds_array

Enumerations

enum  { SDS_ARRAY_START_CAPACITY = 16 }

Functions

struct t_sds_arraysds_array_new (void)
void sds_array_init (struct t_sds_array *array)
void sds_array_clear (struct t_sds_array *array)
void sds_array_free (struct t_sds_array *array)
bool sds_array_push (struct t_sds_array *array, sds s)
bool sds_array_shuffle (struct t_sds_array *array)
bool sds_array_sort (struct t_sds_array *array, bool desc)

Detailed Description

Array functions for sds strings.

Function Documentation

◆ sds_array_clear()

void sds_array_clear ( struct t_sds_array * array)

Clears the sds array, freeing all sds strings

Parameters
arrayPointer to the sds array to clear

◆ sds_array_free()

void sds_array_free ( struct t_sds_array * array)

Frees the sds array and all its contents

Parameters
arrayPointer to the sds array to free

◆ sds_array_init()

void sds_array_init ( struct t_sds_array * array)

Initializes an existing sds array

Parameters
arrayPointer to the sds array to initialize

◆ sds_array_new()

struct t_sds_array * sds_array_new ( void )

Creates and initializes a new sds array

Returns
struct t_sds_array*

◆ sds_array_push()

bool sds_array_push ( struct t_sds_array * array,
sds s )

Pushes the sds string to the array

Parameters
arrayPointer to the sds array
sPointer of sds string to push (this function does not copy it)
Returns
bool true on success, false on failure

◆ sds_array_shuffle()

bool sds_array_shuffle ( struct t_sds_array * array)

Shuffles the sds array using the Fisher-Yates algorithm

Parameters
arrayPointer to the sds array
Returns
bool true on success, false on failure

◆ sds_array_sort()

bool sds_array_sort ( struct t_sds_array * array,
bool desc )

Sorts the sds array utf8 aware and case insensitive using qsort

Parameters
arrayPointer to the sds array
descIf true, sorts in descending order; otherwise, sorts in ascending order
Returns
bool true on success, false on failure