mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
Update docs
Final documentation pass
This commit is contained in:
5 files changed
+34
-34
No files matched your search
@@ -8,7 +8,7 @@ This currently consists of two noncopyable variants of the standard `Array` type
|
||||
|
||||
Unlike `Array`, these new types do not support copy-on-write value semantics -- indeed, they aren't (implicitly) copyable at all, even if their element type happens to be copyable.
|
||||
|
||||
### `struct UniqueArray`
|
||||
### struct UniqueArray
|
||||
|
||||
``UniqueArray`` is a dynamically self-resizing array type that automatically grows its storage as needed to accommodate inserted items. Its name highlights that unlike `Array`, instances of this type are always uniquely owned, never shared. Mutations of a `UniqueArray` therefore never need to copy their storage.
|
||||
|
||||
@@ -41,7 +41,7 @@ Note how preserving a copy of the array at the start of the loop forces the subs
|
||||
|
||||
Taking away the freedom to make implicit copies forces you to think a lot more about ownership concerns when using this type -- it can feel a lot more constrained and nitpicky. In exchange though, it gets much easier to reason about the runtime performance of your code; the subscript mutation looks the same as before, but now it is guaranteed to _always_ have constant complexity.
|
||||
|
||||
### `struct RigidArray`
|
||||
### struct RigidArray
|
||||
|
||||
``RigidArray`` goes a step even further than ``UniqueArray`` by also disabling automatic storage reallocations: it is a fixed-capacity array type. Rigid array instances get created with a specific capacity, and they never resize themselves. If they run out of room, they report a runtime error!
|
||||
|
||||
@@ -62,7 +62,7 @@ This allows ``RigidArray`` to still provide _explicit_ resizing operations: it h
|
||||
|
||||
## Topics
|
||||
|
||||
### Structures
|
||||
### Types
|
||||
|
||||
- ``UniqueArray``
|
||||
- ``RigidArray``
|
||||
@@ -79,7 +79,7 @@
|
||||
|
||||
- ``replaceSubrange(_:newCount:initializingWith:)``
|
||||
- ``replaceSubrange(_:moving:)-(_,OutputSpan<Element>)``
|
||||
- ``replaceSubrange(_:moving:)-(_,RigidArray<Element>))``
|
||||
- ``replaceSubrange(_:moving:)-(_,RigidArray<Element>)``
|
||||
- ``replaceSubrange(_:moving:)-(_,UnsafeMutableBufferPointer<Element>)``
|
||||
- ``replaceSubrange(_:consuming:)``
|
||||
- ``replaceSubrange(_:copying:)-(_,Collection<Element>)``
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Topics
|
||||
|
||||
### Creating a rigid array
|
||||
### Creating a Unique Array
|
||||
|
||||
- ``init()``
|
||||
- ``init(capacity:)``
|
||||
@@ -12,7 +12,7 @@
|
||||
- ``init(capacity:copying:)-(_,Sequence<Element>)``
|
||||
- ``init(capacity:copying:)-(_,Collection<Element>)``
|
||||
|
||||
### Inspecting a rigid array
|
||||
### Inspecting a Unique Array
|
||||
|
||||
- ``isEmpty``
|
||||
- ``isFull``
|
||||
@@ -27,13 +27,13 @@
|
||||
- ``endIndex``
|
||||
- ``indices``
|
||||
|
||||
### Accessing elements
|
||||
### Accessing Elements
|
||||
|
||||
- ``subscript(position:)``
|
||||
- ``swapAt(_:_:)``
|
||||
- ``edit(_:)``
|
||||
|
||||
### Memory management
|
||||
### Memory Management
|
||||
|
||||
- ``reallocate(capacity:)``
|
||||
- ``reserveCapacity(_:)``
|
||||
@@ -49,7 +49,7 @@
|
||||
- ``mutableSpan(after:)``
|
||||
- ``mutableSpan(before:)``
|
||||
|
||||
### Appending items
|
||||
### Appending Items
|
||||
|
||||
- ``append(_:)``
|
||||
- ``pushLast(_:)``
|
||||
@@ -62,7 +62,7 @@
|
||||
- ``append(copying:)-(UnsafeBufferPointer<Element>)``
|
||||
- ``append(copying:)-(UnsafeMutableBufferPointer<Element>)``
|
||||
|
||||
### Inserting items
|
||||
### Inserting Items
|
||||
|
||||
- ``insert(_:at:)``
|
||||
- ``insert(count:at:initializingWith:)``
|
||||
@@ -75,11 +75,11 @@
|
||||
- ``insert(copying:at:)-(UnsafeBufferPointer<Element>,_)``
|
||||
- ``insert(copying:at:)-(UnsafeMutableBufferPointer<Element>,_)``
|
||||
|
||||
### Replacing items
|
||||
### Replacing Items
|
||||
|
||||
- ``replaceSubrange(_:newCount:initializingWith:)``
|
||||
- ``replaceSubrange(_:moving:)-(_,OutputSpan<Element>)``
|
||||
- ``replaceSubrange(_:moving:)-(_,RigidArray<Element>))``
|
||||
- ``replaceSubrange(_:moving:)-(_,RigidArray<Element>)``
|
||||
- ``replaceSubrange(_:moving:)-(_,UnsafeMutableBufferPointer<Element>)``
|
||||
- ``replaceSubrange(_:consuming:)``
|
||||
- ``replaceSubrange(_:copying:)-(_,Collection<Element>)``
|
||||
@@ -87,7 +87,7 @@
|
||||
- ``replaceSubrange(_:copying:)-(_,UnsafeBufferPointer<Element>)``
|
||||
- ``replaceSubrange(_:copying:)-(_,UnsafeMutableBufferPointer<Element>)``
|
||||
|
||||
### Removing items
|
||||
### Removing Items
|
||||
|
||||
- ``removeAll()``
|
||||
- ``removeLast()``
|
||||
|
||||
Reference in new issue
Block a user