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

Side by Side Diff: lib/src/particle/stack_queue.dart

Issue 1138063003: pkg/box2d: 0.2.0 release (Closed) Base URL: https://github.com/google/dbox2d.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « lib/src/particle/particle_system.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2015, Daniel Murphy, Google 2 * Copyright (c) 2015, Daniel Murphy, Google
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without modificati on, 5 * Redistribution and use in source and binary forms, with or without modificati on,
6 * are permitted provided that the following conditions are met: 6 * are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright notice, 7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice, 9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation 10 * this list of conditions and the following disclaimer in the documentation
(...skipping 23 matching lines...) Expand all
34 34
35 void reset(List<T> buffer) { 35 void reset(List<T> buffer) {
36 _buffer = buffer; 36 _buffer = buffer;
37 _front = 0; 37 _front = 0;
38 _back = 0; 38 _back = 0;
39 _end = buffer.length; 39 _end = buffer.length;
40 } 40 }
41 41
42 void push(T task) { 42 void push(T task) {
43 if (_back >= _end) { 43 if (_back >= _end) {
44 BufferUtils.arraycopy( 44 BufferUtils.arraycopy(_buffer, _front, _buffer, 0, _back - _front);
45 _buffer, _front, _buffer, 0, _back - _front);
46 _back -= _front; 45 _back -= _front;
47 _front = 0; 46 _front = 0;
48 if (_back >= _end) { 47 if (_back >= _end) {
49 return; 48 return;
50 } 49 }
51 } 50 }
52 _buffer[_back++] = task; 51 _buffer[_back++] = task;
53 } 52 }
54 53
55 T pop() { 54 T pop() {
56 assert(_front < _back); 55 assert(_front < _back);
57 return _buffer[_front++]; 56 return _buffer[_front++];
58 } 57 }
59 58
60 bool empty() { 59 bool empty() {
61 return _front >= _back; 60 return _front >= _back;
62 } 61 }
63 62
64 T front() { 63 T front() {
65 return _buffer[_front]; 64 return _buffer[_front];
66 } 65 }
67 } 66 }
OLDNEW
« no previous file with comments | « lib/src/particle/particle_system.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698