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

Side by Side Diff: sdk/lib/collection/set.dart

Issue 11867024: Move some core classes to collection library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with bug number. Created 7 years, 11 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 | « sdk/lib/collection/queue.dart ('k') | sdk/lib/core/core.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.core; 5 part of dart.collection;
6 6
7 /**
8 * This class is the public interface of a set. A set is a collection
9 * without duplicates.
10 */
11 abstract class Set<E> extends Collection<E> {
12 factory Set() => new HashSet<E>();
13
14 /**
15 * Creates a [Set] that contains all elements of [other].
16 */
17 factory Set.from(Iterable<E> other) => new HashSet<E>.from(other);
18
19 /**
20 * Returns true if [value] is in the set.
21 */
22 bool contains(E value);
23
24 /**
25 * Adds [value] into the set. The method has no effect if
26 * [value] was already in the set.
27 */
28 void add(E value);
29
30 /**
31 * Removes [value] from the set. Returns true if [value] was
32 * in the set. Returns false otherwise. The method has no effect
33 * if [value] value was not in the set.
34 */
35 bool remove(Object value);
36
37 /**
38 * Returns true if [collection] contains all the elements of this
39 * collection.
40 */
41 bool isSubsetOf(Collection<E> collection);
42
43 /**
44 * Returns true if this collection contains all the elements of
45 * [collection].
46 */
47 bool containsAll(Collection<E> collection);
48
49 /**
50 * Returns a new set which is the intersection between this set and
51 * the given collection.
52 */
53 Set<E> intersection(Collection<E> other);
54
55 /**
56 * Removes all elements in the set.
57 */
58 void clear();
59 }
60 7
61 8
62 class HashSet<E> extends Collection<E> implements Set<E> { 9 class HashSet<E> extends Collection<E> implements Set<E> {
63 // The map backing this set. The associations in this map are all 10 // The map backing this set. The associations in this map are all
64 // of the form element -> element. If a value is not in the map, 11 // of the form element -> element. If a value is not in the map,
65 // then it is not in the set. 12 // then it is not in the set.
66 final _HashMapImpl<E, E> _backingMap; 13 final _HashMapImpl<E, E> _backingMap;
67 14
68 HashSet() : _backingMap = new _HashMapImpl<E, E>(); 15 HashSet() : _backingMap = new _HashMapImpl<E, E>();
69 16
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 do { 101 do {
155 result = _keysIterator.moveNext(); 102 result = _keysIterator.moveNext();
156 } while (result && 103 } while (result &&
157 (_keysIterator.current == null || 104 (_keysIterator.current == null ||
158 identical(_keysIterator.current, _HashMapImpl._DELETED_KEY))); 105 identical(_keysIterator.current, _HashMapImpl._DELETED_KEY)));
159 return result; 106 return result;
160 } 107 }
161 108
162 Iterator _keysIterator; 109 Iterator _keysIterator;
163 } 110 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | sdk/lib/core/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698