| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 import 'dart/performance_service.dart'; | |
| 6 | |
| 7 class PerformanceServiceImpl implements PerformanceService { | |
| 8 int echo(int n) => n; | |
| 9 | |
| 10 int countTreeNodes(TreeNode node) { | |
| 11 int sum = 1; | |
| 12 List<TreeNode> children = node.children; | |
| 13 for (int i = 0; i < children.length; i++) { | |
| 14 sum += countTreeNodes(children[i]); | |
| 15 } | |
| 16 return sum; | |
| 17 } | |
| 18 | |
| 19 void buildTree(int n, TreeNodeBuilder node) { | |
| 20 if (n > 1) { | |
| 21 List<TreeNodeBuilder> children = node.initChildren(2); | |
| 22 buildTree(n - 1, children[0]); | |
| 23 buildTree(n - 1, children[1]); | |
| 24 } | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 main() { | |
| 29 var impl = new PerformanceServiceImpl(); | |
| 30 PerformanceService.initialize(impl); | |
| 31 while (PerformanceService.hasNextEvent()) { | |
| 32 PerformanceService.handleNextEvent(); | |
| 33 } | |
| 34 } | |
| OLD | NEW |