Skip to content

Commit

Permalink
cleanup upper bound
Browse files Browse the repository at this point in the history
  • Loading branch information
davidreynolds committed Mar 14, 2015
1 parent 75f3d17 commit d21eee5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions s2/edgeindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion s2/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d21eee5

Please sign in to comment.