interesting. thanks for that. i had no idea


On Tue, Feb 25, 2014 at 3:57 PM, Joe Nievelt <notifications@github.com>wrote:

> In algebird-core/src/main/scala/com/twitter/algebird/SpaceSaver.scala:
>
> > +      .filter { case (item, (count, err)) => count >= thres }
> > +      .toList
> > +      .sorted(ordering)
> > +      .map { case (item, (count, err)) => (item, Approximate(count - err, count, count, 1.0), thres <= count - err) }
> > +
> > +  /**
> > +    * Get the top-k elements.
> > +    * Returns sorted in descending order: (item, Approximate[Long], guaranteed)
> > +    */
> > +  def topK(k: Int): Seq[(T, Approximate[Long], Boolean)] = {
> > +    require(k < capacity)
> > +    val si = counters
> > +      .toList
> > +      .sorted(ordering)
> > +      .iterator
> > +    val siK = si.take(k).toList
>
> It's not a bug, it's undefined. See
> http://www.scala-lang.org/api/2.10.3/index.html#scala.collection.Iterator--
>
> Reuse: After calling [take], one should discard the iterator it was called
> on, and use only the iterator that was returned. Using the old iterator is
> undefined, subject to change, and may result in changes to the new iterator
> as well.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/twitter/algebird/pull/259/files#r10055378>
> .
>