         self.previous = nil
         self.intersectionInfo.neighbor = nil
     }
-}
-
-extension Vertex: Equatable {
-    public static func == (left: Vertex, right: Vertex) -> Bool {
+
+    static func == (left: Vertex, right: Vertex) -> Bool {
         return left === right
     }
 }

    }
}

internal class Vertex {
    public var location: CGPoint
    public let isIntersection: Bool
    // pointers must be set after initialization

    public struct IntersectionInfo {
        public var isEntry: Bool = false
        public var isExit: Bool = false
        public weak var neighbor: Vertex?
    }
    public var intersectionInfo: IntersectionInfo = IntersectionInfo()

    public var isCrossing: Bool {
        guard let neighborInfo = self.intersectionInfo.neighbor?.intersectionInfo else {
            return false
        }
        return self.isIntersection && (self.intersectionInfo.isEntry || self.intersectionInfo.isExit) && (neighborInfo.isEntry || neighborInfo.isExit)
    }

    internal struct SplitInfo {
        var t: CGFloat
    }
    internal var splitInfo: SplitInfo? // non-nil only when vertex is inserted by splitting an element

    public private(set) var next: Vertex! = nil
    public private(set) weak var previous: Vertex! = nil
    public private(set) var nextTransition: VertexTransition! = nil

    public func setNextVertex(_ vertex: Vertex, transition: VertexTransition) {
        self.next = vertex
        self.nextTransition = transition
    }

    public func setPreviousVertex(_ vertex: Vertex) {
        self.previous = vertex
    }


        list[elementIndex] = v
    }

    private func insertIntersectionVertex(_ v: Vertex, between start: Vertex, and end: Vertex, at t: CGFloat, for element: BezierCurve) {
        assert(start !== end)
        assert(v.isIntersection)
        v.splitInfo = Vertex.SplitInfo(t: t)
