Logo

Programming-Idioms

History of Idiom 17 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-20, 15:45:49

Version 5

2015-08-20, 18:02:21

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to his parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to his parent.

Code
struct Node(T){
    Node!T[] children;
    T data;
}

alias TreeOfIntegers = Node!(int);
Code
struct Node(T){
    Node[] children;
    T data;
}

alias TreeOfIntegers = Node!(int);
Comments bubble
Inside template Node(T), Node is an alias for the instantiated type.