Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
rex4539 committed Feb 4, 2024
1 parent 427083e commit ab744af
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 99 deletions.
2 changes: 1 addition & 1 deletion Sources/DequeModule/_UnsafeWrappedBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ extension _UnsafeMutableWrappedBuffer {
// Note: Array._copyContents traps when not given enough space, so we
// need to check if we have enough contiguous space available above.
//
// FIXME: Add suppport for segmented (a.k.a. piecewise contiguous)
// FIXME: Add support for segmented (a.k.a. piecewise contiguous)
// collections to the stdlib.
var (it, copied) = elements._copyContents(initializing: first)
if copied == first.count, let second = second {
Expand Down
2 changes: 1 addition & 1 deletion Sources/HashTreeCollections/HashNode/_UnsafePath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ extension _RawHashNode {
}
distance += c
}
// See if the target is hiding somwhere in our immediate items.
// See if the target is hiding somewhere in our immediate items.
distance &+= $0.itemCount
if distance >= 0 {
path.selectItem(at: _HashSlot(distance))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension TreeSet: ExpressibleByArrayLiteral {
/// Do not call this initializer directly. It is used by the compiler when
/// you use an array literal. Instead, create a new persistent set using an
/// array literal as its value by enclosing a comma-separated list of values
/// in square brackets. You can use an array literal anywhere a peristent set
/// in square brackets. You can use an array literal anywhere a persistent set
/// is expected by the type context.
///
/// Like the standard `Set`, persistent sets do not preserve the order of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension _HashTable {
/// table. This is a convenient tool for implementing linear probing.
///
/// Beyond merely providing bucket values, bucket iterators can also tell
/// you their current oposition within the hash table, and (for mutable hash
/// you their current opposition within the hash table, and (for mutable hash
/// tables) they allow you update the value of the currently visited bucket.
/// (This is useful when implementing simple insertions, for example.)
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OrderedCollections/OrderedSet/OrderedSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ import _CollectionsUtilities
/// The hash table in an ordered set never needs to store larger indices than
/// the current size of the storage array, and `OrderedSet` makes use of this
/// observation to reduce the number of bits it uses to encode these integer
/// vaues. Additionally, the actual hashed elements are stored in a flat array
/// values. Additionally, the actual hashed elements are stored in a flat array
/// value rather than the hash table itself, so they aren't subject to the hash
/// table's strict maximum load factor. These two observations combine to
/// optimize the memory utilization of `OrderedSet`, sometimes making it even
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension BigString._Chunk: CustomStringConvertible {

func _succinctContents(maxLength c: Int) -> String {
/// 4+"short"-1
/// 0+"longer...tring"-1
/// 0+"longer...string"-1
let pc = String(prefixCount)._lpad(to: 3)
let sc = String(suffixCount)

Expand Down
2 changes: 1 addition & 1 deletion Sources/RopeModule/Rope/Basics/RopeMetric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public protocol RopeMetric<Element>: Sendable {
///
/// - Parameter offset: An integer offset from the start of `element` in this
/// metric, not exceeding `size(of: element.summary)`.
/// - Parameter element: An arbitary rope element.
/// - Parameter element: An arbitrary rope element.
/// - Returns: The index addressing the desired position in the input element.
func index(at offset: Int, in element: Element) -> Element.Index
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// This contains `_BTree`'s general implementation of BidirectionalCollection.
// These operations are bounds in contrast to most other methods on _BTree as
// they are designed to be easily propogated to a higher-level data type.
// they are designed to be easily propagated to a higher-level data type.
// However, they still do not perform index validation

extension _BTree: BidirectionalCollection {
Expand Down
8 changes: 4 additions & 4 deletions Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension _BTree {
/// The depth at which the last instance of sequential unique nodes starting at the root was found.
///
/// In the following path where 'U' denotes a unique node, and 'S' denotes a shared node. The value
/// of this parameter would be '1' indicating the second level of the tre.
/// of this parameter would be '1' indicating the second level of the tree.
///
/// ┌─┐
/// │U├─┐
Expand Down Expand Up @@ -189,7 +189,7 @@ extension _BTree {
// Update the bottom-most node
var (node, result) = try self.updateNode(atDepth: path.depth - 1, body)

// Start the node above the bottom-most node, and propogate up the change
// Start the node above the bottom-most node, and propagate up the change
var depth = path.depth - 2
while depth >= 0 {
if depth > lastUniqueDepth {
Expand Down Expand Up @@ -258,7 +258,7 @@ extension _BTree {
/// - element: A new key-value element to insert.
/// - capacity: Capacity of new internal nodes created during insertion.
/// - Returns: The new root object which may equal in identity to the previous one.
/// - Warning: Doesn not check sortedness invariant
/// - Warning: Does not check sortedness invariant
/// - Complexity: O(`log n`). Ascends the tree once
@inlinable
internal mutating func insertElement(
Expand All @@ -272,7 +272,7 @@ extension _BTree {
handle.insertElement(element, withRightChild: nil, atSlot: slot)
}

// Start the node above the bottom-most node, and propogate up the change
// Start the node above the bottom-most node, and propagate up the change
var depth = path.depth - 2
while depth >= 0 {
let (newNode, _) = self.updateNode(atDepth: depth) { (handle, slot) in
Expand Down
58 changes: 29 additions & 29 deletions Sources/SortedCollections/BTree/_BTree.Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
extension _BTree {
/// Provides an interface for efficiently constructing a filled B-Tree from sorted data.
///
/// A builder supports duplicate keys, in which case they are inserted in the same order they are recieved.
/// A builder supports duplicate keys, in which case they are inserted in the same order they are received.
/// However, is the `deduplicating` parameter is passed as `true`, operations will silently drop
/// duplicates.
///
/// This type has a few advantages when constructing a B-Tree over other approaches such as manually
/// inserting each element or using a cursor:
///
/// This works by maintaing a list of saplings and a view of the node currently being modified. For example
/// This works by maintaining a list of saplings and a view of the node currently being modified. For example
/// the following tree:
///
/// ┌─┐
Expand Down Expand Up @@ -49,21 +49,21 @@ extension _BTree {
/// └─┘ └─┘
///
/// ┌─┐ ┌─┐
/// Seperators: │D│ │F│
/// Separators: │D│ │F│
/// └─┘ └─┘
///
/// While the diagrams above represent a binary-tree, the representation of a B-Tree in the builder is
/// directly analogous to this. By representing the state this way. Append operations can be efficiently
/// performed, and the tree can also be efficiently reconstructed.
///
/// Appending works by filling in a seedling, once a seedling is full, and an associated seperator has been
/// provided, the seedling-seperator pair can be appended to the stack.
/// Appending works by filling in a seedling, once a seedling is full, and an associated separator has been
/// provided, the seedling-separator pair can be appended to the stack.
@usableFromInline
internal struct Builder {
@usableFromInline
enum State {
/// The builder needs to add a seperator to the node
case addingSeperator
/// The builder needs to add a separator to the node
case addingSeparator

/// The builder needs to try to append to the seedling node.
case appendingToSeedling
Expand All @@ -73,7 +73,7 @@ extension _BTree {
internal var _saplings: [Node]

@usableFromInline
internal var _seperators: [Element]
internal var _separators: [Element]

@usableFromInline
internal var _seedling: Node?
Expand Down Expand Up @@ -153,7 +153,7 @@ extension _BTree {
"Capacity must be greater than one")

self._saplings = []
self._seperators = []
self._separators = []
self.state = .appendingToSeedling
self._seedling = Node(withCapacity: leafCapacity, isLeaf: true)
self.leafCapacity = leafCapacity
Expand All @@ -162,26 +162,26 @@ extension _BTree {
self.lastKey = nil
}

/// Pops a sapling and it's associated seperator
/// Pops a sapling and it's associated separator
@inlinable
@inline(__always)
internal mutating func popSapling()
-> (leftNode: Node, seperator: Element)? {
-> (leftNode: Node, separator: Element)? {
return _saplings.isEmpty ? nil : (
leftNode: _saplings.removeLast(),
seperator: _seperators.removeLast()
separator: _separators.removeLast()
)
}

/// Appends a sapling with an associated seperator
/// Appends a sapling with an associated separator
@inlinable
@inline(__always)
internal mutating func appendSapling(
_ sapling: __owned Node,
seperatedBy seperator: Element
separatedBy separator: Element
) {
_saplings.append(sapling)
_seperators.append(seperator)
_separators.append(separator)
}

/// Appends a sequence of sorted values to the tree
Expand Down Expand Up @@ -209,8 +209,8 @@ extension _BTree {
}

switch state {
case .addingSeperator:
completeSeedling(withSeperator: element)
case .addingSeparator:
completeSeedling(withSeparator: element)
state = .appendingToSeedling

case .appendingToSeedling:
Expand All @@ -220,7 +220,7 @@ extension _BTree {
}

if _slowPath(isFull) {
state = .addingSeperator
state = .addingSeparator
}
}
}
Expand All @@ -231,7 +231,7 @@ extension _BTree {
/// further operate on.
@inlinable
internal mutating func completeSeedling(
withSeperator newSeperator: __owned Element
withSeparator newSeparator: __owned Element
) {
var sapling = Node(withCapacity: leafCapacity, isLeaf: true)
swap(&sapling, &self.seedling)
Expand All @@ -242,7 +242,7 @@ extension _BTree {
// bits
// - The stack has saplings of decreasing depth.
// - Saplings on the stack are completely filled except for their roots.
if case (var previousSapling, let seperator)? = self.popSapling() {
if case (var previousSapling, let separator)? = self.popSapling() {
let saplingDepth = sapling.storage.header.depth
let previousSaplingDepth = previousSapling.storage.header.depth
let previousSaplingIsFull = previousSapling.read({ $0.isFull })
Expand All @@ -260,7 +260,7 @@ extension _BTree {
// │ │
// previousSapling sapling
//
// We then use the seperator (B) to transform this into a subtree of a
// We then use the separator (B) to transform this into a subtree of a
// depth increase:
// ┌───┐
// │ B │ ◄─── sapling
Expand All @@ -273,12 +273,12 @@ extension _BTree {
// depth of our B-Tree increases
sapling = _Node(
leftChild: previousSapling,
seperator: seperator,
separator: separator,
rightChild: sapling,
capacity: internalCapacity
)
} else if saplingDepth + 1 == previousSaplingDepth && !previousSaplingIsFull {
// This is when we can append the node with the seperator:
// This is when we can append the node with the separator:
//
// ┌───┐
// │ B │ ◄─ previousSapling
Expand All @@ -288,7 +288,7 @@ extension _BTree {
// │ A │ │ C │ │ E │ ◄─ sapling
// └───┘ └───┘ └───┘
//
// We then use the seperator (D) to append this to previousSapling.
// We then use the separator (D) to append this to previousSapling.
// ┌────┬───┐
// │ B │ D │ ◄─ sapling
// ┌┴────┼───┴┐
Expand All @@ -297,7 +297,7 @@ extension _BTree {
// │ A │ │ C │ │ E │
// └───┘ └───┘ └───┘
previousSapling.update {
$0.appendElement(seperator, withRightChild: sapling)
$0.appendElement(separator, withRightChild: sapling)
}
sapling = previousSapling
} else {
Expand Down Expand Up @@ -327,11 +327,11 @@ extension _BTree {
// └───┘ └───┘ └───┘ └───┘ └───┘ └───┘
//
// We can string them together using the previous cases.
self.appendSapling(previousSapling, seperatedBy: seperator)
self.appendSapling(previousSapling, separatedBy: separator)
}
}

self.appendSapling(sapling, seperatedBy: newSeperator)
self.appendSapling(sapling, separatedBy: newSeparator)
}

/// Finishes building a tree.
Expand All @@ -344,11 +344,11 @@ extension _BTree {
var root: Node = seedling
_seedling = nil

while case (var sapling, let seperator)? = self.popSapling() {
while case (var sapling, let separator)? = self.popSapling() {
root = _Node.join(
&sapling,
with: &root,
seperatedBy: seperator,
separatedBy: separator,
capacity: internalCapacity
)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SortedCollections/BTree/_BTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal struct _BTree<Key: Comparable, Value> {
/// Creates an empty B-Tree which creates node with specified capacities
/// - Parameters:
/// - leafCapacity: The capacity of the leaf nodes. This is the initial buffer used to allocate.
/// - internalCapacity: The capacity of the internal nodes. Generally prefered to be less than
/// - internalCapacity: The capacity of the internal nodes. Generally preferred to be less than
/// `leafCapacity`.
@inlinable
@inline(__always)
Expand All @@ -115,7 +115,7 @@ internal struct _BTree<Key: Comparable, Value> {
)
}

/// Creates a B-Tree rooted at a specific nodey
/// Creates a B-Tree rooted at a specific node
/// - Parameters:
/// - root: The root node.
/// - internalCapacity: The key capacity of new internal nodes.
Expand Down Expand Up @@ -231,7 +231,7 @@ extension _BTree {
}
}

// MARK: Removal Opertations
// MARK: Removal Operations
extension _BTree {
/// Removes the element of a tree at a given offset.
///
Expand Down Expand Up @@ -561,7 +561,7 @@ extension _BTree {

}

// MARK: Immutable Operatoins
// MARK: Immutable Operations
extension _BTree {
@inlinable
@inline(__always)
Expand Down
4 changes: 2 additions & 2 deletions Sources/SortedCollections/BTree/_Node.Splinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension _Node {
self.rightChild = rightChild
}

/// The former median element which should be propogated upward.
/// The former median element which should be propagated upward.
@usableFromInline
internal let element: Element

Expand All @@ -42,7 +42,7 @@ extension _Node {
) -> _Node {
return _Node(
leftChild: leftChild,
seperator: element,
separator: element,
rightChild: rightChild,
capacity: capacity
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SortedCollections/BTree/_Node.Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ extension _Node {
/// storage class is indeed unique. Generally this is the wrong function to call, and should only be used
/// when the callee has created and is guaranteed to be the only owner during the execution of the
/// update callback, _and_ it has been identified that ``_Node.update(_:)`` or other alternatives
/// result in noticable slow-down.
/// result in noticeable slow-down.
///
/// - Parameter body: A closure with a handle which allows interacting with the node
/// - Returns: The value the closure body returns, if any.
Expand Down
Loading

0 comments on commit ab744af

Please sign in to comment.