MPLABĀ® Harmony Graphics Suite
Data Structures | Typedefs | Functions
legato_array.h File Reference

An array implementation for storing pointers. More...

#include "gfx/legato/common/legato_common.h"
Include dependency graph for legato_array.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  leArray
 This struct represents a array. More...
 

Typedefs

typedef struct leArray leArray
 This struct represents a array. More...
 

Functions

leResult leArray_Create (leArray *arr)
 Create a new array. More...
 
leResult leArray_Resize (leArray *arr, uint32_t sz)
 Resize array. More...
 
leResult leArray_PushFront (leArray *arr, void *val)
 Push value on front. More...
 
leResult leArray_PopFront (leArray *arr)
 Pop value from front. More...
 
leResult leArray_PushBack (leArray *arr, void *val)
 Push value on back. More...
 
leResult leArray_PopBack (leArray *arr)
 Pop value from back. More...
 
leResult leArray_InsertAt (leArray *arr, uint32_t idx, void *val)
 Insert value at index. More...
 
leResult leArray_RemoveAt (leArray *arr, uint32_t idx)
 Remove value at index. More...
 
leResult leArray_Remove (leArray *arr, void *val)
 Remove value. More...
 
void * leArray_Get (const leArray *arr, uint32_t idx)
 Get entry at index. More...
 
leResult leArray_Set (leArray *arr, uint32_t idx, void *val)
 Set value at index. More...
 
int32_t leArray_Find (const leArray *arr, void *val)
 Find a first index of value. More...
 
leResult leArray_Copy (leArray *src, leArray *dest)
 Copy array. More...
 
leResult leArray_Clear (leArray *arr)
 Clear array. More...
 

Detailed Description

An array implementation for storing pointers.

This is an array implementation that is used internally by the Legato user interface library.

Typedef Documentation

◆ leArray

typedef struct leArray leArray

This struct represents a array.

An array is used to hold values. It has a size and capacity.

Function Documentation

◆ leArray_Clear()

leResult leArray_Clear ( leArray *  arr)

Clear array.

Removes all values from arr. Array capacity remains the same.

leArray* arr;
Parameters
arris the array to modify.
Returns
LE_SUCCESS if cleared, otherwise LE_FAILURE.

◆ leArray_Copy()

leResult leArray_Copy ( leArray *  src,
leArray *  dest 
)

Copy array.

Copies the contents of src to the array pointed to by dest.

leArray* src;
leArray* dest;
leResult res = leArray_Copy(src, dest)
Parameters
srcis the source array.
destis the destination array.
Returns
LE_SUCCESS if copied, otherwise LE_FAILURE.

◆ leArray_Create()

leResult leArray_Create ( leArray *  arr)

Create a new array.

Creates a new array pointed to by arr.

leArray* arr;
Parameters
arris array to create.
Returns
LE_SUCCESS if created, otherwise LE_FAILURE.

◆ leArray_Find()

int32_t leArray_Find ( const leArray *  arr,
void *  val 
)

Find a first index of value.

Returns the first index of val in arr.

leArray* arr;
void* val;
int32_t index = leArray_Find(arr, val)
Parameters
arris the array to search.
valis the value to set at index.
Returns
the first index of the value or -1 if not found.

◆ leArray_Get()

void* leArray_Get ( const leArray *  arr,
uint32_t  idx 
)

Get entry at index.

Returns the pointer to the entry from arr at the specified idx.

leArray* arr;
uint32_t idx;
void* entry = leArray_Get(arr, idx)
Parameters
arris the array of entries.
idxis the index at which entry is located.
Returns
void* pointer to the entry at idx.
Here is the caller graph for this function:

◆ leArray_InsertAt()

leResult leArray_InsertAt ( leArray *  arr,
uint32_t  idx,
void *  val 
)

Insert value at index.

Inserts val into arr at the specified idx. All existing values from index are shifted right one place.

leArray* arr;
uint32_t idx;
void* val;
leResult res = leArray_InsertAt(arr idx, val)
Parameters
arris the array to modify.
idxis the location at which to insert value.
valis value to insert.
Returns
LE_SUCCESS if inserted, otherwise LE_FAILURE.

◆ leArray_PopBack()

leResult leArray_PopBack ( leArray *  arr)

Pop value from back.

Removes the last value from the back of arr.

leArray* arr;
Parameters
arris the array to modify.
Returns
LE_SUCCESS if popped, otherwise LE_FAILURE.

◆ leArray_PopFront()

leResult leArray_PopFront ( leArray *  arr)

Pop value from front.

Removes the first value from the front of arr. This function shuffles all other values forward one index.

Parameters
arris the array to modify.
Returns
LE_SUCCESS if removed, otherwise LE_FAILURE.

◆ leArray_PushBack()

leResult leArray_PushBack ( leArray *  arr,
void *  val 
)

Push value on back.

Pushes val onto the back of arr.

leArray* arr;
void* val;
leResult res = leArray_PushBack(arr, val)
Parameters
arris the array to modify.
valis the value to push.
Returns
LE_SUCCESS if pushed, otherwise LE_FAILURE.

◆ leArray_PushFront()

leResult leArray_PushFront ( leArray *  arr,
void *  val 
)

Push value on front.

Pushes val onto the front of arr. This function shuffles all other values backward one index.

leArray* arr;
void* val;
leResult res = leArray_PushFront(arr, val)
Parameters
arris the array to modify.
valis the value to push.
Returns
LE_SUCCESS if pushed, otherwise LE_FAILURE.

◆ leArray_Remove()

leResult leArray_Remove ( leArray *  arr,
void *  val 
)

Remove value.

Removes the first instance of val from arr. The function shuffles all values left to fill the gap.

leArray* arr;
void* val;
leResult res = leArray_Remove(leArray* arr, void* val)
Parameters
arris the array to modify.
valis the value removed.
Returns
LE_SUCCESS if removed, otherwise LE_FAILURE.

◆ leArray_RemoveAt()

leResult leArray_RemoveAt ( leArray *  arr,
uint32_t  idx 
)

Remove value at index.

Removes val from arr at the specified idx.

leArray* arr;
uint32_t idx;
leResult res = leArray_RemoveAt(arr idx)
Parameters
arris the array to modify.
idxis the location at which to insert value.
Returns
LE_SUCCESS if removed, otherwise LE_FAILURE.

◆ leArray_Resize()

leResult leArray_Resize ( leArray *  arr,
uint32_t  sz 
)

Resize array.

Expands (or shrinks) arr to the specified sz.

If the array shrinks, any nodes beyond the new capacity will be discarded.

leArray* arr;
uint32_t sz;
leResult res = leArray_Resize(arr, sz)
Parameters
arris the array to resize.
szis the new size.
Returns
LE_SUCCESS if resized, otherwise LE_FAILURE.

◆ leArray_Set()

leResult leArray_Set ( leArray *  arr,
uint32_t  idx,
void *  val 
)

Set value at index.

Sets val onto arr at the specified idx.

leList* arr;
uint32_t idx;
void* val;
leResult res = leArray_Set(arr, idx, val)
Parameters
arris the array to modify.
idxis the index where the value is set.
valis the value to set at index.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leArray_RemoveAt
leResult leArray_RemoveAt(leArray *arr, uint32_t idx)
Remove value at index.
Definition: legato_array.c:197
leList
This struct represents a list.
Definition: legato_list.h:91
leArray_Find
int32_t leArray_Find(const leArray *arr, void *val)
Find a first index of value.
Definition: legato_array.c:242
leArray_PushBack
leResult leArray_PushBack(leArray *arr, void *val)
Push value on back.
Definition: legato_array.c:147
leArray_PushFront
leResult leArray_PushFront(leArray *arr, void *val)
Push value on front.
Definition: legato_array.c:119
leArray_Set
leResult leArray_Set(leArray *arr, uint32_t idx, void *val)
Set value at index.
Definition: legato_array.c:232
leArray_Resize
leResult leArray_Resize(leArray *arr, uint32_t sz)
Resize array.
Definition: legato_array.c:85
leArray
This struct represents a array.
Definition: legato_array.h:61
leArray_Create
leResult leArray_Create(leArray *arr)
Create a new array.
Definition: legato_array.c:73
leArray_InsertAt
leResult leArray_InsertAt(leArray *arr, uint32_t idx, void *val)
Insert value at index.
Definition: legato_array.c:174
leArray_PopBack
leResult leArray_PopBack(leArray *arr)
Pop value from back.
Definition: legato_array.c:164
leArray_PopFront
leResult leArray_PopFront(leArray *arr)
Pop value from front.
Definition: legato_array.c:137
leArray_Clear
leResult leArray_Clear(leArray *arr)
Clear array.
Definition: legato_array.c:279
leArray_Get
void * leArray_Get(const leArray *arr, uint32_t idx)
Get entry at index.
Definition: legato_array.c:224
leArray_Copy
leResult leArray_Copy(leArray *src, leArray *dest)
Copy array.
Definition: legato_array.c:258
leArray_Remove
leResult leArray_Remove(leArray *arr, void *val)
Remove value.
Definition: legato_array.c:207