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

Side by Side Diff: dart/language/grammar/stringbuffer.dart

Issue 10917035: Remove language directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « dart/language/grammar/examples.xsl ('k') | dart/language/namer_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart 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 file.
4
5 class StringBuffer {
6
7 // Constructor. Optional argument [content] takes initial content.
8 StringBuffer([String content = ""]) {
9 init(content);
10 }
11
12 // Returns the length of the buffer.
13 int get length() {
14 return length_;
15 }
16
17 // Appends item to the buffer.
18 void append(String str) {
19 list_.add(str);
20 length_ += str.length;
21 }
22
23 // Appends all items in strings to the buffer.
24 void appendAll(Collection<String> strings) {
25 strings.forEach((str) { append(str); });
26 }
27
28 // Clears the string buffer.
29 void clear() {
30 list_ = [];
31 length_ = 0;
32 }
33
34 // Sets contents of buffer to str.
35 void init(String str) {
36 if (str.isEmpty()) {
37 clear();
38 } else {
39 list_ = [str];
40 length_ += str.length;
41 }
42 }
43
44 // Returns contents of buffer as a concatenated string.
45 String toString() {
46 String result = String.join(list_, "");
47 list_ = [result];
48 return result;
49 }
50
51 List list_;
52 int length_;
53 }
OLDNEW
« no previous file with comments | « dart/language/grammar/examples.xsl ('k') | dart/language/namer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698