Files
tp/libs/SSystem/SComponent/c_list.cpp
T
Jasper St. Pierre 937da3c59b SComponent c_list / c_node (#5)
* SComponent c_list / c_node

* SComponent: c_tree

* SComponent: start c_phase

* SComponent: c_tag

* SComponent: c_counter

* f_pc_line / f_pc_line_tag

the beginnings of the framework process system

* f_pc_method_tag

* SComponent: c_node_iter / c_list_iter / c_tag_iter / c_tree_iter

* f_pc_draw_priority

* f_pc_method_iter

* f_pc_profile

Also add (untested) base header classes for f_pc_base

* f_pc_searcher

* f_pc_create_tag

* f_pc_creator

* f_pc_layer skeleton

* f_pc_method

* f_pc_line_iter

* f_pc_leaf somewhat

* f_pc_delete_tag

* f_pc_create_req

* Fix a few non-matchings

* c_phase: slight additional notes

* c_node: more matching

* fix build

* c_node: One more matching

* f_pc_line_iter: Matching

* f_pc_create_req: a bit more

* f_pc_load, f_pc_deletor partial

* f_pc_executor partial

* f: minor cleanups

* f_pc_executor

Co-authored-by: Pheenoh <pheenoh@gmail.com>
2020-11-30 17:26:55 -05:00

73 lines
1.6 KiB
C++

#include "global.h"
#include "SComponent/c_list.h"
extern "C" {
void cLs_Init(node_list_class *pList)
{
pList->mpHead = NULL;
pList->mpTail = NULL;
pList->mSize = 0;
}
int cLs_SingleCut(node_class *pNode)
{
node_list_class *pList = (node_list_class *) pNode->mpData;
if (pNode == pList->mpHead)
pList->mpHead = pNode->mpNextNode;
if (pNode == pList->mpTail)
pList->mpTail = pNode->mpPrevNode;
cNd_SingleCut(pNode);
cNd_ClearObject(pNode);
int newSize = pList->mSize - 1;
pList->mSize = newSize;
return newSize > 0;
}
int cLs_Addition(node_list_class *pList, node_class *pNode)
{
if (pList->mpTail == NULL) {
pList->mpHead = pNode;
} else {
cNd_Addition(pList->mpTail, pNode);
}
pList->mpTail = cNd_Last(pNode);
cNd_SetObject(pNode, pList);
pList->mSize = cNd_LengthOf(pList->mpHead);
return pList->mSize;
}
int cLs_Insert(node_list_class *pList, int idx, node_class *pNode)
{
node_class *pExisting = cNd_Order(pList->mpHead, idx);
if (pExisting == NULL) {
return cLs_Addition(pList, pNode);
} else {
cNd_SetObject(pNode, pList);
cNd_Insert(pExisting, pNode);
pList->mpHead = cNd_First(pNode);
pList->mSize = cNd_LengthOf(pList->mpHead);
return pList->mSize;
}
}
node_class * cLs_GetFirst(node_list_class *pList)
{
if (pList->mSize != 0) {
node_class *pHead = pList->mpHead;
cLs_SingleCut(pHead);
return pHead;
} else {
return NULL;
}
}
void cLs_Create(node_list_class *pList)
{
cLs_Init(pList);
}
};