list.c File Reference
List Object Type.
More...
#include "pm.h"
Go to the source code of this file.
|
Defines |
#define | __FILE_ID__ 0x0B |
Functions |
PmReturn_t | list_append (pPmObj_t plist, pPmObj_t pobj) |
PmReturn_t | list_getItem (pPmObj_t plist, int16_t index, pPmObj_t *r_pobj) |
PmReturn_t | list_insert (pPmObj_t plist, int16_t index, pPmObj_t pobj) |
PmReturn_t | list_new (pPmObj_t *r_pobj) |
PmReturn_t | list_copy (pPmObj_t pobj, pPmObj_t *r_pobj) |
PmReturn_t | list_replicate (pPmObj_t psrclist, int16_t n, pPmObj_t *r_pnewlist) |
PmReturn_t | list_setItem (pPmObj_t plist, int16_t index, pPmObj_t pobj) |
PmReturn_t | list_remove (pPmObj_t plist, pPmObj_t item) |
PmReturn_t | list_index (pPmObj_t plist, pPmObj_t pitem, uint16_t *r_index) |
PmReturn_t | list_delItem (pPmObj_t plist, int16_t index) |
PmReturn_t | list_clear (pPmObj_t plist) |
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 406 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 170 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 324 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 68 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 282 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 99 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 150 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 251 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 177 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 220 of file list.c.