BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

Array helper.

Functions

void pj_array_insert (void *array, unsigned elem_size, unsigned count, unsigned pos, const void *value)
 
void pj_array_erase (void *array, unsigned elem_size, unsigned count, unsigned pos)
 
pj_status_t pj_array_find (const void *array, unsigned elem_size, unsigned count, pj_status_t(*matching)(const void *value), void **result)
 

Detailed Description

This module provides helper to manipulate array of elements of any size. It provides most used array operations such as insert, erase, and search.

Function Documentation

◆ pj_array_erase()

void pj_array_erase ( void *  array,
unsigned  elem_size,
unsigned  count,
unsigned  pos 
)

Erase a value from the array at given position, and rearrange the remaining elements post the erased element.

Parameters
arraythe array.
elem_sizethe size of the individual element.
countthe current number of elements in the array.
posthe index/position to delete.

◆ pj_array_find()

pj_status_t pj_array_find ( const void *  array,
unsigned  elem_size,
unsigned  count,
pj_status_t(*)(const void *value)  matching,
void **  result 
)

Search the first value in the array according to matching function.

Parameters
arraythe array.
elem_sizethe individual size of the element.
countthe number of elements.
matchingthe matching function, which MUST return PJ_SUCCESS if the specified element match.
resultthe pointer to the value found.
Returns
PJ_SUCCESS if value is found, otherwise the error code.

◆ pj_array_insert()

void pj_array_insert ( void *  array,
unsigned  elem_size,
unsigned  count,
unsigned  pos,
const void *  value 
)

Insert value to the array at the given position, and rearrange the remaining nodes after the position.

Parameters
arraythe array.
elem_sizethe size of the individual element.
countthe CURRENT number of elements in the array.
posthe position where the new element is put.
valuethe value to copy to the new element.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.