Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Typedefs | Functions | Variables
specpq.h File Reference
#include "mem.h"

Go to the source code of this file.

Macros

#define SPECPQ_PASTE_(x, y)   x ## y
 
#define SPECPQ_PASTE(x, y)   SPECPQ_PASTE_(x, y)
 
#define SPECPQ_PQ   struct SPECPQ_PASTE(SPECPQ_TAG, _pq)
 
#define SPECPQ_PQ_   struct SPECPQ_PASTE(SPECPQ_TAG, _pq_private_)
 
#define SPECPQ_CELL_   struct SPECPQ_PASTE(SPECPQ_TAG, _cell_private_)
 
#define SPECPQ_FOO(suffix)   SPECPQ_PASTE(SPECPQ_TAG, suffix)
 

Typedefs

typedef void(*)(SPECPQ_DATA_TYPE SPECPQ_FOO) (_pq_data_free_fn_t)
 

Functions

static SPECPQ_PQ *SPECPQ_FOO() _pq_new (int initial_size)
 
static void SPECPQ_FOO() _pq_destroy (SPECPQ_PQ *_pq)
 
static void SPECPQ_FOO() _pq_destroy_full (SPECPQ_PQ *_pq, SPECPQ_FOO(_pq_data_free_fn_t) data_free)
 
static void SPECPQ_FOO() _pq_insert (SPECPQ_PQ *_pq, SPECPQ_DATA_TYPE data, SPECPQ_PRIORITY_TYPE priority)
 
static void SPECPQ_FOO() _pq_replace (SPECPQ_PQ *_pq, SPECPQ_DATA_TYPE data, SPECPQ_PRIORITY_TYPE priority)
 
static bool SPECPQ_FOO() _pq_remove (SPECPQ_PQ *_pq, SPECPQ_DATA_TYPE *pdata)
 
static bool SPECPQ_FOO() _pq_peek (const SPECPQ_PQ *_pq, SPECPQ_DATA_TYPE *pdata)
 
static bool SPECPQ_FOO() _pq_priority (const SPECPQ_PQ *_pq, SPECPQ_PRIORITY_TYPE *ppriority)
 

Variables

 SPECPQ_PQ
 
 SPECPQ_CELL_
 
SPECPQ_PRIORITY_TYPE priority
 
 SPECPQ_PQ_
 
int avail
 
int step
 
SPECPQ_CELL_cells
 

Macro Definition Documentation

◆ SPECPQ_CELL_

Definition at line 73 of file specpq.h.

◆ SPECPQ_FOO

#define SPECPQ_FOO (   suffix)    SPECPQ_PASTE(SPECPQ_TAG, suffix)

Definition at line 74 of file specpq.h.

◆ SPECPQ_PASTE

#define SPECPQ_PASTE (   x,
  y 
)    SPECPQ_PASTE_(x, y)

Definition at line 69 of file specpq.h.

◆ SPECPQ_PASTE_

#define SPECPQ_PASTE_ (   x,
  y 
)    x ## y

Definition at line 68 of file specpq.h.

◆ SPECPQ_PQ

Definition at line 71 of file specpq.h.

◆ SPECPQ_PQ_

Definition at line 72 of file specpq.h.

Typedef Documentation

◆ SPECPQ_FOO

Definition at line 80 of file specpq.h.

Function Documentation

◆ _pq_destroy()

static void SPECPQ_FOO() _pq_destroy ( SPECPQ_PQ _pq)
inlinestatic

Destructor for queue structure.

Definition at line 117 of file specpq.h.

◆ _pq_destroy_full()

static void SPECPQ_FOO() _pq_destroy_full ( SPECPQ_PQ _pq,
SPECPQ_FOO(_pq_data_free_fn_t data_free 
)
inlinestatic

Alternative destructor for queue structure.

Definition at line 129 of file specpq.h.

◆ _pq_insert()

static void SPECPQ_FOO() _pq_insert ( SPECPQ_PQ _pq,
SPECPQ_DATA_TYPE  data,
SPECPQ_PRIORITY_TYPE  priority 
)
inlinestatic

Insert an item into the queue.

Definition at line 147 of file specpq.h.

Referenced by _pq_replace().

◆ _pq_new()

static SPECPQ_PQ *SPECPQ_FOO() _pq_new ( int  initial_size)
inlinestatic

Build a new queue. 'initial_size' is the number of queue items for which memory should be preallocated, that is, the initial size of the item array the queue uses. If you insert more than n items to the queue, another n items will be allocated automatically.

Definition at line 103 of file specpq.h.

◆ _pq_peek()

static bool SPECPQ_FOO() _pq_peek ( const SPECPQ_PQ _pq,
SPECPQ_DATA_TYPE pdata 
)
inlinestatic

Store the highest-ranking item in dest without removing it. Return FALSE if the queue is empty, in case 'pdata' is not set.

Definition at line 255 of file specpq.h.

◆ _pq_priority()

static bool SPECPQ_FOO() _pq_priority ( const SPECPQ_PQ _pq,
SPECPQ_PRIORITY_TYPE ppriority 
)
inlinestatic

Set the highest priority of the queue in 'datum_priority'. Return FALSE iff the queue is empty.

Definition at line 272 of file specpq.h.

◆ _pq_remove()

static bool SPECPQ_FOO() _pq_remove ( SPECPQ_PQ _pq,
SPECPQ_DATA_TYPE pdata 
)
inlinestatic

Remove the highest-ranking item from the queue and store it in 'pdata'. 'pdata' may be NULL. Return FALSE iff no item could be removed, because the queue was empty.

Definition at line 208 of file specpq.h.

◆ _pq_replace()

static void SPECPQ_FOO() _pq_replace ( SPECPQ_PQ _pq,
SPECPQ_DATA_TYPE  data,
SPECPQ_PRIORITY_TYPE  priority 
)
inlinestatic

Set a better priority for datum. Insert if 'data' is not present yet.

Definition at line 175 of file specpq.h.

Variable Documentation

◆ avail

int avail

Definition at line 91 of file specpq.h.

◆ cells

SPECPQ_CELL_* cells

Definition at line 93 of file specpq.h.

◆ priority

◆ SPECPQ_CELL_

SPECPQ_CELL_
Initial value:
{
#define SPECPQ_DATA_TYPE

Definition at line 84 of file specpq.h.

◆ SPECPQ_PQ

SPECPQ_PQ

Definition at line 77 of file specpq.h.

◆ SPECPQ_PQ_

SPECPQ_PQ_
Initial value:
{
int size
size_t size
Definition specvec.h:72

Definition at line 89 of file specpq.h.

◆ step

int step