以下に示すようなマルチレベルのデータ構造を実装しようとしています。
object {
object A {
child {
myChild;
};
child 1 {
mychild;
};
};
object B {
child {
};
};
};
私のアプローチは、以下に示すように、リンクされたリストを使用してこれを実装することです。
typedef struct node_s {
struct node_s *next;
struct node_s *first_child;
struct node_s *parent;
char *text;
} node_t;
上記のリストを STAILQ (sys/queue.h linux) に変換すると、
typedef struct node_s {
char *text;
....;
} node_t;
typedef struct list_s {
STAILQ_ENTRY(list_s) link;
node_t *first_child;
node_t *parent;
node_t *next;
int level;
} list_t;
typedef STAILQ_HEAD(list_head_s, list_s) list_head_t;
リンクされたリストまたはリンクされたリストを使用する以外に、これを実装する他のより良い方法があるかどうかを提案してください。