Logo

Programming-Idioms

History of Idiom 17 > diff from v6 to v7

Edit summary for version 7 by :

Version 6

2015-08-23, 11:01:59

Version 7

2015-08-23, 11:02:14

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
class Node<T> {
  final T value;
  final List<Node> children;
  Node(this.value, this.children);
}
  
Code
class Node<T> {
  final T value;
  final List<Node<T>> children;
  Node(this.value, this.children);
}