Skip to content
Permalink
Browse files

Merge pull request #5 from adamnemecek/master

* removed unneeded imports
  • Loading branch information...
mpangburn committed Feb 15, 2018
2 parents dbdc255 + d89ffb0 commit 626e44e3f736dc150ef6938693ee0d57e85a4678
Showing with 0 additions and 115 deletions.
  1. +0 −3 Sources/Expressions/ArithmeticExpression.swift
  2. +0 −3 Sources/Expressions/ExpressionNodeKind.swift
  3. +0 −3 Sources/Expressions/FloatingPointArithmeticExpression.swift
  4. +0 −3 Sources/Expressions/LogicalExpression.swift
  5. +0 −3 Sources/Expressions/Protocols/ArithmeticExpressionProtocol.swift
  6. +0 −3 Sources/Expressions/Protocols/Evaluatable.swift
  7. +0 −3 Sources/Expressions/Protocols/EvaluatableExpressionProtocol.swift
  8. +0 −3 Sources/Expressions/Protocols/LogicalExpressionProtocol.swift
  9. +0 −3 Sources/Extensions/Divisible.swift
  10. +0 −3 Sources/Extensions/Numeric.swift
  11. +0 −3 Sources/Operators/Binary/BinaryOperatorAssociativity.swift
  12. +0 −3 Sources/Operators/Binary/BinaryOperatorPrecedence.swift
  13. +0 −3 Sources/Operators/Binary/ComparativeOperator.swift
  14. +0 −3 Sources/Operators/Binary/LogicalBinaryOperator.swift
  15. +0 −3 Sources/Operators/Binary/NumericBinaryOperator.swift
  16. +0 −3 Sources/Operators/Binary/Protocols/BinaryOperatorProtocol.swift
  17. +0 −3 Sources/Operators/Binary/Protocols/ComparativeOperatorProtocol.swift
  18. +0 −3 Sources/Operators/Binary/Protocols/EquatableOperatorProtocol.swift
  19. +0 −2 Sources/Operators/Binary/Protocols/LogicalBinaryOperatorProtocol.swift
  20. +0 −3 Sources/Operators/Binary/Protocols/NumericBinaryOperatorProtocol.swift
  21. +0 −3 Sources/Operators/Binary/Protocols/ReferenceEquatableOperatorProtocol.swift
  22. +0 −3 Sources/Operators/OperatorNodeKind.swift
  23. +0 −3 Sources/Operators/Protocols/OperandProtocol.swift
  24. +0 −3 Sources/Operators/Protocols/OperatorProtocol.swift
  25. +0 −3 Sources/Operators/Unary/LogicalUnaryOperator.swift
  26. +0 −3 Sources/Operators/Unary/NumericUnaryOperator.swift
  27. +0 −3 Sources/Operators/Unary/Protocols/LogicalUnaryOperatorProtocol.swift
  28. +0 −3 Sources/Operators/Unary/Protocols/NumericUnaryOperatorProtocol.swift
  29. +0 −3 Sources/Operators/Unary/Protocols/UnaryOperatorProtocol.swift
  30. +0 −3 Sources/Trees/BinarySearchTree.swift
  31. +0 −3 Sources/Trees/NeverEmptyTreeNode.swift
  32. +0 −3 Sources/Trees/Protocols/BinarySearchTreeProtocol.swift
  33. +0 −3 Sources/Trees/Protocols/BinaryTreeProtocol.swift
  34. +0 −3 Sources/Trees/Protocols/NeverEmptyTreeProtocol.swift
  35. +0 −3 Sources/Trees/Protocols/SingleTypeBinaryTreeProtocol.swift
  36. +0 −3 Sources/Trees/Protocols/SingleTypeTreeProtocol.swift
  37. +0 −3 Sources/Trees/Protocols/TreeProtocol.swift
  38. +0 −3 Sources/Trees/RedBlackTree.swift
  39. +0 −2 Sources/Trees/TreeNode.swift
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// An arithmetic expression modeled as a binary tree.
/// For floating point operands, see FloatingPointArithmeticExpression.
public enum ArithmeticExpression<T: NumericOperandProtocol>: ArithmeticExpressionProtocol {
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// The kind of an expression node--either an operand, a unary operator, or a binary operator.
public enum ExpressionNodeKind<UnaryOperator: UnaryOperatorProtocol, BinaryOperator: BinaryOperatorProtocol> where UnaryOperator.Operand == BinaryOperator.Operand {
public typealias Operand = UnaryOperator.Operand
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


// Once we have conditional conformance, FloatingPointArithmeticExpression need no longer exist!
/* extension ArithmeticExpression: ExpressibleByFloatLiteral where Operand: FloatingPoint & _ExpressibleByBuiltinFloatLiteral { } */

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// An expression of boolean logic.
//public typealias LogicalExpression = LogicalExpression<LogicalUnaryOperator, LogicalBinaryOperator>
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A type representing an arithmetic expression.
public protocol ArithmeticExpressionProtocol: EvaluatableExpressionProtocol, Numeric where UnaryOperator: NumericUnaryOperatorProtocol, BinaryOperator: NumericBinaryOperatorProtocol { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A type that can be evaluated.
public protocol Evaluatable {
/// The result of the evaluation.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import UIKit


/// A type representing an evaluatable expression, e.g. arithmetic or logical.
public protocol EvaluatableExpressionProtocol: CustomPlaygroundQuickLookableBinaryTreeProtocol, NeverEmptyTreeProtocol, Evaluatable, CustomStringConvertible where Result == Leaf {

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A type representing a logical expression.
public protocol LogicalExpressionProtocol: EvaluatableExpressionProtocol, ExpressibleByBooleanLiteral where UnaryOperator: LogicalUnaryOperatorProtocol, BinaryOperator: LogicalBinaryOperatorProtocol { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import CoreGraphics


/// Declares the division operator and its mutating counterpart.
public protocol Divisible: Numeric {
static func / (lhs: Self, rhs: Self) -> Self
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


extension Numeric {
// Would expect these to have default implementations
public static func += (lhs: inout Self, rhs: Self) {
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// Contains the possible values for a binary operator's associativity,
/// which determines how operators of the same precedence are grouped in the absence of parentheses.
public enum BinaryOperatorAssociativity {
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// Contains the possible values for a binary operator's precedence,
/// which is used to determine the order of operations when combined with other operators.
/// c.f. https://developer.apple.com/documentation/swift/operator_declarations
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// An operator for comparing Comparable types.
public struct ComparativeOperator<T: Comparable>: ComparativeOperatorProtocol {
public typealias Operand = T
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator for performing boolean logic.
public struct LogicalBinaryOperator: LogicalBinaryOperatorProtocol {
public typealias Operand = Bool
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator for performing operations on Numeric types.
public struct NumericBinaryOperator<T: NumericOperandProtocol>: NumericBinaryOperatorProtocol {
public typealias Operand = T
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// An operator that performs an operation on exactly two operands.
public protocol BinaryOperatorProtocol: OperatorProtocol {
init(identifier: String, apply: @escaping (Operand, Operand) -> Result, precedence: BinaryOperatorPrecedence,
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator that operates on comparable types.
public protocol ComparativeOperatorProtocol: EquatableOperatorProtocol where Operand: Comparable { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator that operates on equatable types.
public protocol EquatableOperatorProtocol: BinaryOperatorProtocol where Operand: Equatable, Result == Bool { }

@@ -6,8 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator that applies boolean logic.
public protocol LogicalBinaryOperatorProtocol: BinaryOperatorProtocol where Operand == Bool, Result == Bool { }
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator that operates on numeric types.
public protocol NumericBinaryOperatorProtocol: BinaryOperatorProtocol where Operand: Numeric & _ExpressibleByBuiltinIntegerLiteral, Result == Operand { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary operator that operates on reference equatable types.
public protocol ReferenceEquatableOperatorProtocol: BinaryOperatorProtocol where Operand: AnyObject, Result == Bool { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// The kind of an operator node--either a unary or a binary operator.
public enum OperatorNodeKind<UnaryOperator: UnaryOperatorProtocol, BinaryOperator: BinaryOperatorProtocol> {
case unary(UnaryOperator)
@@ -6,8 +6,5 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


// This typealias parallels the Operand constraints for the Numeric Operator protocols
public typealias NumericOperandProtocol = Numeric & Comparable & _ExpressibleByBuiltinIntegerLiteral
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A type that can perform an operation on another.
public protocol OperatorProtocol: Equatable, CustomStringConvertible {
/// The type on which the operation is performed.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A unary operator for performing boolean logic.
public struct LogicalUnaryOperator: LogicalUnaryOperatorProtocol {
public typealias Operand = Bool
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A unary operator for performing arithmetic on numeric types.
public struct NumericUnaryOperator<T: Numeric>: NumericUnaryOperatorProtocol {
public typealias Operand = T
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A unary operator that applies boolean logic.
public protocol LogicalUnaryOperatorProtocol: UnaryOperatorProtocol where Operand == Bool, Result == Bool { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A unary operator for performing operations on Numeric types.
public protocol NumericUnaryOperatorProtocol: UnaryOperatorProtocol where Operand: Numeric, Result == Operand { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// An operator that performs an operation on a single operand.
public protocol UnaryOperatorProtocol: OperatorProtocol {
init(identifier: String, apply: @escaping (Operand) -> Result)
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A traditional non-self-balancing binary search tree.
public enum BinarySearchTree<Element: Comparable>: BinarySearchTreeProtocol {
case empty
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// The kind of a tree node--either a leaf node or a non-leaf node.
/// The enum case's associated value contains the node's data.
public enum NeverEmptyTreeNode<A, B> {
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary tree that subscribes to the following set of rules:
/// - Any node to a node's left is "less than" that node.
/// - Any node to a node's right is "greater than" that node.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A tree with at most two children.
public protocol BinaryTreeProtocol: TreeProtocol {
/// The node's left child.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A tree that cannot be empty.
public protocol NeverEmptyTreeProtocol: TreeProtocol {
/// The kind of a tree node--either a leaf node or a non-leaf node.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A binary tree whose leaf and non-leaf nodes contain values of the same type.
public protocol SingleTypeBinaryTreeProtocol: SingleTypeTreeProtocol, BinaryTreeProtocol { }

@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A tree whose leaf and non-leaf nodes contain values of the same type.
public protocol SingleTypeTreeProtocol: TreeProtocol where Leaf == Node {
/// The single type of element contained by the tree.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A tree whose leaf nodes and non-leaf nodes can hold values of different types.
public protocol TreeProtocol {
/// The type contained by the tree's leaf nodes.
@@ -6,9 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// A self-balancing binary search tree following traditional red-black tree rules.
public enum RedBlackTree<Element: Comparable>: BinarySearchTreeProtocol, SingleTypeTreeProtocol {
public enum Color { case red, black }
@@ -6,8 +6,6 @@
// Copyright © 2017 Michael Pangburn. All rights reserved.
//
import Foundation


/// The kind of a tree node--empty, a leaf node, or a non-leaf node.
/// In either node case, the associated value contains the node's data.

0 comments on commit 626e44e

Please sign in to comment.
You can’t perform that action at this time.