OLD | NEW |
1 // | 1 // |
2 // Copyright 2014 Google Inc. All rights reserved. | 2 // Copyright 2014 Google Inc. All rights reserved. |
3 // | 3 // |
4 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
5 // license that can be found in the LICENSE file or at | 5 // license that can be found in the LICENSE file or at |
6 // https://developers.google.com/open-source/licenses/bsd | 6 // https://developers.google.com/open-source/licenses/bsd |
7 // | 7 // |
8 | 8 |
9 library charted.core.text_metrics.segmentation; | 9 library charted.core.text_metrics.segmentation; |
10 | 10 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 if (CODE_POINT_BLOCKS[idx] > rune) { | 179 if (CODE_POINT_BLOCKS[idx] > rune) { |
180 max = mid - 1; | 180 max = mid - 1; |
181 } else if (CODE_POINT_BLOCKS[idx + 1] < rune) { | 181 } else if (CODE_POINT_BLOCKS[idx + 1] < rune) { |
182 min = max + 1; | 182 min = max + 1; |
183 } | 183 } |
184 } | 184 } |
185 return CODE_CATEGORY_OTHER; // Defaults to OTHER. | 185 return CODE_CATEGORY_OTHER; // Defaults to OTHER. |
186 } | 186 } |
187 | 187 |
188 Iterable<int> graphemeBreakIndices(String s) { | 188 List<int> graphemeBreakIndices(String s) { |
189 List<int> indices = []; | 189 List<int> indices = []; |
190 int previousType = 0; | 190 int previousType = 0; |
191 for (var iter = s.runes.iterator; iter.moveNext();) { | 191 for (var iter = s.runes.iterator; iter.moveNext();) { |
192 int currentType = _typeForRune(iter.current); | 192 int currentType = _typeForRune(iter.current); |
193 if (GRAPHEME_BREAK_TABLE[previousType * 12 + currentType] == 1) { | 193 if (GRAPHEME_BREAK_TABLE[previousType * 12 + currentType] == 1) { |
194 indices.add(iter.rawIndex); | 194 indices.add(iter.rawIndex); |
195 } | 195 } |
196 previousType = currentType; | 196 previousType = currentType; |
197 } | 197 } |
198 return indices; | 198 return indices; |
199 } | 199 } |
OLD | NEW |