Check that two spatial objects have the same dimensionality.

@param box1 First object
@param box2 Second object
@return Dimensionality
@throws IllegalArgumentException when the dimensionalities do not agree
493395
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2) {
    final int dim = box1.getDimensionality();
    if(dim != box2.getDimensionality()) {
      throw new IllegalArgumentException("The spatial objects do not have the same dimensionality!");
    }
    return dim;
  }
1035904
public final static boolean objectEquals(Object a, Object b) {
        return a == null ?
                b == null ? true : false :
                    b == null ? false : a.equals(b);
    }
863355
public static boolean sameLists(String list1, String list2)
    {
        return new CommaListIterator(list1).equals(new CommaListIterator(list2));
    }
403721
public static boolean equal(Object obj1, Object obj2) {
        if (obj1 == obj2) {
            return true;
        }
        if (obj1 == null || obj2 == null) {
            return false;
        }
        if (obj1.getClass().isArray()) {
            return equalsArray(obj1, obj2);
        }
        // this does not handle arrays embedded in objects, such as in lists/maps
        // but you shouldn't use arrays like that, should you?
        return obj1.equals(obj2);
    }
286507
public static double[] subtractArray(double[] array1, double[] array2)
    {
        if (array1.length != array2.length)
        {
            throw new IllegalArgumentException("The dimensions have to be equal!");
        }

        double[] result = new double[array1.length];
        assert array1.length == array2.length;
        for (int i = 0; i < array1.length; i++)
        {
            result[i] = array1[i] - array2[i];
        }

        return result;
    }
898673
public static boolean objectsNotEqual(final Object one, final Object two) {

        return (one == null) ? (two != null) : (!one.equals(two));

    }
1050357
public boolean sameAs(BlockType other) {
        if (!this.isValid) {
            return !other.isValid && (this.isTop == other.isTop);
        } else {
            if (!other.isValid) {
                return false;
            } else {
                // Both facts are valid
                if (this.depth != other.depth) {
                    return false;
                }

                // Compare bits
                for (int i = 0; i < this.depth; ++i) {
                    if (this.get(i) != other.get(i)) {
                        return false;
                    }
                }

                return true;
            }
        }
    }
1256407
public Bbox union(Bbox other) {
		if (other.getWidth() == 0 && other.getHeight() == 0 && other.getX() == 0 && other.getY() == 0) {
			return (Bbox) clone();
		}
		if (width == 0 && height == 0 && x == 0 && y == 0) {
			return (Bbox) other.clone();
		}

		double minx = other.getX() < this.getX() ? other.getX() : this.getX();
		double maxx = other.getEndPoint().getX() > this.getEndPoint().getX() ? other.getEndPoint().getX() : this
				.getEndPoint().getX();
		double miny = other.getY() < this.getY() ? other.getY() : this.getY();
		double maxy = other.getEndPoint().getY() > this.getEndPoint().getY() ? other.getEndPoint().getY() : this
				.getEndPoint().getY();
		return new Bbox(minx, miny, (maxx - minx), (maxy - miny));
	}
181190
public final Object get2d(Object key1, Object key2) {
        AssociativeArray tmp = internalData.get(key1);
        if(tmp == null) {
            return null;
        }
        
        return tmp.internalData.get(key2);
    }
564012
public static final boolean intersection(Rectangle src1, Rectangle src2, Rectangle dest)
    {
        int x1 = Math.max(src1.x, src2.x);
        int y1 = Math.max(src1.y, src2.y);
        int x2 = Math.min(src1.x + src1.width, src2.x + src2.width);
        int y2 = Math.min(src1.y + src1.height, src2.y + src2.height);
        dest.setBounds(x1, y1, x2 - x1, y2 - y1);

        if (dest.width <= 0 || dest.height <= 0)
            return false;

        return true; // non-empty intersection
    }
1161000
public static boolean areEqual(String s1, String s2) {
        return (s1 == null) ? s2 == null : s1.equals(s2);
    }
361009
public static BoundingBox overlap(BoundingBox boundingBox,
			BoundingBox boundingBox2, boolean allowEmpty) {
		return boundingBox.overlap(boundingBox2, allowEmpty);
	}
442252
public static Boolean geomEquals(Geometry a, Geometry b) {
        if(a==null || b==null) {
            return null;
        }
        return a.equals(b);
    }
1125795
public static boolean disjoint(Geometry geometry1, Geometry geometry2,
			SpatialReference spatialReference) {
		OperatorDisjoint op = (OperatorDisjoint) factory
				.getOperator(Operator.Type.Disjoint);
		boolean result = op.execute(geometry1, geometry2, spatialReference,
				null);
		return result;
	}
323197
public static boolean shapeEquals(int[] shape1, int[] shape2) {
        if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
            return Arrays.equals(shape1, shape2);
        }

        if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
            int[] shape1Comp = squeeze(shape1);
            int[] shape2Comp = squeeze(shape2);
            return Arrays.equals(shape1Comp, shape2Comp);
        }

        //scalars
        if(shape1.length == 0 || shape2.length == 0) {
            if(shape1.length == 0 && shapeIsScalar(shape2)) {
                return true;
            }

            if(shape2.length == 0 && shapeIsScalar(shape1)) {
                return true;
            }
        }


        shape1 = squeeze(shape1);
        shape2 = squeeze(shape2);

        return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
    }
28775
public static double[] timesPlusEquals(final double[] v1, final double s1, final double[] v2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    for(int i = 0; i < v1.length; i++) {
      v1[i] = v1[i] * s1 + v2[i];
    }
    return v1;
  }
1224868
public int checkDominance(S a, S b) {

    int flag1 = 0;
    int flag2 = 0;

    for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
      if (a.getObjective(i) < b.getObjective(i)) {
        flag1 = 1;
      } else {
        if (a.getObjective(i) > b.getObjective(i)) {
          flag2 = 1;
        }
      }
    }
    if (flag1 == 1 && flag2 == 0) {
      return 1;
    } else {
      if (flag1 == 0 && flag2 == 1) {
        return -1;
      } else {
        return 0;
      }
    }
  }