Skip to content

Commit

Permalink
Move multiless to missinggo
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Mar 3, 2019
1 parent 72db8ae commit 52b3a4e
Showing 1 changed file with 4 additions and 39 deletions.
43 changes: 4 additions & 39 deletions multiless.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,8 @@
package torrent

import "github.com/anacrolix/missinggo"

type (
cmper func() (same, less bool)
multiLess struct {
ok bool
less bool
}
multiLess = missinggo.MultiLess
cmper = missinggo.SameLessFunc
)

func (me *multiLess) Final() bool {
if !me.ok {
panic("undetermined")
}
return me.less
}

func (me *multiLess) FinalOk() (left, ok bool) {
return me.less, me.ok
}

func (me *multiLess) Next(f cmper) {
if me.ok {
return
}
same, less := f()
if same {
return
}
me.ok = true
me.less = less
}

func (me *multiLess) StrictNext(same, less bool) {
if me.ok {
return
}
me.Next(func() (bool, bool) { return same, less })
}

func (me *multiLess) NextBool(l, r bool) {
me.StrictNext(l == r, l)
}

0 comments on commit 52b3a4e

Please sign in to comment.