Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: samples/chat/chat_server_lib.dart

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload. Adapt code for List.fixedLength. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/snapshot_test.dart ('k') | samples/dartcombat/grids.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library chat_server; 5 library chat_server;
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 // range is split over a number of buckets where each bucket collects 632 // range is split over a number of buckets where each bucket collects
633 // the number of events happening in that time sub-range. The first 633 // the number of events happening in that time sub-range. The first
634 // constructor arument specifies the time range in milliseconds. The 634 // constructor arument specifies the time range in milliseconds. The
635 // buckets are in the list _buckets organized at a circular buffer 635 // buckets are in the list _buckets organized at a circular buffer
636 // with _currentBucket marking the bucket where an event was last 636 // with _currentBucket marking the bucket where an event was last
637 // recorded. A current sum of the content of all buckets except the 637 // recorded. A current sum of the content of all buckets except the
638 // one pointed a by _currentBucket is kept in _sum. 638 // one pointed a by _currentBucket is kept in _sum.
639 class Rate { 639 class Rate {
640 Rate([int timeRange = 1000, int buckets = 10]) 640 Rate([int timeRange = 1000, int buckets = 10])
641 : _timeRange = timeRange, 641 : _timeRange = timeRange,
642 _buckets = new List(buckets + 1), // Current bucket is not in the sum. 642 _buckets = new List.fixedLength(buckets + 1), // Current bucket is not in the sum.
643 _currentBucket = 0, 643 _currentBucket = 0,
644 _currentBucketTime = new Date.now().millisecondsSinceEpoch, 644 _currentBucketTime = new Date.now().millisecondsSinceEpoch,
645 _sum = 0 { 645 _sum = 0 {
646 _bucketTimeRange = (_timeRange / buckets).toInt(); 646 _bucketTimeRange = (_timeRange / buckets).toInt();
647 for (int i = 0; i < _buckets.length; i++) { 647 for (int i = 0; i < _buckets.length; i++) {
648 _buckets[i] = 0; 648 _buckets[i] = 0;
649 } 649 }
650 } 650 }
651 651
652 // Record the specified number of events. 652 // Record the specified number of events.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 685 }
686 } 686 }
687 687
688 int _timeRange; 688 int _timeRange;
689 List<int> _buckets; 689 List<int> _buckets;
690 int _currentBucket; 690 int _currentBucket;
691 int _currentBucketTime; 691 int _currentBucketTime;
692 num _bucketTimeRange; 692 num _bucketTimeRange;
693 int _sum; 693 int _sum;
694 } 694 }
OLDNEW
« no previous file with comments | « runtime/vm/snapshot_test.dart ('k') | samples/dartcombat/grids.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698