Improved traversers

Added abstract class QueueBasedTraverser holds general logic for most
traversers.
Fixed errors in InfoKeepers.
Added InfoKeeper that uses IntToBoolean fastutil map to store Boolean
values.
Changed BreadthFirstTraverser so that first node is the node we start
traverse from (to be consistent with other traversals).
Good thinking. .view and .force exist for this reason btw and will be more readable...
so in terms of your example:
> Seq(1,2,3,4).view.filter(x => {println(x); x % 2 == 0}).take(1)).force
> 

On Aug 4, 2014, at 10:59 PM, Szymon <notifications@github.com> wrote:

> In cassovary-core/src/main/scala/com/twitter/cassovary/graph/Traverser.scala:
> 
> >    }
> >  
> > -  private def enqueueNeighbors(nodeId: Int, newDepth: Int) {
> > -    val nd = getExistingNodeById(graph, nodeId)
> > -    if (maxNumEdgesThresh.isEmpty || (nd.neighborCount(dir) <= maxNumEdgesThresh.get)) {
> > -      nd.neighborIds(dir) foreach { id =>
> > -        // bound the total number of items that
> > -        // can be pushed into the queue by maxSteps
> > -        if (numEnqueuedEver < maxSteps) {
> > -          visitPotentialNode(id, newDepth)
> > +  override def chooseNodesToEnqueue(node: Node): Seq[Int] = {
> > +    val currDepth = depth(node.id).get
> > +
> > +    if (!maxDepthReached(currDepth) && !degreeToHigh(node.neighborCount(dir))) {
> > +      node.neighborIds(dir).iterator
> Using iterator here will prevent from checking filter condition for nodes than will never be taken by the take condition, I think.
> 
> See:
> Seq(1, 2, 3, 4).filter(x => {println(x); % 2 == 0}).take(1)
> Seq(1,2,3,4).iterator.filter(x => {println(x); x % 2 == 0}).take(1)).toSeq
> 
> —
> Reply to this email directly or view it on GitHub.
>