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)
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
18 #endif /* __cplusplus */
24 #define MAX_LEN_WORKLIST 64
25 #define MAX_NUM_WORKLISTS 16
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
, struct universal prod
);
45 bool worklist_insert(struct worklist
*pwl
, struct universal prod
,
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) \
53 struct universal _p; \
56 while (_p##_index < worklist_length(_list)) { \
57 worklist_peek_ith(_list, &_p, _p##_index++);
59 #define worklist_iterate_end \
65 #endif /* __cplusplus */
67 #endif /* FC__WORKLIST_H */