calculate the contrast between 2 colors

@param left
@param right
@return a int between 0 (badest) and 510 (best)
@throws ServletException
423623
public static int contrast(Color left, Color right) throws ServletException {
	return (Math.max(left.getRed(), right.getRed()) - Math.min(left.getRed(), right.getRed()))
		+ (Math.max(left.getGreen(), right.getGreen()) - Math.min(left.getGreen(), right.getGreen()))
		+ (Math.max(left.getBlue(), right.getBlue()) - Math.max(left.getBlue(), right.getBlue()));
    }
200708
private void computeRemainingRows(GrayS16 left, GrayS16 right )
	{
		for( int row = regionHeight; row < left.height; row++ ) {
			int oldRow = row%regionHeight;

			// subtract first row from vertical score
			int scores[] = horizontalScore[oldRow];
			for( int i = 0; i < lengthHorizontal; i++ ) {
				verticalScore[i] -= scores[i];
			}

			UtilDisparityScore.computeScoreRow(left, right, row, scores,
					minDisparity,maxDisparity,regionWidth,elementScore);

			// add the new score
			for( int i = 0; i < lengthHorizontal; i++ ) {
				verticalScore[i] += scores[i];
			}

			// compute disparity
			computeDisparity.process(row - regionHeight + 1 + radiusY, verticalScore);
		}
	}
416850
public static int compare(String left, double right) {
	if (Decision.isNumber(left)) {
	    if (left.length() > 9) {
		try {
		    return new BigDecimal(left).compareTo(new BigDecimal(Caster.toString(right)));
		}
		catch (Exception e) {}
	    }
	    return compare(Caster.toDoubleValue(left, Double.NaN), right);
	}
	if (Decision.isBoolean(left)) return compare(Caster.toBooleanValue(left, false), right);

	if (left.length() == 0) return -1;
	char leftFirst = left.charAt(0);
	if (leftFirst >= '0' && leftFirst <= '9') return left.compareToIgnoreCase(Caster.toString(right));
	return leftFirst - '0';
    }
953317
def contrast(self, color, step):
        """"""
        hls = colorsys.rgb_to_hls(*self.rgb(color))
        if self.is_light(color):
            return colorsys.hls_to_rgb(hls[0], hls[1] - step, hls[2])
        else:
            return colorsys.hls_to_rgb(hls[0], hls[1] + step, hls[2])
991723
public static Number and(Number left, Number right) {
        return NumberMath.and(left, right);
    }
455560
static boolean left(int[] verts, int a, int b, int c) {
        return area2(verts, a, b, c) < 0;
    }
687055
public static boolean areEqualTrimmed(final String left, final String right)
   {
      if ((left != null) && (right != null))
      {
         return left.trim().equals(right.trim());
      }
      return areEqual(left, right);
   }
1155844
protected function opColorColor($op, $left, $right)
    {
        $out = [Type::T_COLOR];

        foreach ([1, 2, 3] as $i) {
            $lval = isset($left[$i]) ? $left[$i] : 0;
            $rval = isset($right[$i]) ? $right[$i] : 0;

            switch ($op) {
                case '+':
                    $out[] = $lval + $rval;
                    break;

                case '-':
                    $out[] = $lval - $rval;
                    break;

                case '*':
                    $out[] = $lval * $rval;
                    break;

                case '%':
                    $out[] = $lval % $rval;
                    break;

                case '/':
                    if ($rval == 0) {
                        $this->throwError("color: Can't divide by zero");
                        break 2;
                    }

                    $out[] = (int) ($lval / $rval);
                    break;

                case '==':
                    return $this->opEq($left, $right);

                case '!=':
                    return $this->opNeq($left, $right);

                default:
                    $this->throwError("color: unknown op $op");
                    break 2;
            }
        }

        if (isset($left[4])) {
            $out[4] = $left[4];
        } elseif (isset($right[4])) {
            $out[4] = $right[4];
        }

        return $this->fixColor($out);
    }
99372
public static Expression compare(
      final int comparisonOpcode, final Expression left, final Expression right) {
    checkArgument(
        left.resultType().equals(right.resultType()),
        "left and right must have matching types, found %s and %s",
        left.resultType(),
        right.resultType());
    checkIntComparisonOpcode(left.resultType(), comparisonOpcode);
    Features features =
        Expression.areAllCheap(left, right) ? Features.of(Feature.CHEAP) : Features.of();
    return new Expression(Type.BOOLEAN_TYPE, features) {
      @Override
      protected void doGen(CodeBuilder mv) {
        left.gen(mv);
        right.gen(mv);
        Label ifTrue = mv.newLabel();
        Label end = mv.newLabel();
        mv.ifCmp(left.resultType(), comparisonOpcode, ifTrue);
        mv.pushBoolean(false);
        mv.goTo(end);
        mv.mark(ifTrue);
        mv.pushBoolean(true);
        mv.mark(end);
      }
    };
  }
699025
private void computeFirstRow(GrayS16 left, GrayS16 right ) {
		// compute horizontal scores for first row block
		for( int row = 0; row < regionHeight; row++ ) {

			int scores[] = horizontalScore[row];

			UtilDisparityScore.computeScoreRow(left, right, row, scores,
					minDisparity,maxDisparity,regionWidth,elementScore);
		}

		// compute score for the top possible row
		for( int i = 0; i < lengthHorizontal; i++ ) {
			int sum = 0;
			for( int row = 0; row < regionHeight; row++ ) {
				sum += horizontalScore[row][i];
			}
			verticalScore[i] = sum;
		}

		// compute disparity
		computeDisparity.process(radiusY, verticalScore);
	}
1096085
function compare(color1, color2, method) {
  var methodName = method || 'CIE76Difference';

  if (undefined === methods[methodName]) {
    throw new Error('Method "' + methodName + '" is unknown. See implemented methods in ./lib/method directory.');
  }

  /** @type Abstract */
  var methodObj = new methods[methodName];

  return methodObj.compare(new HexRgb(color1), new HexRgb(color2));
}
1270054
public static function compare($left, $right){
		if($left->a != $right->a) return $left->a <=> $right->a;
		if($left->b != $right->b) return $left->b <=> $right->b;
		if($left->c != $right->c) return $left->c <=> $right->c;
		if($left->i < 0 || $right->i < 0) return 0;
		return $left->i <=> $right->i;
	}
344763
private static int compareUnsigned(int left, int right) {
    // NOTE: JDK 7 does not have a built-in operation for this, other than casting to longs.
    //       In JDK 8 it's just Integer.compareUnsigned(left, right).  For now we emulate it
    //       by shifting the sign bit away, with a fallback second compare only if needed.
    int diff = (left >>> 2) - (right >>> 2);
    return diff != 0 ? diff : (left & 3) - (right & 3);
  }
1098877
private void processBigram(String left, String right) {
        TokenStats leftStats = getStatsFor(left);
        TokenStats rightStats = getStatsFor(right);
        
        // mark that both appeared
        leftStats.count++;
        rightStats.count++;

        // Mark the respective positions of each
        leftStats.leftCount++;
        rightStats.rightCount++;

        // Increase the number of bigrams seen
        numBigramsInCorpus++;

        // Update the bigram statistics

        // Map the two token's indices into a single long
        long bigram = (((long)leftStats.index) << 32) |  rightStats.index;
        Number curBigramCount = bigramCounts.get(bigram);
        int i = (curBigramCount == null) ? 1 : 1 + curBigramCount.intValue();

        // Compact the count into the smallest numeric type that can represent
        // it.  This hopefully results in some space savings.
        Number val = null;
        if (i < Byte.MAX_VALUE)
            val = Byte.valueOf((byte)i);
        else if (i < Short.MAX_VALUE)
            val = Short.valueOf((short)i);
        else
            val = Integer.valueOf(i);
        
        bigramCounts.put(bigram, val);
    }
901637
public static int getDeclinedColorFromColor(int color) {
        int bg = 0xffffffff;
        int a = DECLINED_EVENT_ALPHA;
        int r = (((color & 0x00ff0000) * a) + ((bg & 0x00ff0000) * (0xff - a))) & 0xff000000;
        int g = (((color & 0x0000ff00) * a) + ((bg & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
        int b = (((color & 0x000000ff) * a) + ((bg & 0x000000ff) * (0xff - a))) & 0x0000ff00;
        return (0xff000000) | ((r | g | b) >> 8);
    }
906124
public static <K,V> Set<K> keysDifference(Map<K,V> left, Map<K,V> right) {
        if (left == null){
            return Collections.emptySet();
        }

        if (right == null){
            return left.keySet();
        }

        return Sets.difference(left.keySet(), right.keySet());
    }
536425
private double doubleValueLeftColor( double color, double right ) {
        return rgba( doubleValue( red( color ), right ), //
                        doubleValue( green( color ), right ), //
                        doubleValue( blue( color ), right ), 1 );
    }