baum

changeset 15:e2048e569891

insertLast returns now new inserted node; very dumb implementation for action_times
author meillo@marmaro.de
date Wed, 13 Feb 2008 09:57:07 +0100
parents 15e11eea1c66
children b62288419c1c
files actions.c baum.c baum.h
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/actions.c	Wed Feb 13 09:16:01 2008 +0100
     1.2 +++ b/actions.c	Wed Feb 13 09:57:07 2008 +0100
     1.3 @@ -85,10 +85,16 @@
     1.4  
     1.5  unsigned char action_times(struct Node* node) {
     1.6  	struct Node* tp;
     1.7 +	struct Node* last;
     1.8  	unsigned char i;
     1.9  	tp = node->down;
    1.10  	for (i = 0; i < node->value; i++) {
    1.11  		/* deep copy */
    1.12 +		last = insertLast(node, newNode(tp->name, tp->value));
    1.13 +		if (tp->down != NULL) {
    1.14 +			last->down = newNode(tp->down->name, tp->down->value);
    1.15 +		}
    1.16 +
    1.17  	}
    1.18  	return 0;
    1.19  }
     2.1 --- a/baum.c	Wed Feb 13 09:16:01 2008 +0100
     2.2 +++ b/baum.c	Wed Feb 13 09:57:07 2008 +0100
     2.3 @@ -58,9 +58,10 @@
     2.4  	return node;
     2.5  }
     2.6  
     2.7 -void insertLast(struct Node* node, struct Node* insert) {
     2.8 +struct Node* insertLast(struct Node* node, struct Node* insert) {
     2.9  	node = lastNode(node);
    2.10  	node->right = insert;
    2.11 +	return insert;
    2.12  }
    2.13  
    2.14  /* delete */
     3.1 --- a/baum.h	Wed Feb 13 09:16:01 2008 +0100
     3.2 +++ b/baum.h	Wed Feb 13 09:57:07 2008 +0100
     3.3 @@ -10,7 +10,7 @@
     3.4  
     3.5  struct Node* nextNode(struct Node* node);
     3.6  struct Node* lastNode(struct Node* node);
     3.7 -void insertLast(struct Node* node, struct Node* insert);
     3.8 +struct Node* insertLast(struct Node* node, struct Node* insert);
     3.9  
    3.10  
    3.11  struct Node {