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

Go to the source code of this file.

Macros

#define SPECLIST_PASTE_(x, y)   x ## y
 
#define SPECLIST_PASTE(x, y)   SPECLIST_PASTE_(x,y)
 
#define SPECLIST_LIST   struct SPECLIST_PASTE(SPECLIST_TAG, _list)
 
#define SPECLIST_LINK   struct SPECLIST_PASTE(SPECLIST_TAG, _list_link)
 
#define SPECLIST_FOO(suffix)   SPECLIST_PASTE(SPECLIST_TAG, suffix)
 
#define FC__SPECLIST_H
 
#define TYPED_LIST_CHECK(ARG_list)   /* Nothing. */
 
#define TYPED_LIST_ITERATE(TYPE_data, ARG_list, NAME_data)
 
#define LIST_ITERATE_END
 
#define MUTEXED_LIST_ITERATE(TYPE_data, LIST_tag, ARG_list, NAME_data)
 
#define MUTEXED_ITERATE_END(LIST_tag, ARG_list)
 
#define MUTEXED_ITERATE_BREAK(LIST_tag, ARG_list)
 
#define TYPED_LIST_ITERATE_REV(TYPE_data, ARG_list, NAME_data)
 
#define LIST_ITERATE_REV_END
 
#define TYPED_LIST_LINK_ITERATE(TYPE_link, ARG_list, NAME_link)
 
#define LIST_LINK_ITERATE_END
 
#define TYPED_LIST_LINK_ITERATE_REV(TYPE_link, ARG_list, NAME_link)
 
#define LIST_LINK_ITERATE_REV_END
 
#define TYPED_LIST_BOTH_ITERATE(TYPE_link, TYPE_data, ARG_list, NAME_link, NAME_data)
 
#define LIST_BOTH_ITERATE_END
 
#define TYPED_LIST_BOTH_ITERATE_REV(TYPE_link, TYPE_data, ARG_list, NAME_link, NAME_data)
 
#define LIST_BOTH_ITERATE_REV_END
 

Typedefs

typedef void(*)(SPECLIST_TYPESPECLIST_FOO) (_list_free_fn_t)
 

Functions

static SPECLIST_LIST *SPECLIST_FOO() _list_new (void) fc__warn_unused_result
 
static SPECLIST_LIST *SPECLIST_FOO() _list_new_full (SPECLIST_FOO(_list_free_fn_t) free_data_func) fc__warn_unused_result
 
static void SPECLIST_FOO() _list_destroy (SPECLIST_LIST *tthis)
 
static SPECLIST_LIST *SPECLIST_FOO() _list_copy (const SPECLIST_LIST *tthis) fc__warn_unused_result
 
static SPECLIST_LIST *SPECLIST_FOO() _list_copy_full (const SPECLIST_LIST *tthis, SPECLIST_FOO(_list_copy_fn_t) copy_data_func, SPECLIST_FOO(_list_free_fn_t) free_data_func) fc__warn_unused_result
 
static void SPECLIST_FOO() _list_clear (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_unique (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_unique_full (SPECLIST_LIST *tthis, SPECLIST_FOO(_list_comp_fn_t) comp_data_func)
 
static void SPECLIST_FOO() _list_append (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
 
static void SPECLIST_FOO() _list_prepend (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
 
static void SPECLIST_FOO() _list_insert (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, int idx)
 
static void SPECLIST_FOO() _list_insert_after (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, SPECLIST_LINK *plink)
 
static void SPECLIST_FOO() _list_insert_before (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, SPECLIST_LINK *plink)
 
static bool SPECLIST_FOO() _list_remove (SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
 
static bool SPECLIST_FOO() _list_remove_if (SPECLIST_LIST *tthis, SPECLIST_FOO(_list_cond_fn_t) cond_data_func)
 
static int SPECLIST_FOO() _list_remove_all (SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
 
static bool SPECLIST_FOO() _list_remove_all_if (SPECLIST_LIST *tthis, cond_data_func)
 
static void SPECLIST_FOO() _list_erase (SPECLIST_LIST *tthis, SPECLIST_LINK *plink)
 
static void SPECLIST_FOO() _list_pop_front (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_pop_back (SPECLIST_LIST *tthis)
 
static int SPECLIST_FOO() _list_size (const SPECLIST_LIST *tthis)
 
static SPECLIST_TYPE *SPECLIST_FOO() _list_get (const SPECLIST_LIST *tthis, int slindex)
 
static SPECLIST_TYPE *SPECLIST_FOO() _list_front (const SPECLIST_LIST *tthis)
 
static SPECLIST_TYPE *SPECLIST_FOO() _list_back (const SPECLIST_LIST *tthis)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_link_get (const SPECLIST_LIST *tthis, int slindex)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_head (const SPECLIST_LIST *tthis)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_tail (const SPECLIST_LIST *tthis)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_search (const SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_search_if (const SPECLIST_LIST *tthis, SPECLIST_FOO(_list_cond_fn_t) cond_data_func)
 
static void SPECLIST_FOO() _list_sort (SPECLIST_LIST *tthis, int(*compar)(const SPECLIST_TYPE *const *, const SPECLIST_TYPE *const *))
 
static void SPECLIST_FOO() _list_shuffle (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_reverse (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_allocate_mutex (SPECLIST_LIST *tthis)
 
static void SPECLIST_FOO() _list_release_mutex (SPECLIST_LIST *tthis)
 
static SPECLIST_TYPE *SPECLIST_FOO() _list_link_data (const SPECLIST_LINK *plink)
 
static SPECLIST_LINK *SPECLIST_FOO() _list_link_prev (const SPECLIST_LINK *plink) fc__warn_unused_result
 
static SPECLIST_LINK *SPECLIST_FOO() _list_link_next (const SPECLIST_LINK *plink) fc__warn_unused_result
 

Variables

 SPECLIST_LIST
 
 SPECLIST_LINK
 

Macro Definition Documentation

◆ FC__SPECLIST_H

#define FC__SPECLIST_H

Definition at line 556 of file speclist.h.

◆ LIST_BOTH_ITERATE_END

#define LIST_BOTH_ITERATE_END
Value:
} \
} while (FALSE);
#define FALSE
Definition support.h:47

Definition at line 714 of file speclist.h.

◆ LIST_BOTH_ITERATE_REV_END

#define LIST_BOTH_ITERATE_REV_END
Value:
} \
} while (FALSE);

Definition at line 741 of file speclist.h.

◆ LIST_ITERATE_END

#define LIST_ITERATE_END
Value:
} \
} while (FALSE);

Definition at line 586 of file speclist.h.

◆ LIST_ITERATE_REV_END

#define LIST_ITERATE_REV_END
Value:
} \
} while (FALSE);

Definition at line 639 of file speclist.h.

◆ LIST_LINK_ITERATE_END

#define LIST_LINK_ITERATE_END
Value:
} \
} while (FALSE);

Definition at line 663 of file speclist.h.

◆ LIST_LINK_ITERATE_REV_END

#define LIST_LINK_ITERATE_REV_END
Value:
} \
} while (FALSE);

Definition at line 684 of file speclist.h.

◆ MUTEXED_ITERATE_BREAK

#define MUTEXED_ITERATE_BREAK (   LIST_tag,
  ARG_list 
)
Value:
do { \
} while (FALSE);
char * incite_cost
Definition comments.c:75
static void SPECLIST_FOO() _list_release_mutex(SPECLIST_LIST *tthis)
Definition speclist.h:504

Definition at line 618 of file speclist.h.

◆ MUTEXED_ITERATE_END

#define MUTEXED_ITERATE_END (   LIST_tag,
  ARG_list 
)
Value:

Definition at line 613 of file speclist.h.

◆ MUTEXED_LIST_ITERATE

#define MUTEXED_LIST_ITERATE (   TYPE_data,
  LIST_tag,
  ARG_list,
  NAME_data 
)
Value:
do { \
const struct genlist_link *NAME_data##_iter; \
NAME_data##_iter = genlist_head((const struct genlist *) ARG_list); \
static struct genlist_link * genlist_head(const struct genlist *pgenlist)
Definition genlist.h:108
static void * genlist_link_data(const struct genlist_link *plink)
Definition genlist.h:140
static fc__warn_unused_result struct genlist_link * genlist_link_next(const struct genlist_link *plink)
Definition genlist.h:162
static void SPECLIST_FOO() _list_allocate_mutex(SPECLIST_LIST *tthis)
Definition speclist.h:496

Definition at line 601 of file speclist.h.

◆ SPECLIST_FOO

#define SPECLIST_FOO (   suffix)    SPECLIST_PASTE(SPECLIST_TAG, suffix)

Definition at line 145 of file speclist.h.

◆ SPECLIST_LINK

Definition at line 144 of file speclist.h.

◆ SPECLIST_LIST

Definition at line 143 of file speclist.h.

◆ SPECLIST_PASTE

#define SPECLIST_PASTE (   x,
  y 
)    SPECLIST_PASTE_(x,y)

Definition at line 141 of file speclist.h.

◆ SPECLIST_PASTE_

#define SPECLIST_PASTE_ (   x,
  y 
)    x ## y

Definition at line 140 of file speclist.h.

◆ TYPED_LIST_BOTH_ITERATE

#define TYPED_LIST_BOTH_ITERATE (   TYPE_link,
  TYPE_data,
  ARG_list,
  NAME_link,
  NAME_data 
)

◆ TYPED_LIST_BOTH_ITERATE_REV

#define TYPED_LIST_BOTH_ITERATE_REV (   TYPE_link,
  TYPE_data,
  ARG_list,
  NAME_link,
  NAME_data 
)
Value:
do { \
genlist_tail((const struct genlist *) ARG_list)); \
NAME_link)); \
struct genlist_link * genlist_tail(const struct genlist *pgenlist)
Definition genlist.c:213
static fc__warn_unused_result struct genlist_link * genlist_link_prev(const struct genlist_link *plink)
Definition genlist.h:151

Definition at line 725 of file speclist.h.

◆ TYPED_LIST_CHECK

#define TYPED_LIST_CHECK (   ARG_list)    /* Nothing. */

Definition at line 562 of file speclist.h.

◆ TYPED_LIST_ITERATE

#define TYPED_LIST_ITERATE (   TYPE_data,
  ARG_list,
  NAME_data 
)

◆ TYPED_LIST_ITERATE_REV

#define TYPED_LIST_ITERATE_REV (   TYPE_data,
  ARG_list,
  NAME_data 
)

◆ TYPED_LIST_LINK_ITERATE

#define TYPED_LIST_LINK_ITERATE (   TYPE_link,
  ARG_list,
  NAME_link 
)

◆ TYPED_LIST_LINK_ITERATE_REV

#define TYPED_LIST_LINK_ITERATE_REV (   TYPE_link,
  ARG_list,
  NAME_link 
)

Typedef Documentation

◆ SPECLIST_FOO

static SPECLIST_LINK * SPECLIST_FOO
inline

Definition at line 154 of file speclist.h.

Function Documentation

◆ _list_allocate_mutex()

static void SPECLIST_FOO() _list_allocate_mutex ( SPECLIST_LIST tthis)
inlinestatic

Allocate speclist mutex

Definition at line 496 of file speclist.h.

◆ _list_append()

static void SPECLIST_FOO() _list_append ( SPECLIST_LIST tthis,
SPECLIST_TYPE pfoo 
)
inlinestatic

Push back an element into the speclist.

Definition at line 260 of file speclist.h.

◆ _list_back()

static SPECLIST_TYPE *SPECLIST_FOO() _list_back ( const SPECLIST_LIST tthis)
inlinestatic

Return the last element of the speclist.

Definition at line 409 of file speclist.h.

◆ _list_clear()

static void SPECLIST_FOO() _list_clear ( SPECLIST_LIST tthis)
inlinestatic

Remove all elements from the speclist.

Definition at line 232 of file speclist.h.

◆ _list_copy()

static SPECLIST_LIST *SPECLIST_FOO() _list_copy ( const SPECLIST_LIST tthis)
inlinestatic

Duplicate a speclist.

Definition at line 203 of file speclist.h.

◆ _list_copy_full()

static SPECLIST_LIST *SPECLIST_FOO() _list_copy_full ( const SPECLIST_LIST tthis,
SPECLIST_FOO(_list_copy_fn_t copy_data_func,
SPECLIST_FOO(_list_free_fn_t free_data_func 
)
inlinestatic

Duplicate a speclist with a free callback and a function to copy each element.

Definition at line 219 of file speclist.h.

◆ _list_destroy()

static void SPECLIST_FOO() _list_destroy ( SPECLIST_LIST tthis)
inlinestatic

Free a speclist.

Definition at line 190 of file speclist.h.

◆ _list_erase()

static void SPECLIST_FOO() _list_erase ( SPECLIST_LIST tthis,
SPECLIST_LINK plink 
)
inlinestatic

Remove the elements pointed by 'plink'. Returns the next element of the speclist.

NB: After calling this function 'plink' is no more usable. You should have saved the next or previous link before.

Definition at line 356 of file speclist.h.

◆ _list_front()

static SPECLIST_TYPE *SPECLIST_FOO() _list_front ( const SPECLIST_LIST tthis)
inlinestatic

Return the first element of the speclist.

Definition at line 400 of file speclist.h.

◆ _list_get()

static SPECLIST_TYPE *SPECLIST_FOO() _list_get ( const SPECLIST_LIST tthis,
int  slindex 
)
inlinestatic

Return the element at position in the speclist.

Definition at line 390 of file speclist.h.

◆ _list_head()

static SPECLIST_LINK *SPECLIST_FOO() _list_head ( const SPECLIST_LIST tthis)
inlinestatic

Return the head link of the speclist.

Definition at line 428 of file speclist.h.

◆ _list_insert()

static void SPECLIST_FOO() _list_insert ( SPECLIST_LIST tthis,
SPECLIST_TYPE pfoo,
int  idx 
)
inlinestatic

Insert an element into the speclist at the given position.

Definition at line 278 of file speclist.h.

◆ _list_insert_after()

static void SPECLIST_FOO() _list_insert_after ( SPECLIST_LIST tthis,
SPECLIST_TYPE pfoo,
SPECLIST_LINK plink 
)
inlinestatic

Insert an element after the specified link.

Definition at line 287 of file speclist.h.

◆ _list_insert_before()

static void SPECLIST_FOO() _list_insert_before ( SPECLIST_LIST tthis,
SPECLIST_TYPE pfoo,
SPECLIST_LINK plink 
)
inlinestatic

Insert an element before the specified link.

Definition at line 298 of file speclist.h.

◆ _list_link_data()

static SPECLIST_TYPE *SPECLIST_FOO() _list_link_data ( const SPECLIST_LINK plink)
inlinestatic

Return the data of the link.

Definition at line 513 of file speclist.h.

◆ _list_link_get()

static SPECLIST_LINK *SPECLIST_FOO() _list_link_get ( const SPECLIST_LIST tthis,
int  slindex 
)
inlinestatic

Return the element at position in the speclist.

Definition at line 418 of file speclist.h.

◆ _list_link_next()

static SPECLIST_LINK *SPECLIST_FOO() _list_link_next ( const SPECLIST_LINK plink)
inlinestatic

Return the next link.

Definition at line 541 of file speclist.h.

◆ _list_link_prev()

static SPECLIST_LINK *SPECLIST_FOO() _list_link_prev ( const SPECLIST_LINK plink)
inlinestatic

Return the previous link.

Definition at line 527 of file speclist.h.

◆ _list_new()

static SPECLIST_LIST *SPECLIST_FOO() _list_new ( void  )
inlinestatic

Create a new speclist.

Definition at line 168 of file speclist.h.

◆ _list_new_full()

static SPECLIST_LIST *SPECLIST_FOO() _list_new_full ( SPECLIST_FOO(_list_free_fn_t free_data_func)
inlinestatic

Create a new speclist with a free callback.

Definition at line 181 of file speclist.h.

◆ _list_pop_back()

static void SPECLIST_FOO() _list_pop_back ( SPECLIST_LIST tthis)
inlinestatic

Remove the last element of the speclist.

Definition at line 373 of file speclist.h.

◆ _list_pop_front()

static void SPECLIST_FOO() _list_pop_front ( SPECLIST_LIST tthis)
inlinestatic

Remove the first element of the speclist.

Definition at line 365 of file speclist.h.

◆ _list_prepend()

static void SPECLIST_FOO() _list_prepend ( SPECLIST_LIST tthis,
SPECLIST_TYPE pfoo 
)
inlinestatic

Push front an element into the speclist.

Definition at line 269 of file speclist.h.

◆ _list_release_mutex()

static void SPECLIST_FOO() _list_release_mutex ( SPECLIST_LIST tthis)
inlinestatic

Release speclist mutex

Definition at line 504 of file speclist.h.

◆ _list_remove()

static bool SPECLIST_FOO() _list_remove ( SPECLIST_LIST tthis,
const SPECLIST_TYPE pfoo 
)
inlinestatic

Search 'pfoo' in the speclist, and remove it. Returns TRUE on success.

Definition at line 309 of file speclist.h.

◆ _list_remove_all()

static int SPECLIST_FOO() _list_remove_all ( SPECLIST_LIST tthis,
const SPECLIST_TYPE pfoo 
)
inlinestatic

Remove 'pfoo' of the whole list. Returns the number of removed elements.

Definition at line 330 of file speclist.h.

◆ _list_remove_all_if()

static bool SPECLIST_FOO() _list_remove_all_if ( SPECLIST_LIST tthis,
cond_data_func   
)
inlinestatic

Remove all elements which fit the conditional function. Returns the number of removed elements.

Definition at line 341 of file speclist.h.

◆ _list_remove_if()

static bool SPECLIST_FOO() _list_remove_if ( SPECLIST_LIST tthis,
SPECLIST_FOO(_list_cond_fn_t cond_data_func 
)
inlinestatic

Remove the first element which fit the conditional function. Returns TRUE on success.

Definition at line 320 of file speclist.h.

◆ _list_reverse()

static void SPECLIST_FOO() _list_reverse ( SPECLIST_LIST tthis)
inlinestatic

Reverse the order of the elements of the speclist.

Definition at line 488 of file speclist.h.

◆ _list_search()

static SPECLIST_LINK *SPECLIST_FOO() _list_search ( const SPECLIST_LIST tthis,
const SPECLIST_TYPE pfoo 
)
inlinestatic

Return the link of the first element which match the data 'pfoo'.

Definition at line 446 of file speclist.h.

◆ _list_search_if()

static SPECLIST_LINK *SPECLIST_FOO() _list_search_if ( const SPECLIST_LIST tthis,
SPECLIST_FOO(_list_cond_fn_t cond_data_func 
)
inlinestatic

Return the link of the first element which match the conditional function.

Definition at line 457 of file speclist.h.

◆ _list_shuffle()

static void SPECLIST_FOO() _list_shuffle ( SPECLIST_LIST tthis)
inlinestatic

Shuffle the speclist.

Definition at line 480 of file speclist.h.

◆ _list_size()

static int SPECLIST_FOO() _list_size ( const SPECLIST_LIST tthis)
inlinestatic

Return the number of elements inside the speclist.

Definition at line 381 of file speclist.h.

◆ _list_sort()

static void SPECLIST_FOO() _list_sort ( SPECLIST_LIST tthis,
int(*)(const SPECLIST_TYPE *const *, const SPECLIST_TYPE *const *)  compar 
)
inlinestatic

Sort the speclist.

Definition at line 469 of file speclist.h.

◆ _list_tail()

static SPECLIST_LINK *SPECLIST_FOO() _list_tail ( const SPECLIST_LIST tthis)
inlinestatic

Return the tail link of the speclist.

Definition at line 437 of file speclist.h.

◆ _list_unique()

static void SPECLIST_FOO() _list_unique ( SPECLIST_LIST tthis)
inlinestatic

Remove all element duplicates (the speclist must be sorted before).

Definition at line 240 of file speclist.h.

◆ _list_unique_full()

static void SPECLIST_FOO() _list_unique_full ( SPECLIST_LIST tthis,
SPECLIST_FOO(_list_comp_fn_t comp_data_func 
)
inlinestatic

Remove all element duplicates (the speclist must be sorted before), using 'comp_data_func' to determine if the elements are equivalents.

Definition at line 250 of file speclist.h.

Variable Documentation

◆ SPECLIST_LINK

SPECLIST_LINK

Definition at line 151 of file speclist.h.

◆ SPECLIST_LIST

SPECLIST_LIST

Definition at line 148 of file speclist.h.