ae2f::Core
Loading...
Searching...
No Matches
Arr.h File Reference
#include "Alloc.h"
#include "Arr/Err.h"

Go to the source code of this file.

Macros

#define ae2f_ds_Arr_NOT_FOUND   ae2f_static_cast(ae2f_errint_t, 0b1100000)
 
#define ae2f_ds_Arr_EQUAL   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, 0)
 they are same
 
#define ae2f_ds_Arr_RIGHT_UNIT   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, 1)
 right is lesser
 
#define ae2f_ds_Arr_LEFT_UNIT   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, -1)
 left is lesser
 
#define ae2f_ds_Arr_BSearch(arr, wanted, fpElCmp, retidx, elw)
 Finds the element [wanted] via binary search.
 
#define ae2f_ds_Arr_QSort(arr, fpElCmp, elw)
 Order the arr via quick sort.
 

Typedefs

typedef int ae2f_ds_Arr_CmpRet_t
 A predefined returning data type for ae2f_ds_Arr_fpElCmp_t.
 
typedef ae2f_ds_Arr_CmpRet_t(* ae2f_ds_Arr_fpElCmp_t) (const void *l, const void *r)
 It is an api for following approximate pseudo code.
 

Functions

ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_BSearch_imp (const ae2f_struct ae2f_ds_cAlloc *arr, const void *wanted, const ae2f_ds_Arr_fpElCmp_t fpElCmp, size_t *out, size_t elsize)
 Finds the element [wanted] via binary search.
 
ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_QSort_imp (ae2f_struct ae2f_ds_cAlloc *arr, const ae2f_ds_Arr_fpElCmp_t fpElCmp, size_t elsize)
 Order the arr via quick sort.
 

Macro Definition Documentation

◆ ae2f_ds_Arr_BSearch

#define ae2f_ds_Arr_BSearch ( arr,
wanted,
fpElCmp,
retidx,
elw )
Value:
ae2f_ds_Arr_CmpRet_t(* ae2f_ds_Arr_fpElCmp_t)(const void *l, const void *r)
It is an api for following approximate pseudo code.
Definition Arr.h:19
ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_BSearch_imp(const ae2f_struct ae2f_ds_cAlloc *arr, const void *wanted, const ae2f_ds_Arr_fpElCmp_t fpElCmp, size_t *out, size_t elsize)
Finds the element [wanted] via binary search.
#define ae2f_reinterpret_cast(t, v)
Definition Cast.h:57

Finds the element [wanted] via binary search.

Parameters
arrArray to see. It must be sorted.
wantedThe element which is wanted
fpElCmpComparing function. comparing will be proceed as
fpElCmp(element, wanted);
retidxBuffer where the Index may be stored
elwSuggested each element's size.
Returns
ae2f_errGlob_OK
ae2f_ds_Arr_NOT_FOUND
Exceptions

ae2f_errGlob_PTR_IS_NULL
ae2f_errGlob_IMP_NOT_FOUND
ae2f_errGlob_ALLOC_FAILED
ae2f_errGlob_WRONG_OPERATION

See also
ae2f_ds_Alloc_cRef_getSize
ae2f_ds_Alloc_cRef_Read
ae2f_ds_Arr_BSearch_imp

◆ ae2f_ds_Arr_EQUAL

#define ae2f_ds_Arr_EQUAL   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, 0)

they are same

◆ ae2f_ds_Arr_LEFT_UNIT

#define ae2f_ds_Arr_LEFT_UNIT   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, -1)

left is lesser

◆ ae2f_ds_Arr_NOT_FOUND

#define ae2f_ds_Arr_NOT_FOUND   ae2f_static_cast(ae2f_errint_t, 0b1100000)

◆ ae2f_ds_Arr_QSort

#define ae2f_ds_Arr_QSort ( arr,
fpElCmp,
elw )
Value:
ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_QSort_imp(ae2f_struct ae2f_ds_cAlloc *arr, const ae2f_ds_Arr_fpElCmp_t fpElCmp, size_t elsize)
Order the arr via quick sort.

Order the arr via quick sort.

Parameters
arrAn array to sort
fpElCmpcomparing will be proceed as
fpElCmp(element, wanted);
elwSuggested each element's size.
Returns
ae2f_errGlob_OK
Exceptions

ae2f_errGlob_ALLOC_FAILED
ae2f_errGlob_IMP_NOT_FOUND

See also
ae2f_ds_Alloc_cRef_getSize
ae2f_ds_Alloc_cRef_Read
ae2f_ds_Alloc_cRef_Write
ae2f_ds_Arr_QSort_imp

◆ ae2f_ds_Arr_RIGHT_UNIT

#define ae2f_ds_Arr_RIGHT_UNIT   ae2f_static_cast(ae2f_ds_Arr_CmpRet_t, 1)

right is lesser

Typedef Documentation

◆ ae2f_ds_Arr_CmpRet_t

◆ ae2f_ds_Arr_fpElCmp_t

typedef ae2f_ds_Arr_CmpRet_t(* ae2f_ds_Arr_fpElCmp_t) (const void *l, const void *r)

It is an api for following approximate pseudo code.

*l - *r
See also
ae2f_ds_Arr_CmpRet_t

Function Documentation

◆ ae2f_ds_Arr_BSearch_imp()

ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_BSearch_imp ( const ae2f_struct ae2f_ds_cAlloc * arr,
const void * wanted,
const ae2f_ds_Arr_fpElCmp_t fpElCmp,
size_t * out,
size_t elsize )

Finds the element [wanted] via binary search.

Parameters
arrArray to see. It must be sorted.
wantedThe element which is wanted
fpElCmpcomparing will be proceed as
fpElCmp(element, wanted);
outBuffer where the Index may be stored
elsizeSuggested each element's size.
Returns
ae2f_errGlob_OK
ae2f_ds_Arr_NOT_FOUND
Exceptions

ae2f_errGlob_PTR_IS_NULL
ae2f_errGlob_IMP_NOT_FOUND
ae2f_errGlob_ALLOC_FAILED

See also
ae2f_ds_Alloc_cRef_getSize
ae2f_ds_Alloc_cRef_Read

◆ ae2f_ds_Arr_QSort_imp()

ae2f_SHAREDCALL ae2f_extern ae2f_errint_t ae2f_ds_Arr_QSort_imp ( ae2f_struct ae2f_ds_cAlloc * arr,
const ae2f_ds_Arr_fpElCmp_t fpElCmp,
size_t elsize )

Order the arr via quick sort.

Parameters
arrAn array to sort
fpElCmpcomparing will be proceed as
fpElCmp(element, wanted);
elsizeSuggested each element's size.
Returns
ae2f_errGlob_OK
Exceptions

ae2f_errGlob_ALLOC_FAILED
ae2f_errGlob_IMP_NOT_FOUND

See also
ae2f_ds_Alloc_cRef_getSize
ae2f_ds_Alloc_cRef_Read
ae2f_ds_Alloc_cRef_Write