/*
对比字串与加密后的字串是否一致
547770
public static function checkPassword($checkString,$encryptedString)
    {
        if(strlen($encryptedString) != 64){
            return false;
        }
        $preString=substr($encryptedString,0,32);
        $sufString=substr($encryptedString,32);
        if(md5($preString.$checkString) == $sufString){
            return true;
        }
        return false;
    }
335873
function difference(arrayA, arrayB) {
  var maxLength = _.max([ arrayA.length, arrayB.length ]);

  for (var i = 0, j = 0; i < maxLength; i += 1, j += 1) {
    if (arrayA[i] !== arrayB[j]) {
      if (arrayB[i-1] === arrayA[i]) {
        j -= 1;
      } else if (arrayB[i+1] === arrayA[i]) {
        j += 1;
      } else {
        return arrayA[i];
      }
    }
  }
}
669703
function (f, d) {

        f = makeCompareFunction(f, d);
        f.thenBy = tb;
        return f;
    }
515100
public static int compare(long[] x, long[] y) {
    if(x == null) {
      return (y == null) ? 0 : -1;
    }
    if(y == null) {
      return +1;
    }
    int p = Math.min(x.length, y.length) - 1;
    for(int i = x.length - 1; i > p; i--) {
      if(x[i] != 0) {
        return +1;
      }
    }
    for(int i = y.length - 1; i > p; i--) {
      if(y[i] != 0) {
        return -1;
      }
    }
    for(; p >= 0; p--) {
      final long xp = x[p], yp = y[p];
      if(xp != yp) {
        return xp < 0 ? (yp < 0 && yp < xp) ? -1 : +1 : (yp < 0 || xp < yp) ? -1 : +1;
      }
    }
    return 0;
  }
633558
private static function defaultCompareWrapper( $a, $b ) {
			if ( $a === $b ) {
				return 0;
			} else {

				if ( is_string( $a ) ) {
					return strcmp( $a, $b . '' );
				} else
				if ( is_int( $a ) || is_float( $b ) ) {
					return (float)$a - $b;
				} else 
				return -1;

			}
		}
500736
function constantCompare(a, b, n) {
	var n2 = n,
		then = Date.now(),
		eq = false,
		len, i
	while (n2--) {
		len = Math.max(a.length, b.length)
		for (i = 0; i < len; i++) {
			if (a.length >= i && b.length >= i && a[i] !== b[i]) {
				eq = false
			}
		}
	}
	return (Date.now() - then) * 1e6 / n
}
1216211
function getCompare(_, ctx) {
  var k = 'c:' + _.$compare + '_' + _.$order,
      c = array(_.$compare).map(function(_) {
        return (_ && _.$tupleid) ? tupleid : _;
      });
  return ctx.fn[k] || (ctx.fn[k] = compare(c, _.$order));
}
486892
function compare(a, b) {
  let isIdentical = true;

  if (isObject(a) && isObject(b)) {
    if (Object.keys(a).length !== Object.keys(b).length) {
      return false;
    }
    Object.keys(a).forEach((key) => {
      if (!compare(a[key], b[key])) {
        isIdentical = false;
      }
    });
    return isIdentical;
  } if (isArray(a) && isArray(b)) {
    if (a.length !== b.length) {
      return false;
    }
    for (let i = 0, l = a.length; i < l; i += 1) {
      if (!compare(a[i], b[i])) {
        return false;
      }
    }
    return true;
  }
  return a === b;
}
1063837
function MinHeap(compareFn) {
  this._elements = [null];
  this._comparator = new Comparator(compareFn);

  Object.defineProperty(this, 'n', {
    get: function () {
      return this._elements.length - 1;
    }.bind(this)
  });
}
747079
function(a, b)
	{
		if ((a == null && b != null) || (a != null && b == null) ||
			(a != null && b != null && a.length != b.length))
		{
			return false;
		}
		else if (a != null && b != null)
		{
			// Counts keys in b to check if all values have been compared
			var count = 0;
			
			for (var key in b)
			{
				count++;
			}
			
			for (var key in a)
			{
				count--
				
				if ((!mxUtils.isNaN(a[key]) || !mxUtils.isNaN(b[key])) && a[key] != b[key])
				{
					return false;
				}
			}
		}
		
		return count == 0;
	}
876338
function similar(a,b) {
    if(a instanceof Array) {
        if(!(b instanceof Array))
            return false

        var tenPercent = a.length/10
        var notEqual = Math.abs(a.length-b.length) // initialize with the length difference
        for(var n=0; n<a.length; n++) {
            if(equal(a[n],b[n])) {
                if(notEqual >= 2 && notEqual > tenPercent || notEqual === a.length) {
                    return false
                }

                notEqual++
            }
        }
        // else
        return true

    } else if(a instanceof Object) {
        if(!(b instanceof Object))
            return false

        var keyMap = merge(arrayToMap(Object.keys(a)), arrayToMap(Object.keys(b)))
        var keyLength = Object.keys(keyMap).length
        var tenPercent = keyLength / 10
        var notEqual = 0
        for(var key in keyMap) {
            var aVal = a[key]
            var bVal = b[key]

            if(!equal(aVal,bVal)) {
                if(notEqual >= 2 && notEqual > tenPercent || notEqual+1 === keyLength) {
                    return false
                }

                notEqual++
            }
        }
        // else
        return true

    } else {
        return a===b || Number.isNaN(a) && Number.isNaN(b)
    }
}
1069396
function BST(compareFn) {
  this.root = null;
  this._size = 0;
  /**
   * @var Comparator
   */
  this._comparator = new Comparator(compareFn);

  /**
   * Read-only property for the size of the tree
   */
  Object.defineProperty(this, 'size', {
    get: function () { return this._size; }.bind(this)
  });
}
547111
function searchAndCompare(specObject, comparisonObject, currentDescription) {

    if (comparisonObject === undefined) {
        comparisonObject = {};
    }

    for (var key in specObject) {
        if (specObject.hasOwnProperty(key)) {
            currentDescription.push(key);
            if (typeof(specObject[key]) === "string") {
                compare(specObject[key], comparisonObject[key], currentDescription);
            } else {
                searchAndCompare(specObject[key].specs, comparisonObject[key], currentDescription);
            }
            currentDescription.pop();
        }
    }
}
1364818
private static boolean contentEquals(String s, char[] chars, int start, int length) {
		if (s.length() != length) {
			return false;
		}
		for (int i = 0; i < length; i++) {
			if (chars[start + i] != s.charAt(i)) {
				return false;
			}
		}
		return true;
	}
923930
@Override
    protected double scoreImpl(List<Word> words1, List<Word> words2) {
        //用词频来标注词的权重
        taggingWeightWithWordFrequency(words1, words2);
        //构造权重快速搜索容器
        Map<String, Float> weights1 = toFastSearchMap(words1);
        Map<String, Float> weights2 = toFastSearchMap(words2);
        //所有的不重复词
        Set<Word> words = new HashSet<>();
        words.addAll(words1);
        words.addAll(words2);
        //向量的维度为words的大小，每一个维度的权重是词频
        //a.b
        AtomicFloat ab = new AtomicFloat();
        //|a|的平方
        AtomicFloat aa = new AtomicFloat();
        //|b|的平方
        AtomicFloat bb = new AtomicFloat();
        //计算
        words
            .parallelStream()
            .forEach(word -> {
                Float x1 = weights1.get(word.getText());
                Float x2 = weights2.get(word.getText());
                if (x1 != null && x2 != null) {
                    //x1x2
                    float oneOfTheDimension = x1 * x2;
                    //+
                    ab.addAndGet(oneOfTheDimension);
                }
                if (x1 != null) {
                    //(x1)^2
                    float oneOfTheDimension = x1 * x1;
                    //+
                    aa.addAndGet(oneOfTheDimension);
                }
                if (x2 != null) {
                    //(x2)^2
                    float oneOfTheDimension = x2 * x2;
                    //+
                    bb.addAndGet(oneOfTheDimension);
                }
            });
        //|a|
        double aaa = Math.sqrt(aa.doubleValue());
        //|b|
        double bbb = Math.sqrt(bb.doubleValue());
        //使用BigDecimal保证精确计算浮点数
        //|a|*|b|
        //double aabb = aaa * bbb;
        BigDecimal aabb = BigDecimal.valueOf(aaa).multiply(BigDecimal.valueOf(bbb));
        //similarity=a.b/|a|*|b|
        //double cos = ab.get() / aabb.doubleValue();
        double cos = BigDecimal.valueOf(ab.get()).divide(aabb, 9, BigDecimal.ROUND_HALF_UP).doubleValue();
        return cos;
    }
1341607
function _comparer (a, b) {
    var result = 0;

    if (typeof a !== typeof b) {
        a = String(a);
        b = String(b);
    }

    if (!areSVZ(a, b)) {
        // eslint-disable-next-line no-self-compare
        result = a > b || a !== a ? 1 : -1;
    }

    return result;
}
1348224
function equal(a, b, diff) {
  diff = diff || {};
  if (a.type !== b.type) {
    return equalDiff(a, b, diff);
  }
  if (a.value !== b.value) {
    return equalDiff(a, b, diff);
  }
  if (isValueNode(a) !== isValueNode(b)) {
    return equalDiff(a, b, diff);
  }
  if (!isValueNode(a)) {
    if (a.nodes.length !== b.nodes.length) {
      return equalDiff(a, b, diff);
    }
    for (var i = 0; i < b.nodes.length; i++) {
      if (!equal(a.nodes[i], b.nodes[i], diff)) {
        return false;
      }
    }
  }
  return true;
}