Codebase list golang-github-beorn7-perks / 0644939
keep real max Blake Mizerany 11 years ago
1 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4040 q []float64
4141 n float64
4242 l *list.List
43 max float64
4344 }
4445
4546 // New returns an initialized stream.
8586 var r float64
8687 e := qt.l.Front()
8788 return func(v, w float64) {
89 if v > qt.max {
90 qt.max = v
91 }
92
8893 for ; e != nil; e = e.Next() {
8994 c := e.Value.(*Sample)
9095 if c.Value > v {
164169
165170 // Max returns the maximum value observed in the stream within the error epsilon.
166171 func (qt *stream) Max() float64 {
167 if e := qt.l.Back(); e != nil {
168 return e.Value.(*Sample).Value
172 if qt.l.Len() > 0 {
173 return qt.max
169174 }
170175 return math.NaN()
171176 }