lists.h

来自「An complete pmp solution for mattel juic」· C头文件 代码 · 共 82 行

H
82
字号
#ifndef LISTS_H
#define LISTS_H

#include "stdint.h"
#include "malloc.h"
#include "qsort.h"
#include "string.h"

#define dIncludeStaticList
//#define dIncludeLinkedList
#define dIncludeStringList

//===================================================================
//                        Static list
//-------------------------------------------------------------------
#ifdef dIncludeStaticList
//i32 wCompare (void *a, void *b);
typedef struct xTStaticList
  {
  u32 *pxItems;
  u32 ulLength;
  u32 ulMaxLength;
  i16 (*wCompare)(void*, void*);
  } xTStaticList;

//-------------------------------------------------------------------
void wStaticListAdd (xTStaticList *pxList, void *pvValue);
void wStaticSortedListAdd (xTStaticList *pxList, void *pvValue);
void wStaticListRemove (xTStaticList *pxList, u32 ulPosition);
void wStaticSortedListRemove (xTStaticList *pxList, u32 ulPosition);
void wStaticListSort (xTStaticList *pxList);
#endif
//===================================================================
//                        Linked list
//-------------------------------------------------------------------
#ifdef dIncludeLinkedList
typedef struct xTListItem
  {
  void *pvValue;
  void *pvNext;
  void *pvPrevious;
  }xTListItem;

typedef struct xTLinkedList
  {
  u32 ulLength;
  xTListItem *pxListStart;
  xTListItem *pxListEnd;
  }xTLinkedList;

void wListAdd (xTLinkedList *pxList, void *pvValue);
void wListRemove (xTLinkedList *pxList, xTListItem *xItem);
#endif
//===================================================================
//                          String List
//-------------------------------------------------------------------
#ifdef dIncludeStringList
#ifndef dIncludeStaticList
#define dIncludeStaticList
#endif
//#define wCompare(a, b) srtcmp((char*)a, (char*)b)
//-------------------------------------------------------------------
typedef struct xTStringList
  {
  u32 *pxItems;
  u32 ulLength;
  u32 ulMaxLength;
  i16 (*wCompare)(void*, void*);
  }xTStringList;

void wStringListAdd (xTStringList *pxList, char *pvValue);
void wStringSortedListAdd (xTStringList *pxList, char *pvValue);
void wStringListRemove (xTStringList *pxList, u32 ulPosition);
void wStringSortedListRemove (xTStringList *pxList, u32 ulPosition);
void wStringListSort (xTStringList *pxList);
void wStringListClear(xTStringList *pxList);
void wStringListReadFromBuffer (xTStringList *pxList, u32 ulBufferLength, u08 *sBuffer);

#endif
//-------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?