From d21eee5e333604b7cd1852a668ca2854c3ed16e7 Mon Sep 17 00:00:00 2001 From: David Reynolds Date: Sat, 14 Mar 2015 00:26:06 -0700 Subject: [PATCH] cleanup upper bound --- s2/edgeindex.go | 8 +++++--- s2/loop.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/s2/edgeindex.go b/s2/edgeindex.go index bb54229..02d88f8 100644 --- a/s2/edgeindex.go +++ b/s2/edgeindex.go @@ -49,14 +49,16 @@ func (m *CellEdgeMultimap) Insert(ce CellEdge) { func (m *CellEdgeMultimap) LowerBound(id CellID) int { idx := sort.Search(m.Len(), func(k int) bool { - return uint64(m.items[k].cellId) >= uint64(id) + return m.items[k].cellId >= id }) return idx } func (m *CellEdgeMultimap) UpperBound(id CellID) int { - // XXX: Is this a good way to get the upper bound? - return m.LowerBound(id.Next()) + idx := sort.Search(m.Len(), func(k int) bool { + return m.items[k].cellId > id + }) + return idx } type EdgeIndexer interface { diff --git a/s2/loop.go b/s2/loop.go index 4f41bcd..046fd76 100644 --- a/s2/loop.go +++ b/s2/loop.go @@ -88,7 +88,7 @@ func NewLoopFromCell(cell Cell) *Loop { } func (l *Loop) IsValid() bool { - // Loops must have 3 vertices. + // Loops must have at least 3 vertices. if len(l.vertices) < 3 { return false }