Commit Graph

51 Commits

Author SHA1 Message Date
Ben Cohen
df2307e035 [stdlib][DNM] Collapse sequence and collection wrappers (#20221)
* Concretize dropFirst/Last/sufix/prefix from Sequence

Remove split customization point

Eliminate SubSequence from Sequence protocol

Collapse LazyCollection

Collapse LazyMapCollection

Eliminate _SequenceWrapper

Collapse LazyFilterCollection

Collapse LazyDrop/PrefixWhileCollection

Fix tests, ABI stability update

Collapse FlattenSequence

* Add entries to source/ABI compatible expected results.

* Update tests to avoid pre-10.14 objc runtime bug

* Expunge _preprocessingPass
2018-11-14 10:05:58 -08:00
Nate Cook
dfb01b6a6a [stdlib] Minor documentation revisions (#20045)
* [stdlib] Minor documentation revisions
* [docs] Convert 'nonoptional' to 'non-optional'
We're switching to 'non-optional' across the board, as the unhyphenated
form is too easy to read as 'no-noptional'.
2018-10-26 00:05:45 -05:00
Ben Cohen
dd2f3b4386 [stdlib] More inalienable auditing (#18925)
* Removing FIXME from methods also marked always/never

* Unavailable/deprecated things don't need inlining

* Trivial implementations

* Enum namespaces

* Unsafe performance of opaque/raw pointer

* Dump doesn't need to be fast

* Error paths shouldn't require inlining

* Consistency with surrounding code

* Lazy performance needs specialization
2018-08-23 18:52:21 -07:00
Ben Cohen
a4230ab2ad [stdlib] Update stdlib to 4.0 and reorganize compatibility shims (#17580)
* Update stdlib to 4.0 and move all compatibility shims into a dedicated source file
2018-06-29 06:26:52 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Max Moiseev
2670874072 [stdlib] Only deprecate flatMap starting with Swift 4.1
Fixes: https://bugs.swift.org/browse/SR-6970 and rdar://problem/37393816
2018-02-13 13:47:58 -08:00
Max Moiseev
aceb63e058 [stdlib] Improve the flatMap deprecation message
<rdar://problem/36555646>
2018-01-19 15:29:46 -08:00
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00
Max Moiseev
6f7aecd030 [stdlib] Introduce filterMap and deprecate one flatMap variant
This is the implementation of
[SE-0187](https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md)

<rdar://problem/34918180>
2017-12-18 09:16:37 -08:00
Max Moiseev
c27b366f46 [stdlib] Utilize conditional conformances for FlattenCollection (#13476)
* [stdlib] Utilize conditional conformances for FlattenCollection

* Fix indentation [NFC]
2017-12-16 10:57:02 -08:00
Max Moiseev
1f78f3927b [stdlib] Conditional conformances for LazyMapCollection
(cherry picked from commit b927254564)
2017-12-11 10:46:30 -08:00
Max Moiseev
ea02806f28 [stdlib] Conditional conformances for LazyFilterCollection
(cherry picked from commit 833721a172)
2017-12-11 10:46:25 -08:00
Graydon Hoare
62a6b74ad1 Revert "[stdlib] Conditional conformances for Lazy[Filter|Map]Collection" 2017-12-10 12:48:36 -08:00
Max Moiseev
b927254564 [stdlib] Conditional conformances for LazyMapCollection 2017-12-08 12:52:12 -08:00
Max Moiseev
833721a172 [stdlib] Conditional conformances for LazyFilterCollection 2017-12-08 12:52:12 -08:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Doug Gregor
388f0c505e [Stdlib] Eliminate explicit constraints made redundant by inferred ones. 2017-03-22 17:35:12 -07:00
Doug Gregor
13c4ae0168 [Standard library] Eliminate redundant conformance constraints.
Eliminate all of the redundant conformance constraints in the standard
library that were identified by the newly-introduced warning for
redundant, explicitly-specified conformances.
2017-03-17 20:15:09 -10:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Nate Cook
3bc4909de8 [stdlib] Various revisions and fixes for documentation
- Fix wording for RandomAccessCollection
- Add note about array growth to reserveCapacity(_:)
- Reformat lazy flatMap discussions
- Improve Collection symbol consistency
2016-12-15 11:47:19 -06:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Michael Ilseman
ccda8f33d1 [noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation
test suite, and tests. This will be necessary as soon as noescape is
the default for closure parameters.
2016-07-29 13:48:07 -07:00
Jacob Bandes-Storch
039ad2bf09 [stdlib] Rename flatten() to joined() (SE-0133) 2016-07-27 23:19:31 -07:00
Rintaro Ishizaki
668b9dbc64 [stdlib] Apply tail style "where" clause to stdlib/public/core 2016-06-02 12:00:55 +09:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
Russ Bishop
7dc71d0d96 Rename generic arguments 2016-05-11 13:44:37 -07:00
Russ Bishop
b7329df146 Cleanup comments for flatMap overloads 2016-05-11 00:27:59 -07:00
Russ Bishop
408e8c738b Remove RandomAccess overloads and types 2016-05-11 00:27:59 -07:00
Russ Bishop
1afa93b646 [stdlib] SR-361: Implement SE008: Add Lazy flatMap for Seq of Optionals
https://bugs.swift.org/browse/SR-361

Adds required LazyFilterRandomAccessCollection and the flatMap extensions.
2016-05-10 02:42:57 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Dmitri Gribenko
955f4144be New indexing model: fix lazy flatMap() 2016-03-09 20:41:58 -08:00
Dmitri Gribenko
ad1428e1d6 New collection indexing model: removed old index protocols
... and started to fix compiler errors.
2016-03-06 01:53:34 -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
ken0nek
e7e70cea92 Add spaces before and after closure arrow in stdlib 2015-12-23 04:52:15 +09:00
Dmitri Gribenko
156d29a2af flatMap(): generic type parameter Intermediate => SegmentOfResult 2015-12-17 17:07:21 -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
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08: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
David Farler
7a49dda2c8 Add @warn_unused_result to map, flatMap, and filter
rdar://problem/21971932

Swift SVN r30849
2015-07-31 05:15:10 +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
Dave Abrahams
b184e6df59 [stdlib] Document complexity of flatMaps
Swift SVN r30470
2015-07-21 22:35:38 +00:00
Dave Abrahams
2088a71259 [stdlib] Document the lazy flatMaps
Swift SVN r30467
2015-07-21 22:01:24 +00:00