/* * join.cpp * * Created on: Sep 22, 2010 * Author: fischer */ #include "join.hpp" // Precondition: dp1 and dp2 must be sorted void Join::commonData(const DataPack& dp1, const DataPack& dp2) { int i1 = 0; int i2 = 0; BT x1, x2; while (i1 < dp1.getN() && i2 < dp2.getN()) { x1 = dp1.getItem(i1); x2 = dp2.getItem(i2); if (x1 == x2) // common element found dp->add(x1); if (x1 <= x2) // Skip past all elements in dp1 matching x1 do { i1++; } while (i1 < dp1.getN() && dp1.getItem(i1) == x1); if (x1 >= x2) // Skip past all elements in dp2 matching x2 do { i2++; } while (i2 < dp2.getN() && dp2.getItem(i2) == x2); } }