Design Pattern Examples
Overview of object-oriented design patterns
uintarray.c File Reference

Implementation of the supporting functions for the UIntArray structure that represents an array of 32-bit unsigned integers. More...

#include <stdlib.h>
#include <memory.h>
#include "uintarray.h"
Include dependency graph for uintarray.c:

Go to the source code of this file.

Functions

void UIntArray_Initialize (UIntArray *array)
 Initialize the given UIntArray object.
 
void UIntArray_Clear (UIntArray *array)
 Clear the given UIntArray object so it can be reused again. Releases the list of integers.
 
bool UIntArray_AddInt (UIntArray *array, uint32_t value)
 Add an unsigned 32-bit integer to the given UIntArray object.
 
void UIntArray_RemoveInt (UIntArray *array, int removeIndex)
 Remove the unsigned 32-bit integer from the given UIntArray object at the given index. All subsequent integers are moved up one. Does nothing if the index is not valid.
 
int UIntArray_Find (UIntArray *array, uint32_t value)
 Search the given UIntArray object for the specified value and return the index of that found value.
 
bool UIntArray_Copy (UIntArray *sourceArray, UIntArray *destinationArray)
 Copy the source UIntArray to the destination UIntArray. The destination UIntArray is erased before getting a copy of the contents of the source.
 

Detailed Description

Implementation of the supporting functions for the UIntArray structure that represents an array of 32-bit unsigned integers.

Definition in file uintarray.c.

Function Documentation

◆ UIntArray_AddInt()

bool UIntArray_AddInt ( UIntArray array,
uint32_t  value 
)

Add an unsigned 32-bit integer to the given UIntArray object.

Parameters
arrayThe UIntArray object to update.
valueThe value to add to the UIntArray object.
Returns
Returns true if the value was added to the array; otherwise, returns false, indicating an out of memory condition (or a NULL argument).

Definition at line 38 of file uintarray.c.

References UIntArray::allocatedLength, UIntArray::data, and UIntArray::length.

Referenced by DeviceChain_GetIdCodesForVisibleNodes(), and HandlerChain_AddWindow().

◆ UIntArray_Clear()

void UIntArray_Clear ( UIntArray array)

Clear the given UIntArray object so it can be reused again. Releases the list of integers.

Parameters
arrayA UIntArray object to clear.

Definition at line 26 of file uintarray.c.

References UIntArray::data, and UIntArray_Initialize().

Referenced by Facade_Exercise(), HandlerChain_SendMessage(), HandlerChain_ToString(), and UIntArray_Copy().

◆ UIntArray_Copy()

bool UIntArray_Copy ( UIntArray sourceArray,
UIntArray destinationArray 
)

Copy the source UIntArray to the destination UIntArray. The destination UIntArray is erased before getting a copy of the contents of the source.

Parameters
sourceArrayThe UIntArray to copy from.
destinationArrayThe UIntArray to copy to.
Returns
Returns true if the array was successfully copied; otherwise, returns false, indicating an out of memory condition (or a NULL argument).

Definition at line 116 of file uintarray.c.

References UIntArray::allocatedLength, UIntArray::data, UIntArray::length, and UIntArray_Clear().

Referenced by HandlerChain_SendMessage(), and HandlerChain_ToString().

◆ UIntArray_Find()

int UIntArray_Find ( UIntArray array,
uint32_t  value 
)

Search the given UIntArray object for the specified value and return the index of that found value.

Parameters
arrayThe UIntArray object to search.
valueThe value to search for.
Returns
Returns an index into the list to the position of the value if found; otherwise, returns -1, indicating the value is not in the list.

Definition at line 93 of file uintarray.c.

References UIntArray::data, and UIntArray::length.

Referenced by HandlerChain_AddWindow(), and HandlerChain_RemoveWindow().

◆ UIntArray_Initialize()

void UIntArray_Initialize ( UIntArray array)

Initialize the given UIntArray object.

Parameters
arrayA UIntArray object to initialize.

Definition at line 13 of file uintarray.c.

References UIntArray::allocatedLength, UIntArray::data, and UIntArray::length.

Referenced by Facade_Exercise(), and UIntArray_Clear().

◆ UIntArray_RemoveInt()

void UIntArray_RemoveInt ( UIntArray array,
int  removeIndex 
)

Remove the unsigned 32-bit integer from the given UIntArray object at the given index. All subsequent integers are moved up one. Does nothing if the index is not valid.

Parameters
arrayThe UIntArray object to update.
removeIndexIndex of the value to remove.

Definition at line 75 of file uintarray.c.

References UIntArray::allocatedLength, UIntArray::data, and UIntArray::length.

Referenced by HandlerChain_RemoveWindow().