- Proposal: SE-NNNN
- Authors: Daryle Walker, Author 2
- Review Manager: TBD
- Status: Awaiting review
This is a proposal to add a macro-like facility to automatically create lists.
// | |
// LeftOpenRange.swift | |
// NodeCollections | |
// | |
// Created by Daryle Walker on 4/6/18. | |
// Copyright © 2018 Daryle Walker. All rights reserved. | |
// | |
// MARK: Primary Definitions |
/// A singly-linked list. | |
public final class SinglyLinkedList<T>: RangeReplaceableCollection, MutableCollection { | |
/// A node for a singly-linked list. | |
final class Node { | |
/// The node's data. May be absent (like for sentinel nodes). | |
var value: T? | |
/// The link to the next node, or `nil` when none. | |
var next: Node! |
/* | |
BinaryInteger+Extensions.swift | |
Created by Daryle Walker on 1/29/18. | |
Copyright (c) 2018 Daryle Walker. | |
Distributed under the MIT License. | |
Various properties and methods for BitArray's bit-twiddling. |
// Copyright (c) 2018 Daryle Walker. | |
// Distributed under the MIT License. | |
// Based off <https://en.wikipedia.org/wiki/Calkin–Wilf_tree>. | |
// "fusc" from Edsger W. Dijkstra. | |
// To-Do: Add the iterative version of "fusc" | |
struct SternDiatomicSequenceIterator: IteratorProtocol { | |
var cache = [0: 0, 1: 1] |
This is a proposal to add a macro-like facility to automatically create lists.
During the review process, add the following fields as needed:
This proposal adds a nominal type whose structure is an existing value type and interface can be customized, including selective use of the original type's interface. It is equivalent to the type declaration feature in Go, newtype
in Haskell, and the oft-requested "strong typedef" in C(++).
During the review process, add the following fields as needed:
extension CollectionType { | |
func diverges<PossiblePrefix: CollectionType where PossiblePrefix.Generator.Element == Generator.Element>(from possiblePrefix: PossiblePrefix, isEquivalent: (Generator.Element, Generator.Element) throws -> Bool) rethrows -> (Index, PossiblePrefix.Index) { | |
var selfIndex = startIndex | |
var fromIndex = possiblePrefix.startIndex | |
while selfIndex != endIndex && fromIndex != possiblePrefix.endIndex { | |
let areEqual = try isEquivalent(self[selfIndex], possiblePrefix[fromIndex]) | |
guard areEqual else { | |
break | |
} |
import Foundation | |
/** | |
A generator for the distance between two adjacent elements from another generator. | |
*/ | |
public struct AdjacentDifferenceGenerator<Source: GeneratorType where Source.Element: Strideable>: GeneratorType { | |
/// The last value read, needed to calculate the difference | |
private var queue: (Source.Element?, Source.Element?) |