class STCClusteringAlgorithm extends AttrComposite implements ClusteringAlgorithm {

  static int computeIntersection(int[] a, int aPos, int aLength, int[] b, int bPos, int bLength) {
    final int maxa = aPos + aLength;
    final int maxb = bPos + bLength;

    int ea;
    int eb;
    int common = 0;
    while (aPos < maxa && bPos < maxb) {
      ea = a[aPos];
      eb = b[bPos];
      if (ea >= eb) bPos++;
      if (ea <= eb) aPos++;
      if (ea == eb) common++;
    }

    return common;
  }

}