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

Side by Side Diff: pkg/analyzer/lib/src/generated/utilities_collection.dart

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.utilities.collection; 8 library engine.utilities.collection;
9 9
10 import "dart:math" as math;
10 import 'dart:collection'; 11 import 'dart:collection';
11 import "dart:math" as math;
12 12
13 import 'java_core.dart'; 13 import 'java_core.dart';
14 import 'scanner.dart' show Token; 14 import 'scanner.dart' show Token;
15 15
16 /** 16 /**
17 * The class `BooleanArray` defines methods for operating on integers as if they were arrays 17 * The class `BooleanArray` defines methods for operating on integers as if they were arrays
18 * of booleans. These arrays can be indexed by either integers or by enumeration constants. 18 * of booleans. These arrays can be indexed by either integers or by enumeration constants.
19 */ 19 */
20 class BooleanArray { 20 class BooleanArray {
21 /** 21 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 /** 62 /**
63 * Set the value of the element at the given index to the given value. 63 * Set the value of the element at the given index to the given value.
64 * 64 *
65 * @param array the array being modified 65 * @param array the array being modified
66 * @param index the index of the element being set 66 * @param index the index of the element being set
67 * @param value the value to be assigned to the element 67 * @param value the value to be assigned to the element
68 * @return the updated value of the array 68 * @return the updated value of the array
69 * @throws IndexOutOfBoundsException if the index is not between zero (0) and 31, inclusive 69 * @throws IndexOutOfBoundsException if the index is not between zero (0) and 31, inclusive
70 */ 70 */
71 static int setEnum(int array, Enum index, bool value) => set(array, index.ordi nal, value); 71 static int setEnum(int array, Enum index, bool value) =>
72 set(array, index.ordinal, value);
72 73
73 /** 74 /**
74 * Throw an exception if the index is not within the bounds allowed for an int eger-encoded array 75 * Throw an exception if the index is not within the bounds allowed for an int eger-encoded array
75 * of boolean values. 76 * of boolean values.
76 * 77 *
77 * @throws IndexOutOfBoundsException if the index is not between zero (0) and 31, inclusive 78 * @throws IndexOutOfBoundsException if the index is not between zero (0) and 31, inclusive
78 */ 79 */
79 static void _checkIndex(int index) { 80 static void _checkIndex(int index) {
80 if (index < 0 || index > 30) { 81 if (index < 0 || index > 30) {
81 throw new RangeError("Index not between 0 and 30: $index"); 82 throw new RangeError("Index not between 0 and 30: $index");
(...skipping 11 matching lines...) Expand all
93 */ 94 */
94 class DirectedGraph<N> { 95 class DirectedGraph<N> {
95 /** 96 /**
96 * The table encoding the edges in the graph. An edge is represented by an ent ry mapping the head 97 * The table encoding the edges in the graph. An edge is represented by an ent ry mapping the head
97 * to a set of tails. Nodes that are not the head of any edge are represented by an entry mapping 98 * to a set of tails. Nodes that are not the head of any edge are represented by an entry mapping
98 * the node to an empty set of tails. 99 * the node to an empty set of tails.
99 */ 100 */
100 HashMap<N, HashSet<N>> _edges = new HashMap<N, HashSet<N>>(); 101 HashMap<N, HashSet<N>> _edges = new HashMap<N, HashSet<N>>();
101 102
102 /** 103 /**
104 * Return `true` if this graph is empty.
105 *
106 * @return `true` if this graph is empty
107 */
108 bool get isEmpty => _edges.isEmpty;
109
110 /**
111 * Return the number of nodes in this graph.
112 *
113 * @return the number of nodes in this graph
114 */
115 int get nodeCount => _edges.length;
116
117 /**
118 * Return a set of all nodes in the graph.
119 */
120 Set<N> get nodes => _edges.keys.toSet();
121
122 /**
103 * Add an edge from the given head node to the given tail node. Both nodes wil l be a part of the 123 * Add an edge from the given head node to the given tail node. Both nodes wil l be a part of the
104 * graph after this method is invoked, whether or not they were before. 124 * graph after this method is invoked, whether or not they were before.
105 * 125 *
106 * @param head the node at the head of the edge 126 * @param head the node at the head of the edge
107 * @param tail the node at the tail of the edge 127 * @param tail the node at the tail of the edge
108 */ 128 */
109 void addEdge(N head, N tail) { 129 void addEdge(N head, N tail) {
110 // 130 //
111 // First, ensure that the tail is a node known to the graph. 131 // First, ensure that the tail is a node known to the graph.
112 // 132 //
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 */ 183 */
164 List<N> findCycleContaining(N node) { 184 List<N> findCycleContaining(N node) {
165 if (node == null) { 185 if (node == null) {
166 throw new IllegalArgumentException(); 186 throw new IllegalArgumentException();
167 } 187 }
168 DirectedGraph_SccFinder<N> finder = new DirectedGraph_SccFinder<N>(this); 188 DirectedGraph_SccFinder<N> finder = new DirectedGraph_SccFinder<N>(this);
169 return finder.componentContaining(node); 189 return finder.componentContaining(node);
170 } 190 }
171 191
172 /** 192 /**
173 * Return the number of nodes in this graph.
174 *
175 * @return the number of nodes in this graph
176 */
177 int get nodeCount => _edges.length;
178
179 /**
180 * Return a set of all nodes in the graph.
181 */
182 Set<N> get nodes => _edges.keys.toSet();
183
184 /**
185 * Return a set containing the tails of edges that have the given node as thei r head. The set will 193 * Return a set containing the tails of edges that have the given node as thei r head. The set will
186 * be empty if there are no such edges or if the node is not part of the graph . Clients must not 194 * be empty if there are no such edges or if the node is not part of the graph . Clients must not
187 * modify the returned set. 195 * modify the returned set.
188 * 196 *
189 * @param head the node at the head of all of the edges whose tails are to be returned 197 * @param head the node at the head of all of the edges whose tails are to be returned
190 * @return a set containing the tails of edges that have the given node as the ir head 198 * @return a set containing the tails of edges that have the given node as the ir head
191 */ 199 */
192 Set<N> getTails(N head) { 200 Set<N> getTails(N head) {
193 HashSet<N> tails = _edges[head]; 201 HashSet<N> tails = _edges[head];
194 if (tails == null) { 202 if (tails == null) {
195 return new HashSet<N>(); 203 return new HashSet<N>();
196 } 204 }
197 return tails; 205 return tails;
198 } 206 }
199 207
200 /** 208 /**
201 * Return `true` if this graph is empty.
202 *
203 * @return `true` if this graph is empty
204 */
205 bool get isEmpty => _edges.isEmpty;
206
207 /**
208 * Remove all of the given nodes from this graph. As a consequence, any edges for which those 209 * Remove all of the given nodes from this graph. As a consequence, any edges for which those
209 * nodes were either a head or a tail will also be removed. 210 * nodes were either a head or a tail will also be removed.
210 * 211 *
211 * @param nodes the nodes to be removed 212 * @param nodes the nodes to be removed
212 */ 213 */
213 void removeAllNodes(List<N> nodes) { 214 void removeAllNodes(List<N> nodes) {
214 for (N node in nodes) { 215 for (N node in nodes) {
215 removeNode(node); 216 removeNode(node);
216 } 217 }
217 } 218 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 int _index = 0; 352 int _index = 0;
352 353
353 /** 354 /**
354 * The stack of nodes that are being visited in order to identify components. 355 * The stack of nodes that are being visited in order to identify components.
355 */ 356 */
356 List<N> _stack = new List<N>(); 357 List<N> _stack = new List<N>();
357 358
358 /** 359 /**
359 * A table mapping nodes to information about the nodes that is used by this a lgorithm. 360 * A table mapping nodes to information about the nodes that is used by this a lgorithm.
360 */ 361 */
361 HashMap<N, DirectedGraph_NodeInfo<N>> _nodeMap = new HashMap<N, DirectedGraph_ NodeInfo<N>>(); 362 HashMap<N, DirectedGraph_NodeInfo<N>> _nodeMap =
363 new HashMap<N, DirectedGraph_NodeInfo<N>>();
362 364
363 /** 365 /**
364 * A list of all strongly connected components found, in topological sort orde r (each node in a 366 * A list of all strongly connected components found, in topological sort orde r (each node in a
365 * strongly connected component only has edges that point to nodes in the same component or 367 * strongly connected component only has edges that point to nodes in the same component or
366 * earlier components). 368 * earlier components).
367 */ 369 */
368 List<List<N>> _allComponents = new List<List<N>>(); 370 List<List<N>> _allComponents = new List<List<N>>();
369 371
370 /** 372 /**
371 * Initialize a newly created finder. 373 * Initialize a newly created finder.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 509
508 /** 510 /**
509 * Return the value associated with the current element. 511 * Return the value associated with the current element.
510 * 512 *
511 * @return the value associated with the current element 513 * @return the value associated with the current element
512 * @throws NoSuchElementException if there is no current element 514 * @throws NoSuchElementException if there is no current element
513 */ 515 */
514 V get value; 516 V get value;
515 517
516 /** 518 /**
519 * Set the value associated with the current element to the given value.
520 *
521 * @param newValue the new value to be associated with the current element
522 * @throws NoSuchElementException if there is no current element
523 */
524 void set value(V newValue);
525
526 /**
517 * Advance to the next entry in the map. Return `true` if there is a current e lement that 527 * Advance to the next entry in the map. Return `true` if there is a current e lement that
518 * can be accessed after this method returns. It is safe to invoke this method even if the 528 * can be accessed after this method returns. It is safe to invoke this method even if the
519 * previous invocation returned `false`. 529 * previous invocation returned `false`.
520 * 530 *
521 * @return `true` if there is a current element that can be accessed 531 * @return `true` if there is a current element that can be accessed
522 */ 532 */
523 bool moveNext(); 533 bool moveNext();
524
525 /**
526 * Set the value associated with the current element to the given value.
527 *
528 * @param newValue the new value to be associated with the current element
529 * @throws NoSuchElementException if there is no current element
530 */
531 void set value(V newValue);
532 } 534 }
533 535
534 /** 536 /**
535 * Instances of the class `MultipleMapIterator` implement an iterator that can b e used to 537 * Instances of the class `MultipleMapIterator` implement an iterator that can b e used to
536 * sequentially access the entries in multiple maps. 538 * sequentially access the entries in multiple maps.
537 */ 539 */
538 class MultipleMapIterator<K, V> implements MapIterator<K, V> { 540 class MultipleMapIterator<K, V> implements MapIterator<K, V> {
539 /** 541 /**
540 * The iterators used to access the entries. 542 * The iterators used to access the entries.
541 */ 543 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 576
575 @override 577 @override
576 V get value { 578 V get value {
577 if (_currentIterator == null) { 579 if (_currentIterator == null) {
578 throw new NoSuchElementException(); 580 throw new NoSuchElementException();
579 } 581 }
580 return _currentIterator.value; 582 return _currentIterator.value;
581 } 583 }
582 584
583 @override 585 @override
586 void set value(V newValue) {
587 if (_currentIterator == null) {
588 throw new NoSuchElementException();
589 }
590 _currentIterator.value = newValue;
591 }
592
593 @override
584 bool moveNext() { 594 bool moveNext() {
585 if (_iteratorIndex < 0) { 595 if (_iteratorIndex < 0) {
586 if (_iterators.length == 0) { 596 if (_iterators.length == 0) {
587 _currentIterator = null; 597 _currentIterator = null;
588 return false; 598 return false;
589 } 599 }
590 if (_advanceToNextIterator()) { 600 if (_advanceToNextIterator()) {
591 return true; 601 return true;
592 } else { 602 } else {
593 _currentIterator = null; 603 _currentIterator = null;
594 return false; 604 return false;
595 } 605 }
596 } 606 }
597 if (_currentIterator.moveNext()) { 607 if (_currentIterator.moveNext()) {
598 return true; 608 return true;
599 } else if (_advanceToNextIterator()) { 609 } else if (_advanceToNextIterator()) {
600 return true; 610 return true;
601 } else { 611 } else {
602 _currentIterator = null; 612 _currentIterator = null;
603 return false; 613 return false;
604 } 614 }
605 } 615 }
606 616
607 @override
608 void set value(V newValue) {
609 if (_currentIterator == null) {
610 throw new NoSuchElementException();
611 }
612 _currentIterator.value = newValue;
613 }
614
615 /** 617 /**
616 * Under the assumption that there are no more entries that can be returned us ing the current 618 * Under the assumption that there are no more entries that can be returned us ing the current
617 * iterator, advance to the next iterator that has entries. 619 * iterator, advance to the next iterator that has entries.
618 * 620 *
619 * @return `true` if there is a current iterator that has entries 621 * @return `true` if there is a current iterator that has entries
620 */ 622 */
621 bool _advanceToNextIterator() { 623 bool _advanceToNextIterator() {
622 _iteratorIndex++; 624 _iteratorIndex++;
623 while (_iteratorIndex < _iterators.length) { 625 while (_iteratorIndex < _iterators.length) {
624 MapIterator<K, V> iterator = _iterators[_iteratorIndex]; 626 MapIterator<K, V> iterator = _iterators[_iteratorIndex];
625 if (iterator.moveNext()) { 627 if (iterator.moveNext()) {
626 _currentIterator = iterator; 628 _currentIterator = iterator;
627 return true; 629 return true;
628 } 630 }
629 _iteratorIndex++; 631 _iteratorIndex++;
630 } 632 }
631 return false; 633 return false;
632 } 634 }
633 } 635 }
634 636
635 /** 637 /**
636 * Instances of the class `TokenMap` map one set of tokens to another set of tok ens.
637 */
638 class TokenMap {
639 /**
640 * A table mapping tokens to tokens. This should be replaced by a more perform ant implementation.
641 * One possibility is a pair of parallel arrays, with keys being sorted by the ir offset and a
642 * cursor indicating where to start searching.
643 */
644 HashMap<Token, Token> _map = new HashMap<Token, Token>();
645
646 /**
647 * Return the token that is mapped to the given token, or `null` if there is n o token
648 * corresponding to the given token.
649 *
650 * @param key the token being mapped to another token
651 * @return the token that is mapped to the given token
652 */
653 Token get(Token key) => _map[key];
654
655 /**
656 * Map the key to the value.
657 *
658 * @param key the token being mapped to the value
659 * @param value the token to which the key will be mapped
660 */
661 void put(Token key, Token value) {
662 _map[key] = value;
663 }
664 }
665
666 /**
667 * Instances of the class `SingleMapIterator` implement an iterator that can be used to access 638 * Instances of the class `SingleMapIterator` implement an iterator that can be used to access
668 * the entries in a single map. 639 * the entries in a single map.
669 */ 640 */
670 class SingleMapIterator<K, V> implements MapIterator<K, V> { 641 class SingleMapIterator<K, V> implements MapIterator<K, V> {
671 /** 642 /**
672 * Returns a new [SingleMapIterator] instance for the given [Map].
673 */
674 static SingleMapIterator forMap(Map map) => new SingleMapIterator(map);
675
676 /**
677 * The [Map] containing the entries to be iterated over. 643 * The [Map] containing the entries to be iterated over.
678 */ 644 */
679 final Map<K, V> _map; 645 final Map<K, V> _map;
680 646
681 /** 647 /**
682 * The iterator used to access the entries. 648 * The iterator used to access the entries.
683 */ 649 */
684 Iterator<K> _keyIterator; 650 Iterator<K> _keyIterator;
685 651
686 /** 652 /**
(...skipping 25 matching lines...) Expand all
712 678
713 @override 679 @override
714 V get value { 680 V get value {
715 if (_currentKey == null) { 681 if (_currentKey == null) {
716 throw new NoSuchElementException(); 682 throw new NoSuchElementException();
717 } 683 }
718 return _currentValue; 684 return _currentValue;
719 } 685 }
720 686
721 @override 687 @override
688 void set value(V newValue) {
689 if (_currentKey == null) {
690 throw new NoSuchElementException();
691 }
692 _currentValue = newValue;
693 _map[_currentKey] = newValue;
694 }
695
696 @override
722 bool moveNext() { 697 bool moveNext() {
723 if (_keyIterator.moveNext()) { 698 if (_keyIterator.moveNext()) {
724 _currentKey = _keyIterator.current; 699 _currentKey = _keyIterator.current;
725 _currentValue = _map[_currentKey]; 700 _currentValue = _map[_currentKey];
726 return true; 701 return true;
727 } else { 702 } else {
728 _currentKey = null; 703 _currentKey = null;
729 return false; 704 return false;
730 } 705 }
731 } 706 }
732 707
733 @override 708 /**
734 void set value(V newValue) { 709 * Returns a new [SingleMapIterator] instance for the given [Map].
735 if (_currentKey == null) { 710 */
736 throw new NoSuchElementException(); 711 static SingleMapIterator forMap(Map map) => new SingleMapIterator(map);
737 } 712 }
738 _currentValue = newValue; 713
739 _map[_currentKey] = newValue; 714 /**
715 * Instances of the class `TokenMap` map one set of tokens to another set of tok ens.
716 */
717 class TokenMap {
718 /**
719 * A table mapping tokens to tokens. This should be replaced by a more perform ant implementation.
720 * One possibility is a pair of parallel arrays, with keys being sorted by the ir offset and a
721 * cursor indicating where to start searching.
722 */
723 HashMap<Token, Token> _map = new HashMap<Token, Token>();
724
725 /**
726 * Return the token that is mapped to the given token, or `null` if there is n o token
727 * corresponding to the given token.
728 *
729 * @param key the token being mapped to another token
730 * @return the token that is mapped to the given token
731 */
732 Token get(Token key) => _map[key];
733
734 /**
735 * Map the key to the value.
736 *
737 * @param key the token being mapped to the value
738 * @param value the token to which the key will be mapped
739 */
740 void put(Token key, Token value) {
741 _map[key] = value;
740 } 742 }
741 } 743 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/token_factory.dart ('k') | pkg/analyzer/lib/src/generated/utilities_dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698