Dependencies:
mbed
« Back to documentation index
list.c File Reference
List Object Type.
More...
Go to the source code of this file.
Functions
PmReturn_t list_append (pPmObj_t plist, pPmObj_t pobj)
Appends the given obj to the end of the given list.
PmReturn_t list_getItem (pPmObj_t plist, int16_t index, pPmObj_t *r_pobj)
Gets the object in the list at the index.
PmReturn_t list_insert (pPmObj_t plist, int16_t index, pPmObj_t pobj)
Inserts the object into the list at the desired index.
PmReturn_t list_new (pPmObj_t *r_pobj)
Allocates a new List object.
PmReturn_t list_copy (pPmObj_t pobj, pPmObj_t *r_pobj)
Makes a copy of the given list.
PmReturn_t list_replicate (pPmObj_t psrclist, int16_t n, pPmObj_t *r_pnewlist)
Creates a new list with the contents of psrclist copied pint number of times.
PmReturn_t list_setItem (pPmObj_t plist, int16_t index, pPmObj_t pobj)
Sets the item in the list at the index.
PmReturn_t list_remove (pPmObj_t plist, pPmObj_t item)
Removes a given object from the list.
PmReturn_t list_index (pPmObj_t plist, pPmObj_t pitem, uint16_t *r_index)
Finds the first index of the item that matches pitem.
PmReturn_t list_delItem (pPmObj_t plist, int16_t index)
Removes the item at the given index.
PmReturn_t list_print (pPmObj_t plist)
Prints out a list.
PmReturn_t list_clear (pPmObj_t plist)
Removes all items from the list and zeroes the length.
Detailed Description
List Object Type.
List object type operations.
Definition in file list.c .
Function Documentation
Appends the given obj to the end of the given list.
Allocate the memory for the node. Do not copy obj, just reuse ptr.
Parameters:
plist Ptr to list
pobj Ptr to item to append
Returns: Return status
Definition at line 32 of file list.c .
Removes all items from the list and zeroes the length.
Parameters:
Returns: Return status
Definition at line 364 of file list.c .
Makes a copy of the given list.
Allocate the necessary memory for root and nodes. Duplicate ptrs to objs.
Parameters:
pobj Ptr to source list
r_pobj Return; Addr of ptr to return obj
Returns: Return status
Definition at line 151 of file list.c .
Removes the item at the given index.
Raises a TypeError if the first argument is not a list. Raises an IndexError if the index is out of bounds.
Parameters:
plist Ptr to list obj
index Index of item to remove
Returns: Return status
Definition at line 289 of file list.c .
Gets the object in the list at the index.
Parameters:
plist Ptr to list obj
index Index into list
r_pobj Return by reference; ptr to item
Returns: Return status
Definition at line 58 of file list.c .
Finds the first index of the item that matches pitem.
Returns an ValueError Exception if the item is not found.
Parameters:
plist Ptr to list obj
pitem Ptr to object to be removed
r_index Return by reference; ptr to index (C uint16)
Returns: Return status
Definition at line 254 of file list.c .
Inserts the object into the list at the desired index.
Parameters:
plist Ptr to list obj
pobj Ptr to obj to insert
index Index of where to insert obj
Returns: Return status
Definition at line 89 of file list.c .
Allocates a new List object.
If there is not enough memory to allocate the List, the return status will indicate an OutOfMemoryError that must be passed up to the interpreter. Otherwise, a ptr to the list is returned by reference and the return status is OK.
Parameters:
r_pobj Return; addr of ptr to obj
Returns: Return status
Definition at line 130 of file list.c .
Prints out a list.
Uses obj_print() to print elements.
Parameters:
Returns: Return status
Definition at line 322 of file list.c .
Removes a given object from the list.
Parameters:
plist Ptr to list obj
item Ptr to object to be removed
Returns: Return status
Definition at line 229 of file list.c .
Creates a new list with the contents of psrclist copied pint number of times.
This implements the python code "[0,...] * N" where the list can be any list and N is an integer.
Parameters:
psrclist The source list to replicate
n The integer number of times to replicate it
r_pnewlist Return; new list with its contents set.
Returns: Return status
Definition at line 158 of file list.c .
Sets the item in the list at the index.
Parameters:
plist Ptr to list
index Index into list
pobj Ptr to obj to put into list
Returns: Return status
Definition at line 198 of file list.c .