ctrump/common/queue.h File Reference

FIFO. More...

#include "ctrump/common/dll.h"
#include <stddef.h>

Include dependency graph for queue.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ctrump_queue
 FIFO. More...

Defines

#define QUEUE_PUSH(t, q, e)
 追加
#define QUEUE_PUSH_PTR(t, q, dest)
 空きを作りそこへのポインタを返す
#define QUEUE_POP(t, q, dest)
 要素の取得

Functions

CTRUMP_EXTDEF void ctrump_queue_init (struct ctrump_queue *q, size_t nelem, size_t elem_size)
 FIFOの初期化.
CTRUMP_EXTDEF void ctrump_queue_realloc (struct ctrump_queue *q)
 FIFOのサイズを増やす.
CTRUMP_EXTDEF void ctrump_queue_destroy (struct ctrump_queue *q)
 FIFOの消去.


Detailed Description

FIFO.

Definition in file queue.h.


Define Documentation

#define QUEUE_POP ( t,
q,
dest   ) 

Value:

do {                                                \
        (dest) = ((t*)(q)->elements)[(q)->tail];        \
        (q)->tail++;                                    \
        (q)->rem++;                                     \
        if ((q)->tail == (q)->size)                     \
            (q)->tail = 0;                              \
    } while (0)
要素の取得

Parameters:
t 
q FIFOオブジェクト
dest 値を入れる変数

Definition at line 104 of file queue.h.

Referenced by build_bfs_order().

#define QUEUE_PUSH ( t,
q,
 ) 

Value:

do {                                        \
        if ((q)->rem==0)                        \
            ctrump_queue_realloc(q);            \
                                                \
        ((t*)(q)->elements)[(q)->head] = (e);   \
        (q)->rem --;                            \
        (q)->head ++;                           \
        if ((q)->head == (q)->size)             \
            (q)->head = 0;                      \
    } while(0)
追加

Parameters:
t 
q FIFOオブジェクト
e 要素

Definition at line 67 of file queue.h.

Referenced by build_bfs_order().

#define QUEUE_PUSH_PTR ( t,
q,
dest   ) 

Value:

do {                                        \
        if ((q)->rem==0)                        \
            ctrump_queue_realloc(q);            \
                                                \
        dest = &((t*)(q)->elements)[(q)->head]; \
        (q)->rem --;                            \
        (q)->head ++;                           \
        if ((q)->head == (q)->size)             \
            (q)->head = 0;                      \
    } while(0)
空きを作りそこへのポインタを返す

Note:
構造体のコピーをしたくない場合に使う
Parameters:
t 
q FIFOオブジェクト
dest ポインタを入れる変数

Definition at line 86 of file queue.h.


Function Documentation

CTRUMP_EXTDEF void ctrump_queue_destroy ( struct ctrump_queue q  ) 

FIFOの消去.

Parameters:
q FIFOオブジェクト

Definition at line 87 of file queue.c.

References ctrump_queue::elements.

Referenced by build_bfs_order().

CTRUMP_EXTDEF void ctrump_queue_init ( struct ctrump_queue q,
size_t  nelem,
size_t  elem_size 
)

FIFOの初期化.

Parameters:
q FIFOオブジェクト
nelem 初期要素数
要素サイズ 

Definition at line 41 of file queue.c.

References ctrump_queue::elem_size, ctrump_queue::elements, ctrump_queue::head, ctrump_queue::rem, ctrump_queue::size, and ctrump_queue::tail.

Referenced by build_bfs_order().

CTRUMP_EXTDEF void ctrump_queue_realloc ( struct ctrump_queue q  ) 

FIFOのサイズを増やす.

Parameters:
q FIFOオブジェクト

Definition at line 52 of file queue.c.

References ctrump_queue::elem_size, ctrump_queue::elements, ctrump_queue::head, ctrump_queue::rem, ctrump_queue::size, and ctrump_queue::tail.


Generated on Tue Mar 31 20:19:24 2009 for ctrump by  doxygen 1.5.6