Commit Graph

4 Commits

Author SHA1 Message Date
Dave Abrahams
241f4e9b46 [stdlib] Avoid Suicide Sequences
In a naive implementation of a Sequence adapter, adapting a
non-self-destructive (multi-pass) Sequence having a reference-semantics
Generator produces a self-destructive adapted view.  This is technically
correct because Sequences are allowed to be self-destructive, and
theoretically every multi-pass Sequence would be a Collection.  However
Sequences are much easier to build than Collections, so users are likely
to make them, and it would be extremely surprising if adapting a
self-preserving Sequence yielded a self-destructive one.

Swift SVN r18350
2014-05-18 20:38:33 +00:00
Dave Abrahams
215da18af9 [stdlib] Publicize Map, add lazy map()
As declared, Dictionary's keys and values were private.  Instead of
hiding Map away as _Map, give it a "nice" verbose name and expose it
through a "nice" lowercase global function called map(), which we
overload so it works on both Collections and Sequences, returning a
Collection when that's what it started on.

We'll follow this pattern for filter, which was requested on Array.  The
implementation is easy once you have a lazy view!

Swift SVN r18340
2014-05-18 19:00:42 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Dave Abrahams
f4b04760c8 [stdlib] Add a lazy "Map" Collection
The name may have the wrong implication to a C++'er, but the point is
that this Collection is a Lazy version of the map() function.  Maybe we
should be giving our Collections capitalized lazy versions of their
member algorithms, e.g.

  a.Map {something}

Swift SVN r16110
2014-04-09 09:43:22 +00:00