Commit Graph

39 Commits

Author SHA1 Message Date
Dmitri Gribenko
f0633ce5a9 stdlib: Sequence.iterator() => .makeIterator() 2016-02-23 13:52:30 -08:00
Dmitri Gribenko
3d3d4540e1 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-20 14:37:49 -08:00
Max Moiseev
78ba5d5f3f [stdlib] Requires in comments changed to Precondition 2016-02-19 18:57:26 -08:00
practicalswift
401fe4e577 [gardening] Remove redundant assignment: "var foo: Foo? = nil" → "var foo: Foo?" 2016-02-19 19:09:08 +01:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Nate Cook
51251dc133 Convert imperative function summaries to present.
i.e., "Return ..." -> "Returns ..."
2016-02-12 04:20:39 -06:00
Nate Cook
f3c4e0ac74 Remove style on *generator* and friends. 2016-02-12 04:20:01 -06:00
Nate Cook
32f81e8238 Add missing abstracts for types and protocols. 2016-02-11 11:47:27 -06:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
practicalswift
ca9e488f30 [gardening] Add "-*- swift -*-" to *.swift.gyb. Remove from *.swift. 2016-01-23 10:27:03 +01:00
Dmitri Gribenko
9bcd5a1056 Collection.length => .count 2016-01-22 18:41:19 -08:00
Dmitri Gribenko
574052f1be stdlib: standardize fatalError() messages for unavailable APIs 2016-01-21 16:34:54 -08:00
Max Moiseev
86680ec622 [stdlib] @available attributes for removed APIs 2016-01-20 13:08:27 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Kevin Ballard
dee1c7a05c [Stdlib] Add notes to lazy collection doc comments about complexity
Many lazy collections don't offer O(1) performance for `startIndex`,
`first`, or any method that depends on `startIndex`.
`LazyFilterCollection` already had a note to this effect (which I
tweaked a bit), but `FlattenCollection` didn't.

Related to SR-425.
2015-12-31 13:35:52 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Chris Lattner
66f7ef1295 Move stdlib off ++ and -- 2015-12-21 18:07:36 -08:00
Max Moiseev
5ccc258f71 func underestimatedLength() => var underestimatedLength { get } 2015-12-18 16:22:24 -08:00
Max Moiseev
b3fcc5fefa underestimateLength() => underestimatedLength() 2015-12-18 16:22:24 -08:00
Maxim Moiseev
9e50505970 internal or public // @testable initializers 2015-12-17 17:02:49 -08:00
Dmitri Gribenko
73ce9ae7e9 Collection.count => .length
And other API changes that naturally fall out from this, like
Array(repeating:count:) => Array(repeating:length:).
2015-12-17 15:55:29 -08:00
Maxim Moiseev
6b7fc91beb LazySequenceType => LazySequenceProtocol 2015-12-10 17:00:08 -08:00
Maxim Moiseev
844b81c46b SequenceType => Sequence 2015-12-09 17:16:56 -08:00
Maxim Moiseev
c678a839dc IndexType => Index 2015-12-09 17:16:42 -08:00
Maxim Moiseev
01e1a7bd52 LazyCollectionType => LazyCollectionProtocol 2015-12-09 17:16:22 -08:00
Maxim Moiseev
7e2466c14e CollectionType => Collection 2015-12-09 17:12:48 -08:00
Dmitri Gribenko
1c0047829a Rename SequenceType.generate() to SequenceType.iterator() 2015-12-09 17:11:17 -08:00
Dmitri Gribenko
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08:00
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Dmitri Hrybenko
f57947a7e0 stdlib: fix capitalization issues in documentation comments
Patch by Nate Cook.

rdar://22054901

Swift SVN r32226
2015-09-25 17:13:54 +00:00
Dmitri Hrybenko
dd3194a18c stdlib: adopt @warn_unused_result
rdar://20957486

Swift SVN r31048
2015-08-06 14:53:18 +00:00
Dave Abrahams
ad43a596bd [stdlib] Retire the old lazy subsystem...
...replacing it with the new, after passing API review!

* The lazy free function has become a property.

* Before we could extend protocols, we lacked a means for value types to
  share implementations, and each new lazy algorithm had to be added to
  each of up to four types: LazySequence, LazyForwardCollection,
  LazyBidirectionalCollection, and LazyRandomAccessCollection. These
  generic adapters hid the usual algorithms by defining their own
  versions that returned new lazy generic adapters. Now users can extend
  just one of two protocols to do the same thing: LazySequenceType or
  LazyCollectionType.

* To avoid making the code duplication worse than it already was, the
  generic adapters mentioned above were used to add the lazy generic
  algorithms around simpler adapters such as MapSequence that just
  provided the basic requirements of SequenceType by applying a
  transformation to some base sequence, resulting in deeply nested
  generic types as shown here. Now, MapSequence is an instance of
  LazySequenceType (and is renamed LazyMapSequence), and thus transmits
  laziness to its algorithms automatically.

* Documentation comments have been rewritten.

* The .array property was retired

* various renamings

* A bunch of Gyb files were retired.

Swift SVN r30902
2015-08-01 03:52:13 +00:00
Dave Abrahams
f37d607a13 Revert "stdlib: remove FlattenCollection -- it does not model CollectionType properly."
Actually we hadn't nailed down the indexing model sufficiently; now we
have.

This reverts r30617.

Swift SVN r30694
2015-07-27 19:33:15 +00:00
Dmitri Hrybenko
78222237e0 stdlib: remove FlattenCollection -- it does not model CollectionType properly.
An index of a FlattenCollection is composed of two: an index to the
current chunk and an index within that chunk.  So you take the
startIndex, and advance it to the second chunk; call the result idx1.
You take startIndex again, and advance it the same number of steps; call
the result idx2:

let idx1 = flatMapCollection.startIndex.advancedBy(10)
let idx2 = flatMapCollection.startIndex.advancedBy(10)

idx1 and idx2 have to compare equal according to collection and index
axioms.  But this can't be cheaply implemented.  Every index contains an
index into the inner collection.  So indices into two collections with
the same elements have to compare equal even though the collections
don't have any common history, they were merely created using the same
sequence of steps.

What currently happens is that you get random results depending on the
underlying collection kind.

rdar://21989896

Swift SVN r30617
2015-07-25 02:18:13 +00:00
Dmitri Hrybenko
739cceba3d stdlib: lazy FlattenCollection: don't invoke the closure as frequently
FlattenCollection used to evaluate the closure three times per element.
That's acceptable from the technical standpoint, given its lazy
semantics, but not acceptable in practice.  This commit fixes it to only
evaluate it two times when it is converted into an array.

This commit also improves tests.  The new checks used to fail before the
standard library was fixed.

But there are larger issues with FlattenCollection -- it does not model
CollectionType properly.  See next commit.

Swift SVN r30616
2015-07-25 02:18:12 +00:00
Dave Abrahams
6be395d638 [stdlib] Documentation touch-ups for flatten
Swift SVN r30471
2015-07-21 22:35:39 +00:00
Dave Abrahams
cc1ee51cc5 [stdlib] Make new Reverse*Collection not drop laziness
We used to be only propagating laziness through reverse collections when
the base collection was a LazyCollection<T>, rather than all
LazyCollectionType's. Also updated the flatten tests to check for the
same issue.

Swift SVN r30367
2015-07-18 05:36:27 +00:00
Dave Abrahams
24f930ee67 [stdlib] Add ._prext_flatten for sequences-of-sequences
Swift SVN r30361
2015-07-18 02:58:36 +00:00