Commit Graph

104 Commits

Author SHA1 Message Date
lrn@google.com 171c6d7741 Optimize some collection operations.
Extracted from EfficientLength CL.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//26976002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28509 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-11 11:39:57 +00:00
lrn@google.com e3713a08d4 Make List.shuffle take an optional Random object to use.
R=floitsch@google.com

Review URL: https://codereview.chromium.org//25931003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28305 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-07 12:07:30 +00:00
lrn@google.com 55a8a72ca6 Add List.shuffle().
Will add tests too.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//24740003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28206 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 11:09:01 +00:00
iposva@google.com e7e2e4bf03 - Rename arrays to lists:
_ObjectArray -> _List
  _GrowableObjectArray -> _GrowableList
  _ImmutableArray -> _ImmutableList

R=srdjan@google.com

Review URL: https://codereview.chromium.org//25813002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28189 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 00:15:14 +00:00
zarah@google.com 93bcd6baf7 Move toString() to collection classes.
R=floitsch@google.com

Committed: https://code.google.com/p/dart/source/detail?r=24836

Review URL: https://codereview.chromium.org//18837002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24913 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-11 12:59:12 +00:00
zarah@google.com a0c76e6d43 Revert "Move toString() to collection classes."
This reverts commit 24836

Review URL: https://codereview.chromium.org//18282008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24837 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 09:36:47 +00:00
zarah@google.com 8ed47ae514 Move toString() to collection classes.
R=floitsch@google.com

Review URL: https://codereview.chromium.org//18837002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24836 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 08:35:54 +00:00
floitsch@google.com 48b1656690 Allow Object when doing lookups.
According to our typing rules a Set<Apple> is a Set<Fruit>. However, before this change, we couldn't use it as a Set<Fruit>:

===
bool foo(Set<Fruit> fruits) {
  // Would yield a type-error since we actually got a Set<Apple>.
  return fruits.contains(new Banana());
}

foo(new Set<Apple>());
===

R=ajohnsen@google.com, blois@google.com, lrn@google.com

Review URL: https://codereview.chromium.org//14246008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24326 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-24 12:45:10 +00:00
floitsch@google.com 5d058bb0eb Adding isNotEmpty property to collection and string.
BUG= http://dartbug.com/3074
R=floitsch@google.com

Review URL: https://codereview.chromium.org//15263004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23294 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-28 17:30:37 +00:00
srdjan@google.com 7797d39362 Added Object._cid getter, optimized it. Added to (some) classes a static final _clCid. Use those to test for exact type in VM's libraries.
R=iposva@google.com

Review URL: https://codereview.chromium.org//14703005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22695 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-14 18:16:44 +00:00
lrn@google.com e0e13fe852 Fix missing concurrency check in [].forEach.
Also fix a bad range check for List.setRange.

Added more tests.

BUG=http://dartbug.com/10045

Review URL: https://codereview.chromium.org//14468004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21935 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 09:34:17 +00:00
lrn@google.com 554a845e4f Make List.remove return boolean.
Remove Queue implementations' remove methods, which are not in the
interface.
Added more tests for list operations.
Fixed bugs and omissions found by tests.

http://dartbug.com/10042
http://dartbug.com/10112

Review URL: https://codereview.chromium.org//14425003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21867 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 11:13:17 +00:00
floitsch@google.com 1049521aaa Add setAll, insertAll, replaceRange and fillRange.
BUG=

Review URL: https://codereview.chromium.org//14175013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21471 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 16:25:21 +00:00
floitsch@google.com 759a366cea Remove insertRange.
Review URL: https://codereview.chromium.org//13956006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21464 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 15:20:16 +00:00
floitsch@google.com 9bfc844930 Refactor removeRange.
Review URL: https://codereview.chromium.org//13872007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21462 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 15:10:23 +00:00
floitsch@google.com bebe3ac2cd Refactor List.setRange function.
Review URL: https://codereview.chromium.org//13863012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21452 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 13:52:29 +00:00
ajohnsen@google.com 044f0d02eb Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove.
BUG=

Review URL: https://codereview.chromium.org//14173003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21338 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-12 09:34:52 +00:00
floitsch@google.com aecbeabcac Implement getRange (returning an Iterable).
Review URL: https://codereview.chromium.org//14065011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21281 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 14:14:29 +00:00
lrn@google.com f41508d33b Added new version of reduce.
Removed min/max and uses of min/max.

Review URL: https://codereview.chromium.org//14071002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21258 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 08:32:31 +00:00
floitsch@google.com 62358bf5e2 Make default argument to Iterable.join be "".
Review URL: https://codereview.chromium.org//13945009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21193 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-10 11:28:32 +00:00
lrn@google.com f8efe5b278 Fix typo in type parameter.
Review URL: https://codereview.chromium.org//14037002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21185 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-10 08:14:40 +00:00
lrn@google.com 6160e59850 Moving ListBase, FixedLengthListMixin and UmodifiableListMixin to collection.
Users can now create lists easily by extending these classes, just
as they can create iterables by extending Iterable.

Reduce the dependency of IterableMixinWorkaround outside of core/collection
implementations. I plan to move IterableMixinWorkaround to _collection-dev
before M4.

Review URL: https://codereview.chromium.org//13774006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21147 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-09 12:11:05 +00:00
floitsch@google.com bef8ebb5f6 Add Iterable.fold (and Stream.fold) which replace reduce.
For now this is just a copy. In a next step we will change the behavior of
`reduce`.

BUG= http://dartbug.com/9536

Review URL: https://codereview.chromium.org//13548002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20978 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-05 16:12:40 +00:00
lrn@google.com 3b13f62170 Remove addLast from List.
The List.addLast method has been deprecated for quite a while.
A recent change removed it from the interface, but left the
implementation in place (which caused some errors from the analyzer).
This removes it completely.

Review URL: https://codereview.chromium.org//13528004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20857 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-03 12:52:19 +00:00
lrn@google.com 844cd39fad Change getRange to sublist. Make getRange deprecated.
This changes the exception behavior of getRange. It used to accept
a length of zero, no matter what start value. Now the start value
must be a valid list index.

Review URL: https://codereview.chromium.org//12817003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20064 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-15 09:15:39 +00:00
floitsch@google.com 76d507cb6f Add List.insert.
BUG= http://dartbug.com/5375

Review URL: https://codereview.chromium.org//12383073

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20037 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 17:38:14 +00:00
floitsch@google.com 65718c56df Rename XMatching to XWhere.
For example firstMatching -> firstWhere.

BUG= http://dartbug.com/8664
BUG= http://dartbug.com/8337

Review URL: https://codereview.chromium.org//12537009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19880 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-12 17:34:49 +00:00
floitsch@google.com d91bca2813 Add List.asMap().
Review URL: https://codereview.chromium.org//12391046

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19399 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-04 16:57:52 +00:00
lrn@google.com f4300b84a2 Make List.from and Iterable.toList default to not growable.
Review URL: https://codereview.chromium.org//12401002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19391 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-04 14:55:40 +00:00
iposva@google.com 5c71abedff - Do not use the ? operator in the List factory.
Review URL: https://codereview.chromium.org//12335146

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19178 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 22:36:22 +00:00
lrn@google.com 6b4f4b1bab Change new List(n) to return fixed length list.
Deprecate List.fixedLength, add List.filled.

Make Iterable.toList and List.from take "growable" argument,
defaulting to false.

Review URL: https://codereview.chromium.org//12328104

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19112 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 08:45:04 +00:00
lrn@google.com 03f5a66836 Recommit changing List.skip/take/revert returns Iterable and remove mappedBy.
This reverts r18591.

Review URL: https://codereview.chromium.org//12295009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18615 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-18 10:35:51 +00:00
rnystrom@google.com 0e0473d33a Unbreak pub:
Revert "Make List.skip, List.take and List.reversed return Iterables, not Lists."

This reverts commit 44c3745a76acfad3d1d5bfc7a8b8c8e2def30e09.

Revert "Remove deprecated mappedBy."

This reverts commit 779ab69eab73e5e349245e99560b18955908e0cc.

BUG=dartbug.com/8560

Review URL: https://codereview.chromium.org//12286004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18591 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 18:38:42 +00:00
floitsch@google.com 0672317bec Remove deprecated mappedBy.
Committed: https://code.google.com/p/dart/source/detail?r=18575
Reverted: http://code.google.com/p/dart/source/detail?r=18576

Review URL: https://codereview.chromium.org//12212213

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18579 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 13:57:18 +00:00
floitsch@google.com ad839e6957 Revert "Remove deprecated mappedBy."
This reverts commit 18575.

Review URL: https://codereview.chromium.org//12207205

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18576 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 13:23:22 +00:00
floitsch@google.com b37100770b Remove deprecated mappedBy.
Review URL: https://codereview.chromium.org//12212213

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18575 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 13:18:17 +00:00
lrn@google.com b7f36d0d11 Make List.skip, List.take and List.reversed return Iterables, not Lists.
Removes ListView. It was premature optimization to have classes that combined any sequence of reverse, skip and take instead of just wrapping iterables.

Review URL: https://codereview.chromium.org//12262037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18570 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 10:43:21 +00:00
lrn@google.com 2a7fb1c733 Added expand method to iterables.
Review URL: https://codereview.chromium.org//12188011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18123 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-05 09:48:05 +00:00
lrn@google.com 0d91963a1c Added MappedListIterable/Iterator to implement map() on Lists.
Review URL: https://codereview.chromium.org//12094103

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18036 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-04 09:30:36 +00:00
lrn@google.com 9b23dff467 Reapply "Rename mappedBy to map."
This reverts commit r17907.

TBR.

Review URL: https://codereview.chromium.org//12090093

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17918 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-31 15:12:56 +00:00
floitsch@google.com b1a118d5ce Revert "Rename mappedBy to map."
This reverts commit 17899.

Review URL: https://codereview.chromium.org//12087103

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17907 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-31 14:02:27 +00:00
lrn@google.com 0dc2f4b1ba Rename mappedBy to map.
Retain a deprecated mappedBy for now.
Change return type of mappedBy, skip and take on List to Iterable.

BUG= http://dartbug.com/8063
BUG= http://dartbug.com/8064
BUG= http://dartbug.com/6739
BUG= http://dartbug.com/7982

Review URL: https://codereview.chromium.org//12086062

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17899 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-31 12:37:13 +00:00
lrn@google.com 16795f22d1 Add List.reversed to give a reverse fixed-length view of a list.
Review URL: https://codereview.chromium.org//11896013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17402 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-22 14:56:45 +00:00
floitsch@google.com 0108e97dc6 Move sort to collection-dev and remove coreSort.
Review URL: https://codereview.chromium.org//11960005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17296 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-18 17:21:16 +00:00
lrn@google.com 0e934a631e Add methods to Collection.
Methods are:
- void add(E)
- void addAll(Iterable<E>)
- void remove(Object)
- void removeAll(Iterable)
- void retainAll(Iterable)
- void removeMatching(bool test(E))
- void retainMatching(bool test(E))

They have been implemented for List and Set only.

Default implementations of removeX methods in Collections assume an efficient
remove method, which Lists won't have.

Review URL: https://codereview.chromium.org//11931034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17257 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-18 10:13:51 +00:00
floitsch@google.com 6dcfe3ca41 Create IterableMixinWorkaround and move most of the Collections methods there.
Committed: https://code.google.com/p/dart/source/detail?r=17207
Reverted: https://code.google.com/p/dart/source/detail?r=17210

Review URL: https://codereview.chromium.org//11971016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17213 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-17 14:36:40 +00:00
floitsch@google.com 7ca573ae90 Revert "Create IterableMixinWorkaround and move most of the Collections methods there."
This reverts commit 17207.

Review URL: https://codereview.chromium.org//11956039

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17210 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-17 14:19:47 +00:00
floitsch@google.com e0459f6d6e Create IterableMixinWorkaround and move most of the Collections methods there.
Review URL: https://codereview.chromium.org//11971016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17207 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-17 14:01:52 +00:00
floitsch@google.com d95bad9312 Let list-classes call Collections.joinList (which avoids allocating an iterator).
Review URL: https://codereview.chromium.org//11906002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17118 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-16 08:29:11 +00:00
floitsch@google.com 4a7dfd2da3 Big merge from experimental to bleeding edge.
Review URL: https://codereview.chromium.org//11783009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16687 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-07 11:23:16 +00:00