OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import '../lib/shared_messages.dart' as shared_messages; | 7 import '../lib/shared_messages.dart' as shared_messages; |
8 | 8 |
9 math.Random random = new math.Random(); | 9 math.Random random = new math.Random(); |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /// Computes a random message ID that hasn't been used before. | 23 /// Computes a random message ID that hasn't been used before. |
24 void main() { | 24 void main() { |
25 var usedIds = | 25 var usedIds = |
26 shared_messages.MESSAGES.values.map((entry) => entry.id).toSet(); | 26 shared_messages.MESSAGES.values.map((entry) => entry.id).toSet(); |
27 | 27 |
28 print("${usedIds.length} existing ids"); | 28 print("${usedIds.length} existing ids"); |
29 | 29 |
30 var newId; | 30 var newId; |
31 do { | 31 do { |
32 newId = computeId(); | 32 newId = computeId(); |
33 } while (!usedIds.contains(newId)); | 33 } while (usedIds.contains(newId)); |
34 print("Available id: $newId"); | 34 print("Available id: $newId"); |
35 } | 35 } |
OLD | NEW |