3
我試圖實現在C#中描述的here的Bentley-Ottmann算法。 特別是,我執行IComparable <T> 段類掃描線狀態結構的問題。段類列舉如下:Bentley-Ottmann算法的段類的IComparable實現
public class SweepLineSegment : IComparable<SweepLineSegment>
{
public int Edge { get; set; }
public PointF LeftmostVertexPoint { get; set; }
public PointF RightmostVertexPoint { get; set; }
public SweepLineSegment Above { get; set; }
public SweepLineSegment Below { get; set;}
public int CompareTo(SweepLineSegment other)
{
?????
}
}
我沒有清楚地瞭解我應該如何比較兩個片段,當我將它們添加到掃描線狀態結構?
是否有可能從Bentley-Ottmann算法中解耦您的問題?這樣做會使更多觀衆受益。 –
根據Bentley-Ottmann算法,跨越掃描線的線段保留在通常爲平衡二叉搜索樹(AVL樹,RB樹等)的結構中。我嘗試爲Segment類實現簡單的通用BST,但我需要知道Segment類的正確比較方法才能正確實現它。這種方法與算法密切相關,對我來說不是很清楚。 – GEO
所以你的問題只是簡單地說:「我如何比較兩個自定義對象(在這種情況下爲段)?」 –