ubinos
Classes | Macros | Typedefs | Functions
edlist.h File Reference

ubiclib embedded double linked list API More...

#include <ubinos_config.h>
#include <ubinos/type.h>

Go to the source code of this file.

Classes

struct  _edlist_t
 
struct  _edlist_elmt_t
 

Macros

#define edlist_init(edlist)
 
#define edlist_link_init(link)
 
#define edlist_insertprev(elmttype, linkname, edlist, ref, elmt)
 
#define edlist_insertnext(elmttype, linkname, edlist, ref, elmt)
 
#define edlist_remove(elmttype, linkname, elmt)
 
#define edlist_setcur(elmttype, linkname, edlist, cur)   ((elmttype) _edlist_setcur(edlist, cur))
 
#define edlist_getcur(elmttype, linkname, edlist)   ((elmttype) _edlist_getcur(edlist))
 
#define edlist_getcurnext(elmttype, linkname, edlist)
 
#define edlist_head(elmttype, linkname, edlist)   ((elmttype) (edlist)->head)
 
#define edlist_tail(elmttype, linkname, edlist)   ((elmttype) (edlist)->tail)
 
#define edlist_next(elmttype, linkname, elmt)   ((elmt)->linkname.next)
 
#define edlist_prev(elmttype, linkname, elmt)   ((elmt)->linkname.prev)
 
#define edlist_list(elmttype, linkname, elmt)   ((elmt)->linkname.list)
 

Typedefs

typedef struct _edlist_t edlist_t
 
typedef edlist_tedlist_pt
 
typedef struct _edlist_elmt_t edlist_elmt_t
 
typedef edlist_elmt_tedlist_elmt_pt
 

Functions

void * _edlist_setcur (edlist_pt edlist, void *cur)
 
void * _edlist_getcur (edlist_pt edlist)
 

Detailed Description

ubiclib embedded double linked list API

ubiclib 내장형 더블 링크드 리스트 API를 정의합니다.

Macro Definition Documentation

◆ edlist_getcur

#define edlist_getcur (   elmttype,
  linkname,
  edlist 
)    ((elmttype) _edlist_getcur(edlist))

현재 엘리먼트를 돌려주는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터
Returns
현재 엘리먼트

NULL: 대상 리스트가 비어 있음

◆ edlist_getcurnext

#define edlist_getcurnext (   elmttype,
  linkname,
  edlist 
)
Value:
( (elmttype) \
((NULL == (edlist)->cur || NULL == ((elmttype) (edlist)->cur)->linkname.next) ? \
_edlist_setcur((edlist), (edlist)->head) : \
_edlist_setcur((edlist), ((elmttype) (edlist)->cur)->linkname.next) ) )

현재 엘리먼트 포인터(cur)를 그 다음 엘리먼트 포인터로 변경하고 변경된 현재 엘리먼트 포인터를 돌려주는 매크로,
현재 엘리먼트 포인터가 NULL이거나 마지막 엘리먼트를 가리키면 현재 엘리먼트 포인터를 첫번째 엘리먼트 포인터로 변경

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터
Returns
변경된 현재 엘리먼트 포인터

NULL: 대상 리스트가 비어 있음

◆ edlist_head

#define edlist_head (   elmttype,
  linkname,
  edlist 
)    ((elmttype) (edlist)->head)

첫 엘리먼트를 지정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터

◆ edlist_init

#define edlist_init (   edlist)
Value:
{ \
(edlist)->count = 0; \
(edlist)->head = NULL; \
(edlist)->tail = NULL; \
(edlist)->cur = NULL; \
(edlist)->data = NULL; \
}

내장형 더블 링크드 리스트를 초기화하는 매크로

Parameters
edlist대상 리스트 포인터

◆ edlist_insertnext

#define edlist_insertnext (   elmttype,
  linkname,
  edlist,
  ref,
  elmt 
)
Value:
{ \
(elmt)->linkname.prev = ((elmttype) ref); \
\
if (NULL == ((elmttype) ref)) { \
(elmt)->linkname.next = (edlist)->head; \
(edlist)->head = (elmt); \
} \
else { \
(elmt)->linkname.next = ((elmttype) ref)->linkname.next; \
((elmttype) ref)->linkname.next = (elmt); \
} \
\
if (NULL == (elmt)->linkname.next) { \
(edlist)->tail = (elmt); \
} \
else { \
(elmt)->linkname.next->linkname.prev = (elmt); \
} \
\
(edlist)->count++; \
\
(elmt)->linkname.list = (edlist); \
}

지정한 엘리먼트 다음에 엘리먼트를 추가하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터
ref이 포인터가 가리키는 엘리먼트 다음에 추가함,
NULL이면 맨 앞에 추가함
elmt추가할 엘리먼트

◆ edlist_insertprev

#define edlist_insertprev (   elmttype,
  linkname,
  edlist,
  ref,
  elmt 
)
Value:
{ \
(elmt)->linkname.next = ((elmttype) ref); \
\
if (NULL == ((elmttype) ref)) { \
(elmt)->linkname.prev = (edlist)->tail; \
(edlist)->tail = (elmt); \
} \
else { \
(elmt)->linkname.prev = ((elmttype) ref)->linkname.prev; \
((elmttype) ref)->linkname.prev = (elmt); \
} \
\
if (NULL == (elmt)->linkname.prev) { \
(edlist)->head = (elmt); \
} \
else { \
(elmt)->linkname.prev->linkname.next = (elmt); \
} \
\
(edlist)->count++; \
\
(elmt)->linkname.list = (edlist); \
}

지정한 엘리먼트 앞에 엘리먼트를 추가하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터
ref이 포인터가 가리키는 엘리먼트 앞에 추가함,
NULL이면 맨 뒤에 추가함
elmt추가할 엘리먼트

◆ edlist_link_init

#define edlist_link_init (   link)
Value:
{ \
(link)->prev = NULL; \
(link)->next = NULL; \
(link)->list = NULL; \
}

내장형 더블 링크드 리스트 링크를 초기화하는 매크로

Parameters
link대상 링크 포인터

◆ edlist_list

#define edlist_list (   elmttype,
  linkname,
  elmt 
)    ((elmt)->linkname.list)

지정한 엘리먼트가 소속된 내장형 더블 링크드 리스트를 지정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
elmt이 포인터가 가리키는 엘리먼트가 소속된 내장형 더블 링크드 리스트 포인터를 지정

◆ edlist_next

#define edlist_next (   elmttype,
  linkname,
  elmt 
)    ((elmt)->linkname.next)

지정한 엘리먼트 다음 엘리먼트를 지정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
elmt이 포인터가 가리키는 엘리먼트 다음 엘리먼트 포인터를 지정

◆ edlist_prev

#define edlist_prev (   elmttype,
  linkname,
  elmt 
)    ((elmt)->linkname.prev)

지정한 엘리먼트 이전 엘리먼트를 지정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
elmt이 포인터가 가리키는 엘리먼트 이전 엘리먼트 포인터를 지정

◆ edlist_remove

#define edlist_remove (   elmttype,
  linkname,
  elmt 
)
Value:
{ \
if (NULL != ((elmt)->linkname.list)) { \
if ((elmt) == ((elmt)->linkname.list)->cur) { \
((elmt)->linkname.list)->cur = (elmt)->linkname.prev; \
} \
\
if (NULL == (elmt)->linkname.prev) { \
((elmt)->linkname.list)->head = (elmt)->linkname.next; \
} \
else { \
(elmt)->linkname.prev->linkname.next = (elmt)->linkname.next; \
} \
\
if (NULL == (elmt)->linkname.next) { \
((elmt)->linkname.list)->tail = (elmt)->linkname.prev; \
} \
else { \
(elmt)->linkname.next->linkname.prev = (elmt)->linkname.prev; \
} \
\
((elmt)->linkname.list)->count--; \
\
(elmt)->linkname.prev = NULL; \
(elmt)->linkname.next = NULL; \
(elmt)->linkname.list = NULL; \
} \
}

엘리먼트를 소속된 리스트에서 제거하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
elmt제거할 엘리먼트

◆ edlist_setcur

#define edlist_setcur (   elmttype,
  linkname,
  edlist,
  cur 
)    ((elmttype) _edlist_setcur(edlist, cur))

현재 엘리먼트를 설정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터
cur현재 엘리먼트로 설정할 엘리먼트 포인터
Returns
현재 엘리먼트

NULL: 오류

◆ edlist_tail

#define edlist_tail (   elmttype,
  linkname,
  edlist 
)    ((elmttype) (edlist)->tail)

마지막 엘리먼트를 지정하는 매크로

Parameters
elmttype엘리먼트 포인터 형
linkname링크 이름
edlist대상 리스트 포인터

Typedef Documentation

◆ edlist_elmt_pt

내장형 더블 링크드 리스트 엘리먼트 포인터 형 정의 예

◆ edlist_elmt_t

typedef struct _edlist_elmt_t edlist_elmt_t

내장형 더블 링크드 리스트 엘리먼트 자료 구조 예

내장형 더블 링크드 리스트 엘리먼트 형 정의 예

◆ edlist_pt

typedef edlist_t* edlist_pt

내장형 더블 링크드 리스트 포인터 형 정의

◆ edlist_t

typedef struct _edlist_t edlist_t

내장형 더블 링크드 리스트 자료 구조

내장형 더블 링크드 리스트 형 정의

Function Documentation

◆ _edlist_getcur()

void* _edlist_getcur ( edlist_pt  edlist)

현재 엘리먼트를 돌려주는 함수

Parameters
edlist대상 리스트 포인터
Returns
현재 엘리먼트

NULL: 대상 리스트가 비어 있음

◆ _edlist_setcur()

void* _edlist_setcur ( edlist_pt  edlist,
void *  cur 
)

현재 엘리먼트를 설정하는 함수

Parameters
edlist대상 리스트 포인터
cur현재 엘리먼트로 설정할 엘리먼트 포인터
Returns
현재 엘리먼트

NULL: 오류
NULL
#define NULL
Definition: type.h:65
_edlist_setcur
void * _edlist_setcur(edlist_pt edlist, void *cur)