Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / worklist.h
blobb4b081ccee4457eb587ac5ee846b47772775a5e0
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__WORKLIST_H
14 #define FC__WORKLIST_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #include "registry.h"
22 #include "fc_types.h"
24 #define MAX_LEN_WORKLIST 64
25 #define MAX_NUM_WORKLISTS 16
27 /* a worklist */
28 struct worklist {
29 int length;
30 struct universal entries[MAX_LEN_WORKLIST];
33 void worklist_init(struct worklist *pwl);
35 int worklist_length(const struct worklist *pwl);
36 bool worklist_is_empty(const struct worklist *pwl);
37 bool worklist_peek(const struct worklist *pwl, struct universal *prod);
38 bool worklist_peek_ith(const struct worklist *pwl,
39 struct universal *prod, int idx);
40 void worklist_advance(struct worklist *pwl);
42 void worklist_copy(struct worklist *dst, const struct worklist *src);
43 void worklist_remove(struct worklist *pwl, int idx);
44 bool worklist_append(struct worklist *pwl, const struct universal *prod);
45 bool worklist_insert(struct worklist *pwl, const struct universal *prod,
46 int idx);
47 bool are_worklists_equal(const struct worklist *wlist1,
48 const struct worklist *wlist2);
50 /* Iterate over all entries in the worklist. */
51 #define worklist_iterate(_list, _p) \
52 { \
53 struct universal _p; \
54 int _p##_index = 0; \
56 while (_p##_index < worklist_length(_list)) { \
57 worklist_peek_ith(_list, &_p, _p##_index++);
59 #define worklist_iterate_end \
60 } \
63 #ifdef __cplusplus
65 #endif /* __cplusplus */
67 #endif /* FC__WORKLIST_H */