Added duplicate row support for mergeJoin
Added duplicate row support for mergeJoin

The mergeJoin algorithm now does a cross/cartesian join when joining duplicate
(with respect to the comparator) rows. This is how hashJoin already works.

e.g.

    Join.mergeJoin(
      [ {x: 1, y: 1},
        {x: 1, y: 2},
        {x: 2, y: 3},
        {x: 3, y: 4}
      ],
      [ {x: 1, y: 5},
        {x: 1, y: 6},
        {x: 2, y: 7},
        {x: 4, y: 8}
      ],
      function(l, r) {
        return l.x - r.x;
      },
      function(l, r) {
        if (l && r) {
          return {x: l.x, y1: l.y, y2: r.y};
        } else if (l) {
          return {x: l.x, y1: l.x, y2: 0};
        } else {
          return {x:r.x, y1: 0, y2: r.x};
        }
      }
    );

Used to return:

    [
      {x: 1, y1: 1, y2: 5},
      {x: 1, y1: 2, y2: 6},

      {x: 2, y1: 3, y2: 7},
      {x: 3, y1: 4, y2: 0},
      {x: 4, y1: 0, y2: 8}
    ]

But now returns:

    [
      {x: 1, y1: 1, y2: 5},
      {x: 1, y1: 1, y2: 6},
      {x: 1, y1: 2, y2: 5},
      {x: 1, y1: 2, y2: 6},

      {x: 2, y1: 3, y2: 7},
      {x: 3, y1: 4, y2: 0},
      {x: 4, y1: 0, y2: 8}
    ]

atavakoli/angular-join