2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
7 #ifndef SATSOLVER_DIRPOOL_H
8 #define SATSOLVER_DIRPOOL_H
11 #include "pooltypes.h"
14 typedef struct _Dirpool {
20 void dirpool_init(Dirpool *dp);
21 void dirpool_free(Dirpool *dp);
23 void dirpool_make_dirtraverse(Dirpool *dp);
24 Id dirpool_add_dir(Dirpool *dp, Id parent, Id comp, int create);
26 static inline Id dirpool_parent(Dirpool *dp, Id did)
30 while (dp->dirs[--did] > 0)
32 return -dp->dirs[did];
36 dirpool_sibling(Dirpool *dp, Id did)
38 if (did + 1 < dp->ndirs && dp->dirs[did + 1] > 0)
40 while (dp->dirs[--did] > 0)
42 /* need to special case did == 0 to prevent looping */
46 dirpool_make_dirtraverse(dp);
47 return dp->dirtraverse[did];
51 dirpool_child(Dirpool *dp, Id did)
54 dirpool_make_dirtraverse(dp);
55 return dp->dirtraverse[did];
59 dirpool_free_dirtraverse(Dirpool *dp)
61 sat_free(dp->dirtraverse);
66 dirpool_compid(Dirpool *dp, Id did)
71 #endif /* SATSOLVER_DIRPOOL_H */