I'm implementing the Ordering type according to the docs but I'm getting a missing method error. The docs don't say anything about needing to define iterate?
ERROR: LoadError: MethodError: no method matching iterate(::Type{BidOrdering})
using DataStructures
import Base.Ordering
import Base.lt
import DataStructures.eq
struct MBOBookEntity
orderid::Int64
price::String
orderPriority::Int64
displayQty::Int64
end
mutable struct MBOBook
bidBook::SortedSet{MBOBookEntity}
askBook::SortedSet{MBOBookEntity}
function MBOBook()
bidBook = SortedSet{MBOBookEntity}(BidOrdering)
askBook = SortedSet{MBOBookEntity}(AskOrdering)
new(bidBook, askBook)
end
end
struct BidOrdering <: Ordering end
struct AskOrdering <: Ordering end
lt(::BidOrdering, o1::MBOBookEntity, o2::MBOBookEntity) = begin
if o1.price == o2.price
return o1.orderPriority < o2.orderPriority
else
return o2.price < o1.price
end
end
eq(::BidOrdering, o1::MBOBookEntity, o2::MBOBookEntity) = isequal(o1.orderid, o2.orderid)
lt(::AskOrdering, o1::MBOBookEntity, o2::MBOBookEntity) = begin
if o1.price == o2.price
return o1.orderPriority < o2.orderPriority
else
return o1.price < o2.price
end
end
eq(::AskOrdering, o1::MBOBookEntity, o2::MBOBookEntity) = isequal(o1.orderid, o2.orderid)