Freeciv-3.3
Loading...
Searching...
No Matches
worklist.h
Go to the documentation of this file.
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.
7
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
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20#include "registry.h"
21
22#include "fc_types.h"
23
24#define MAX_LEN_WORKLIST 64
25#define MAX_NUM_WORKLISTS 16
26
27/* A worklist */
32
33void worklist_init(struct worklist *pwl);
34
35int worklist_length(const struct worklist *pwl);
36bool worklist_is_empty(const struct worklist *pwl);
37bool worklist_peek(const struct worklist *pwl, struct universal *prod);
38bool worklist_peek_ith(const struct worklist *pwl,
39 struct universal *prod, int idx);
40void worklist_advance(struct worklist *pwl);
41
42void worklist_copy(struct worklist *dst, const struct worklist *src);
43void worklist_remove(struct worklist *pwl, int idx);
44bool worklist_append(struct worklist *pwl, const struct universal *prod);
45bool worklist_insert(struct worklist *pwl, const struct universal *prod,
46 int idx);
47bool are_worklists_equal(const struct worklist *wlist1,
48 const struct worklist *wlist2);
49
50/* Iterate over all entries in the worklist. */
51#define worklist_iterate(_list, _p) \
52{ \
53 struct universal _p; \
54 int _p##_index = 0; \
55 \
56 while (_p##_index < worklist_length(_list)) { \
57 worklist_peek_ith(_list, &_p, _p##_index++);
58
59#define worklist_iterate_end \
60 } \
61}
62
63#ifdef __cplusplus
64}
65#endif /* __cplusplus */
66
67#endif /* FC__WORKLIST_H */
char * incite_cost
Definition comments.c:76
struct universal entries[MAX_LEN_WORKLIST]
Definition worklist.h:30
int length
Definition worklist.h:29
void worklist_advance(struct worklist *pwl)
Definition worklist.c:104
bool worklist_peek(const struct worklist *pwl, struct universal *prod)
Definition worklist.c:76
void worklist_copy(struct worklist *dst, const struct worklist *src)
Definition worklist.c:112
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
Definition worklist.c:86
#define MAX_LEN_WORKLIST
Definition worklist.h:24
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66
bool worklist_append(struct worklist *pwl, const struct universal *prod)
Definition worklist.c:147
bool worklist_insert(struct worklist *pwl, const struct universal *prod, int idx)
Definition worklist.c:167
void worklist_remove(struct worklist *pwl, int idx)
Definition worklist.c:122
bool are_worklists_equal(const struct worklist *wlist1, const struct worklist *wlist2)
Definition worklist.c:192
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57