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

ubiclib double linked list API More...

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

Go to the source code of this file.

Classes

struct  _dlist_elmt_t
 
struct  _dlist_t
 

Macros

#define DLIST_ERR__NOTEXIST   -21
 
#define dlist_init(dlist)
 

Typedefs

typedef struct _dlist_elmt_t dlist_elmt_t
 
typedef dlist_elmt_tdlist_elmt_pt
 
typedef struct _dlist_t dlist_t
 
typedef dlist_tdlist_pt
 

Functions

dlist_elmt_pt dlist_elmt_create (void *data, void *data2)
 
int dlist_elmt_delete (dlist_elmt_pt elmt)
 
int dlist_create (dlist_pt *dlist_p)
 
int dlist_delete (dlist_pt *dlist_p)
 
int dlist_insertprev (dlist_pt dlist, dlist_elmt_pt ref, dlist_elmt_pt elmt)
 
int dlist_insertnext (dlist_pt dlist, dlist_elmt_pt ref, dlist_elmt_pt elmt)
 
int dlist_remove (dlist_elmt_pt elmt)
 
dlist_elmt_pt dlist_getcurnext (dlist_pt dlist)
 
int dlist_find (dlist_pt dlist, dlist_elmt_pt *elmt_p, void *data)
 
int dlist_findandremove (dlist_pt dlist, dlist_elmt_pt *elmt_p, void *data)
 

Detailed Description

ubiclib double linked list API

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

Macro Definition Documentation

◆ DLIST_ERR__NOTEXIST

#define DLIST_ERR__NOTEXIST   -21

오류: 해당 엘리먼트가 없음

◆ dlist_init

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

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

Parameters
dlist대상 더블 링크드 리스트 포인터

Typedef Documentation

◆ dlist_elmt_pt

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

◆ dlist_elmt_t

더블 링크드 리스트 엘리먼트 자료 구조

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

◆ dlist_pt

typedef dlist_t* dlist_pt

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

◆ dlist_t

typedef struct _dlist_t dlist_t

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

더블 링크드 리스트 형 정의

Function Documentation

◆ dlist_create()

int dlist_create ( dlist_pt dlist_p)

더블 링크드 리스트를 생성하는 함수

Parameters
dlist_p생성한 더블 링크드 리스트의 주소를 저장할 포인터의 주소
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ dlist_delete()

int dlist_delete ( dlist_pt dlist_p)

더블 링크드 리스트를 제거하는 함수

Parameters
dlist_p제거할 더블 링크드 리스트의 주소가 저장된 포인터의 주소
제거에 성공하면 *dlist_p는 NULL이 됨
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ dlist_elmt_create()

dlist_elmt_pt dlist_elmt_create ( void *  data,
void *  data2 
)

더블 링크드 리스트 엘리먼트를 생성하는 함수

Parameters
data엘리먼트의 데이터
data2엘리먼트의 데이터2
Returns
생성한 더블 링크드 리스트 엘리먼트 포인터

NULL: 오류

◆ dlist_elmt_delete()

int dlist_elmt_delete ( dlist_elmt_pt  elmt)

더블 링크드 리스트 엘리먼트를 제거하는 함수

Parameters
elmt대상 더블 링크드 리스트 엘리먼트 포인터
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ dlist_find()

int dlist_find ( dlist_pt  dlist,
dlist_elmt_pt elmt_p,
void *  data 
)

지정된 값을 가진 첫번째 엘리먼트를 찾는 함수

Parameters
dlist대상 더블 링크드 리스트 포인터
elmt_p찾은 엘리먼트 포인터를 저장할 변수 주소
data이 값을 가진 첫번째 엘리먼트를 찾음
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음
DLIST_ERR__NOTEXIST : data를 값으로 가지는 엘리먼트가 없음

◆ dlist_findandremove()

int dlist_findandremove ( dlist_pt  dlist,
dlist_elmt_pt elmt_p,
void *  data 
)

지정된 값을 가진 첫번째 엘리먼트를 찾아 제거하는 함수

Parameters
dlist대상 더블 링크드 리스트 포인터
elmt_p찾은 엘리먼트 포인터를 저장할 변수 주소 (NULL이면 무시)
data이 값을 가진 첫번째 엘리먼트를 찾아 제거함
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음
DLIST_ERR__NOTEXIST : data를 값으로 가지는 엘리먼트가 없음

◆ dlist_getcurnext()

dlist_elmt_pt dlist_getcurnext ( dlist_pt  dlist)

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

Parameters
dlist대상 더블 링크드 리스트 포인터
Returns
변경된 현재 엘리먼트 포인터

NULL: 대상 더블 링크드 리스트가 비어 있음

◆ dlist_insertnext()

int dlist_insertnext ( dlist_pt  dlist,
dlist_elmt_pt  ref,
dlist_elmt_pt  elmt 
)

엘리먼트를 지정된 엘리먼트 다음에 추가하는 함수

Parameters
dlist대상 더블 링크드 리스트 포인터
ref이 포인터가 가리키는 엘리먼트 다음에 추가함
NULL 이면 맨 앞에 추가함
elmt추가할 엘리먼트
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ dlist_insertprev()

int dlist_insertprev ( dlist_pt  dlist,
dlist_elmt_pt  ref,
dlist_elmt_pt  elmt 
)

엘리먼트를 지정된 엘리먼트 앞에 추가하는 함수

Parameters
dlist대상 더블 링크드 리스트 포인터
ref이 포인터가 가리키는 엘리먼트 앞에 추가함
NULL 이면 맨 뒤에 추가함
elmt추가할 엘리먼트
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ dlist_remove()

int dlist_remove ( dlist_elmt_pt  elmt)

엘리먼트를 소속된 더블 링크드 리스트에서 제거하는 함수

Parameters
elmt제거할 엘리먼트
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음
NULL
#define NULL
Definition: type.h:65