Open bshafiee opened 1 year ago
hello @bshafiee,
i didn't expect a heterogenous tree structure with different types being compared would be a common use case. Potentially this could cause a lot of confusion.
Why don't you handle it on the client side?
I.e. you could have
struct MetaNode: KDTreePoint
point: Either<CGPoint, OtherPoint>
func squaredDistance(to otherPoint: Self) -> Double {
switch self {
...
}
Assuming the common definition many people use for Either<A, B>
Hi, Thanks for creating this awesome library. Would it be Possible to extend the protocol to support any KDTreePoint implemented type? What I mean is that, currently the protocol expect the same type for distance comparision:
This is okay but very limiting, imagine my nodes have this structure:
if I create my tree with Node, I am forced always to query it with a
Node
as well, but if you would have relaxed the Protocol to:then I could extend both Node and CGPoint and do my queries with a tiny CGPoint (albeit handling the type check in the distance function etc.). I know this is a convenience but figured mention it. Thank you!