OLD | NEW |
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 part of dart.collection; | 5 part of dart.collection; |
6 | 6 |
7 typedef bool _Predicate<T>(T value); | 7 typedef bool _Predicate<T>(T value); |
8 | 8 |
9 /** | 9 /** |
10 * A node in a splay tree. It holds the sorting key and the left | 10 * A node in a splay tree. It holds the sorting key and the left |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 return _last.key; | 758 return _last.key; |
759 } | 759 } |
760 | 760 |
761 E get single { | 761 E get single { |
762 if (_count == 0) throw IterableElementError.noElement(); | 762 if (_count == 0) throw IterableElementError.noElement(); |
763 if (_count > 1) throw IterableElementError.tooMany(); | 763 if (_count > 1) throw IterableElementError.tooMany(); |
764 return _root.key; | 764 return _root.key; |
765 } | 765 } |
766 | 766 |
767 // From Set. | 767 // From Set. |
768 bool contains(Object object) { | 768 bool contains(Object element) { |
769 return _validKey(object) && _splay(object as dynamic/*=E*/) == 0; | 769 return _validKey(element) && _splay(element as dynamic/*=E*/) == 0; |
770 } | 770 } |
771 | 771 |
772 bool add(E element) { | 772 bool add(E element) { |
773 int compare = _splay(element); | 773 int compare = _splay(element); |
774 if (compare == 0) return false; | 774 if (compare == 0) return false; |
775 _addNewRoot(new _SplayTreeNode(element), compare); | 775 _addNewRoot(new _SplayTreeNode(element), compare); |
776 return true; | 776 return true; |
777 } | 777 } |
778 | 778 |
779 bool remove(Object object) { | 779 bool remove(Object object) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 } | 862 } |
863 | 863 |
864 void clear() { | 864 void clear() { |
865 _clear(); | 865 _clear(); |
866 } | 866 } |
867 | 867 |
868 Set<E> toSet() => _clone(); | 868 Set<E> toSet() => _clone(); |
869 | 869 |
870 String toString() => IterableBase.iterableToFullString(this, '{', '}'); | 870 String toString() => IterableBase.iterableToFullString(this, '{', '}'); |
871 } | 871 } |
OLD | NEW |