node_tree 0.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

node_tree

An unbalanced tree of arbitrary but limitable breadth and depth. Supports random and asynchronous generation.

Node children are kept in a HashMap instead of a list to support arbitrary placement.

"Breadth" (maxBreadth) here refers to the number of children per node, not to the tree itself.

[0.1.1] - November 4, 2018

  • Fix missing import.

[0.1.0] - October 30, 2018

  • First release.

example/main.dart

import 'dart:async';
import 'package:node_tree/node_tree.dart';

void main() async {
  // Number generator.
  Future<int> gen(int i) async => i + 1;

  print('Manual creation.');
  final tree = Tree<String>('a');
  final b = tree.root.add('b');
  final c = tree.root.add('c');
  b..add('d')..add('e');
  c..add('f')..add('g');
  tree.addRandom('x');
  print(tree.toString());

  print('10 random nodes.');
  print((await Tree.generate((i) async => i < 10 ? i + 1 : null))
      .toString(includePosition: true));
  print(
      (await Tree.generate(gen, maxNodes: 10)).toString(includePosition: true));

  print('Generated, depth-first.');
  print((await Tree.generate(gen, maxNodes: 10, depthFirst: true, maxDepth: 2))
      .toString(depthFirst: true));

  print('Generated, breadth-first.');
  print(
      await Tree.generate(gen, maxNodes: 10, depthFirst: false, maxBreadth: 2));

  print('Filled, depth first.');
  print((await Tree.generate(gen, maxBreadth: 2, maxDepth: 3, depthFirst: true))
      .toString(depthFirst: true));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  node_tree: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:node_tree/node_tree.dart';
  
Version Uploaded Documentation Archive
0.1.1 Nov 4, 2018 Go to the documentation of node_tree 0.1.1 Download node_tree 0.1.1 archive
0.1.0 Oct 30, 2018 Go to the documentation of node_tree 0.1.0 Download node_tree 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:node_tree/node_tree.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0