Trees

  • A value-semantic, immutable Tree structure with two generic types for the branches and leaves.

    Example Usage

    A Tree can be used in pretty simple cases:

    let justALeaf: Tree<(),Double> = .leaf(3.14159265359)
    

    Or more nested cases:

    let happyTree = Tree.branch("alpha", [
        .leaf(1),
        .branch("beta", [
            .leaf(2),
            .leaf(3),
            .leaf(4)
        ]),
        .leaf(5),
        .branch("gamma", [
            .leaf(6),
            .branch("delta", [
                .leaf(7),
                .leaf(8)
            ])
        ])
    ])
    
    See more

    Declaration

    Swift

    public enum Tree<Branch, Leaf>
    extension Tree: CustomStringConvertible
    extension Tree: Equatable where Leaf: Equatable, Branch: Equatable
    extension Tree: Hashable where Leaf: Hashable, Branch: Hashable
  • Implements a priority queue where minimum values have highest priority.

    See more

    Declaration

    Swift

    public struct BinaryHeap<Element, Value> where Element : Hashable, Value : Comparable
  • Undocumented

    See more

    Declaration

    Swift

    public enum BinarySearchTree<Value> where Value : Comparable
    extension BinarySearchTree: ExpressibleByArrayLiteral
  • Copy-on-write self-balancing binary search tree.

    See more

    Declaration

    Swift

    public struct AVLTree<Key, Value> where Key : Comparable
    extension AVLTree: ExpressibleByArrayLiteral
    extension AVLTree: Equatable where Value: Equatable
  • Mutable Tree structure.

    See more

    Declaration

    Swift

    public class ReferenceTree
  • Interface for nodes in tree structures.

    Provides default implementations for many tree structure operations.

    Useable only by final class types.

    See more

    Declaration

    Swift

    public protocol ReferenceTreeProtocol : AnyObject