WIP: before recursion, a perfect iteration ? (is OK)

This commit is contained in:
Jean Sirmai 2023-12-16 08:45:54 +01:00
parent 1d1b1fa744
commit 2132b0a7b4
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 10 additions and 8 deletions

View File

@ -67,6 +67,7 @@ static TreeItem C[] = {{ "H", H }, { NULL }};
static TreeItem B[] = {{ "E", E }, { "F", F }, { "G", G }, { NULL }};
static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }};
static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }};
static TreeItem O[] = {{ "R", R }, { NULL }}; // Artefact added for symetry
static GtkTreeModel *
iterate_node(GtkTreeStore *model, TreeItem *parent, TreeItem *children)
@ -82,23 +83,24 @@ create_model (void)
{
GtkTreeStore *model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
TreeItem *item_0 = R;
while (item_0->label)
{
TreeItem *item_0 = O->children;
while (item_0->label) {
iterate_node(model, O, item_0);
GtkTreeIter iter;
gtk_tree_store_append (model, &iter, NULL);
gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -1);
TreeItem *item_1 = item_0->children;
while (item_1->label) {
iterate_node(model, item_0, item_1);
GtkTreeIter child_iter;
gtk_tree_store_append (model, &child_iter, &iter);
gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, -1);
TreeItem *item_2 = item_1->children;
while (item_2->label) {
GtkTreeIter child_child_iter;
iterate_node(model, item_1, item_2);
GtkTreeIter child_child_iter;
gtk_tree_store_append (model, &child_child_iter, &child_iter);
gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1);