Go to the source code of this file.
Classes | |
struct | Segment_s |
struct | Seglist_s |
Defines | |
#define | SEGLIST_OBJS_PER_SEG 8 |
Typedefs | |
typedef struct Segment_s | Segment_t |
typedef struct Segment_s * | pSegment_t |
typedef struct Seglist_s | Seglist_t |
typedef struct Seglist_s * | pSeglist_t |
Functions | |
PmReturn_t | seglist_appendItem (pSeglist_t pseglist, pPmObj_t pobj) |
PmReturn_t | seglist_clear (pSeglist_t pseglist) |
PmReturn_t | seglist_findEqual (pSeglist_t pseglist, pPmObj_t pobj, int16_t *r_index) |
PmReturn_t | seglist_getItem (pSeglist_t pseglist, int16_t index, pPmObj_t *r_pobj) |
PmReturn_t | seglist_new (pSeglist_t *r_pseglist) |
PmReturn_t | seglist_insertItem (pSeglist_t pseglist, pPmObj_t pobj, int16_t index) |
PmReturn_t | seglist_setItem (pSeglist_t pseglist, pPmObj_t pobj, int16_t index) |
PmReturn_t | seglist_removeItem (pSeglist_t pseglist, uint16_t index) |
A seglist is a linked list of segments. A segment is an array of ptrs to objects (with a pointer to the next segment). Seglists are used to implement Lists and Dicts.
This implementation of Seglist is straight. That is, the next pointer in the final segment contains C_NULL.
This implementation of Seglist is dense. That is, there are no gaps in a segment. All entries point to an object, except entries that are beyond the index of the last item.
#define SEGLIST_OBJS_PER_SEG 8 |
Defines the length of the object array in a segment
PmReturn_t seglist_appendItem | ( | pSeglist_t | pseglist, | |
pPmObj_t | pobj | |||
) |
Puts the new object at the end of the list. This is intended for the List type where the List index matches the order of the Seglist index. Make room if necessary by adding new segments.
pseglist | Ptr to seglist to scan | |
indx | Index of object to obtain |
PmReturn_t seglist_clear | ( | pSeglist_t | pseglist | ) |
Clears the the seglist by unlinking the root segment.
pseglist | Ptr to seglist to empty |
PmReturn_t seglist_findEqual | ( | pSeglist_t | pseglist, | |
pPmObj_t | pobj, | |||
int16_t * | r_index | |||
) |
Finds the first obj equal to pobj in the seglist. Starts searching the list at the given segnum and indx.
pseglist | The seglist to search | |
pobj | The object to match | |
r_index | Return arg; the index of where to start the search. If a match is found, return the index by reference. If no match is found, this value is undefined. |
PmReturn_t seglist_getItem | ( | pSeglist_t | pseglist, | |
int16_t | index, | |||
pPmObj_t * | r_pobj | |||
) |
Gets the item in the seglist at the given coordinates. The segment number and the index within the segment are the coordinates of the object to get.
pseglist | Ptr to seglist to scan | |
index | Index of item to get | |
r_pobj | Return arg; Ptr to object at the index |
PmReturn_t seglist_insertItem | ( | pSeglist_t | pseglist, | |
pPmObj_t | pobj, | |||
int16_t | index | |||
) |
Puts the item in the next available slot in the first available segment. This is intended for the Dict type where the Seglist index is insignificant. Pushing an object assures it will be found early during a call to seglist_findEqual().
pseglist | Ptr to seglist in which object is placed. | |
pobj | Ptr to object which is inserted. | |
index | Index into seglist before which item is inserted |
PmReturn_t seglist_new | ( | pSeglist_t * | r_pseglist | ) |
Allocates a new empty seglist
r_pseglist | return; Address of ptr to new seglist |
PmReturn_t seglist_removeItem | ( | pSeglist_t | pseglist, | |
uint16_t | index | |||
) |
Removes the item at the given index.
pseglist | Ptr to seglist in which object is removed. | |
index | Index into seglist of where to put object. |
PmReturn_t seglist_setItem | ( | pSeglist_t | pseglist, | |
pPmObj_t | pobj, | |||
int16_t | index | |||
) |
Puts the item in the designated slot and segment. This is intended to be used after seglist_findEqual() returns the proper indeces.
pseglist | Ptr to seglist in which object is placed. | |
pobj | Ptr to object which is set. | |
index | Index into seglist of where to put object. |