/*
This method tries to match between initial objects
and key objects and then aggregates objects from both
the properties.
356436
function _getChildPrefs(prefItem) {

        var finalObj = {},
            keysFound = false;

        if (!prefItem) {
            return {};
        }

        function _populateKeys(allKeys) {

            var prop;
            if (typeof (allKeys) === "object") {
                // iterate through the list.
                keysFound = true;
                for (prop in allKeys) {
                    if (allKeys.hasOwnProperty(prop)) {
                        finalObj[prop] = allKeys[prop];
                    }
                }
            }
        }

        _populateKeys(prefItem.initial);
        _populateKeys(prefItem.keys);

        // Last resort: Maybe plain objects, in which case
        // we blindly extract all the properties.
        if (!keysFound) {
            _populateKeys(prefItem);
        }

        return finalObj;
    }
957197
function convertPropertyNamesAndValues (context, pkg, map, root, waiting) {
	if(!map) {
		return map;
	}
	var clone = {}, val, name;
	for(var property in map ) {
		val = map[property];
		name = convertName(context, pkg, map, root, property, waiting); 
		val = typeof val === "object"
			? convertPropertyNamesAndValues(context, pkg, val, root, waiting)
			: convertName(context, pkg, map, root, val, waiting);
		if(typeof name !== 'undefined' && typeof val !== 'undefined') {
			clone[name] = val;
		}
	}
	return clone;
}
32817
public static boolean equalsBuilder(Object object1, Object object2) {
		Set<String> excludeFields = new HashSet<String>();
		for(Field field: object1.getClass().getDeclaredFields()) {
			if(field.isAnnotationPresent(InEquals.class)) {
				InEquals inEquals = field.getAnnotation(InEquals.class);
				if(inEquals.ignore()) {
					excludeFields.add(field.getName());
				}
			}
		}
		return EqualsBuilder.reflectionEquals(object1, object2, excludeFields);
	}
309847
function mergeIntoWithNoDuplicateKeys(one, two) {
    _invariant(one && two && (typeof one === 'undefined' ? 'undefined' : _typeof(one)) === 'object' && (typeof two === 'undefined' ? 'undefined' : _typeof(two)) === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.');

    for (var key in two) {
      if (two.hasOwnProperty(key)) {
        _invariant(one[key] === undefined, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key);
        one[key] = two[key];
      }
    }
    return one;
  }
725012
function mergeDeepObjects(object1, object2) {
  const keys1 = Object.keys(object1);
  const keys2 = Object.keys(object2);

  let index = -1,
      mergedObject = {},
      key,
      indexOfKey;

  while (++index < keys1.length) {
    key = keys1[index];
    indexOfKey = keys2.indexOf(key);

    if (~indexOfKey) {
      mergedObject[key] = getDeeplyMergedValues(object1[key], object2[key]);

      keys2.splice(indexOfKey, 1);

      continue;
    }

    mergedObject[key] = object1[key];
  }

  if (keys2.length) {
    index = -1;

    while (++index < keys2.length) {
      key = keys2[index];

      mergedObject[key] = object2[key];
    }
  }

  return mergedObject;
}
1073973
def aggregate(obj_a, obj_b, level=False, map_class=Map, sequence_class=Sequence):
    '''
    
    '''
    deep, subdeep = levelise(level)

    if deep:
        obj_a = mark(obj_a, map_class=map_class, sequence_class=sequence_class)
        obj_b = mark(obj_b, map_class=map_class, sequence_class=sequence_class)

    if isinstance(obj_a, dict) and isinstance(obj_b, dict):
        if isinstance(obj_a, Aggregate) and isinstance(obj_b, Aggregate):
            # deep merging is more or less a.update(obj_b)
            response = copy.copy(obj_a)
        else:
            # introspection on obj_b keys only
            response = copy.copy(obj_b)

        for key, value in six.iteritems(obj_b):
            if key in obj_a:
                value = aggregate(obj_a[key], value,
                                  subdeep, map_class, sequence_class)
            response[key] = value
        return response

    if isinstance(obj_a, Sequence) and isinstance(obj_b, Sequence):
        response = obj_a.__class__(obj_a[:])
        for value in obj_b:
            if value not in obj_a:
                response.append(value)
        return response

    response = copy.copy(obj_b)

    if isinstance(obj_a, Aggregate) or isinstance(obj_b, Aggregate):
        log.info('only one value marked as aggregate. keep `obj_b` value')
        return response

    log.debug('no value marked as aggregate. keep `obj_b` value')
    return response
522117
function(setA, setB, property1, property2){
	// p for param
	// v for value
	var numProps = numericProperties(setA, setB, property1, property2);
	var sAv1 = numProps.sAv1,
		sAv2 = numProps.sAv2,
		sBv1 = numProps.sBv1,
		sBv2 = numProps.sBv2,
		count = sAv2 - sAv1 + 1;

	var after = {
		difference: [sBv2+1, sAv2],
		intersection: [sAv1,sBv2],
		union: [sBv1, sAv2],
		count: count,
		meta: "after"
	};
	var before = {
		difference: [sAv1, sBv1-1],
		intersection: [sBv1,sAv2],
		union: [sAv1, sBv2],
		count: count,
		meta: "before"
	};

	// if the sets are equal
	if(sAv1 === sBv1 && sAv2 === sBv2) {
		return {
			intersection: [sAv1,sAv2],
			union: [sAv1,sAv2],
			count: count,
			meta: "equal"
		};
	}
	// A starts at B but A ends later
	else if( sAv1 === sBv1 && sBv2 < sAv2 ) {
		return after;
	}
	// A end at B but A starts earlier
	else if( sAv2 === sBv2 && sBv1 > sAv1 ) {
		return before;
	}
	// B contains A
	else if( within(sAv1, [sBv1, sBv2]) && within(sAv2, [sBv1, sBv2]) ) {
		return {
			intersection: [sAv1,sAv2],
			union: [sBv1, sBv2],
			count: count,
			meta: "subset"
		};
	}
	// A contains B
	else if( within(sBv1, [sAv1, sAv2]) && within(sBv2, [sAv1, sAv2]) ) {
		return {
			intersection: [sBv1,sBv2],
			// there is a difference in what A has
			difference: [null, null],
			union: [sAv1, sAv2],
			count: count,
			meta: "superset"
		};
	}
	// setA starts earlier and overlaps setB
	else if(sAv1 < sBv1 && within(sAv2, [sBv1, sBv2]) ) {
		return before;
	}
	// setB starts earlier and overlaps setA
	else if(sBv1 < sAv1 && within(sBv2, [sAv1, sAv2]) ) {
		return after;
	}
	// side by side ... nothing intersection
	else if(sAv2 === sBv1-1) {
		return {
			difference: [sAv1,sAv2],
			union: [sAv1, sBv2],
			count: count,
			meta: "disjoint-before"
		};
	}

	else if(sBv2 === sAv1 - 1) {
		return {
			difference: [sAv1,sAv2],
			union: [sBv1, sAv2],
			count: count,
			meta: "disjoint-after"
		};
	}
	if(!isNaN(count)) {
		return {
			count: count,
			meta: "disjoint"
		};
	}

}
269169
function (a, b) {
  if (a) {
    if (Array.isArray(b)) {
      for (var i = 0; i < b.length; i++) {
        if (b[i]) {
          a[i] = extend(a[i], b[i]);
        }
      }
      return a;
    } else if (typeof b === 'object') {
      Object.getOwnPropertyNames(b).forEach(function (key) {
        a[key] = extend(a[key], b[key]);
      });
      return a;
    }
  }
  return b;
}
8059
private int compare(Object k1, Object k2) {
        return (mComparator==null ? ((Comparable)k1).compareTo(k2)
                : mComparator.compare(k1, k2));
    }
807546
private static boolean groupTogether(Object key1, Object key2, int groupLevel) {
        if (groupLevel == 0 || !(key1 instanceof List) || !(key2 instanceof List)) {
            return key1.equals(key2);
        }
        @SuppressWarnings("unchecked")
        List<Object> key1List = (List<Object>) key1;
        @SuppressWarnings("unchecked")
        List<Object> key2List = (List<Object>) key2;

        // if either key list is smaller than groupLevel and the key lists are different
        // sizes, they cannot be equal.
        if ((key1List.size() < groupLevel || key2List.size() < groupLevel) &&
                key1List.size() != key2List.size()) {
            return false;
        }

        int end = Math.min(groupLevel, Math.min(key1List.size(), key2List.size()));
        for (int i = 0; i < end; ++i) {
            if (key1List.get(i) != null && !key1List.get(i).equals(key2List.get(i)))
                return false;
            else if (key1List.get(i) == null && key2List.get(i) != null)
                return false;
        }
        return true;
    }
215628
function (prop) {
      var keys = Object.keys(this.keyMap);
      var items = this.items.map(function (item, i) {
        item.key = keys[i];
        return item;
      });
      var sorted = lazy.arraySort(items, prop);
      this.items = sorted;
      this.keyMap = this.items.reduce(function (acc, item, i) {
        acc[item.key] = i;
        return acc;
      }, {});
      return this;
    }
1208117
function isMatch (obj, source) {
  var objKeys = objectKeys(obj)
  var sourceKeys = objectKeys(source)
  if (sourceKeys.length) {
    if (XEUtils.includeArrays(objKeys, sourceKeys)) {
      return XEUtils.some(sourceKeys, function (key2) {
        return findIndexOf(objKeys, function (key1) {
          return key1 === key2 && isEqual(obj[key1], source[key2])
        }) > -1
      })
    }
  } else {
    return true
  }
  return isEqual(obj, source)
}
1162071
function fromEntries(keys, values) {
  return keys.reduce((obj, key, i) => {
    obj[key] = values[i];
    return obj;
  }, {})
}
129950
function getInitializedAverage(data) {
    return _.reduce(data, function (prev, a, dataKey) {
      // create a first-level object of the key
      prev[dataKey] = {};

      _.each(data[dataKey], function (b, dataMetricKey) {
        // the metrics are properties inside this object
        prev[dataKey][dataMetricKey] = 0;
      });

      return prev;
    }, {});
  }
285571
function checkInitialValue(obj, props) {

  Object.keys(props).forEach(function(k) {
    var p = props[k], val = obj[k];

    if (util.isNullOrUndefined(val)) {
      if (p.nullable === false) {
        throw k + ' is not-nullable property but initial value is null';
      }
      return;
    }

    if (Struct.isStructType(p.type, val) || util.isType(p.type, val)) {
      return;
    }

    var mat = p.type.match(REGEXP_STRUCT_TYPE);
    if (mat) {
      // Definition is struct type but normal object given
      var structName = mat[1];
      checkInitialValue(val, Struct.structs[structName]);
      // Auto boxing
      obj[k] = Struct.create(structName, val);
      return;
    }

    throw k + ' must be ' + props[k].type +
          ' type. But initial value not matched';
  });

  // Check each condition formula
  Object.keys(props).forEach(function(k) {
    var p = props[k], val = obj[k];
    if (p.cond && !p.cond(val)) {
      throw 'Invalid value:' + k + '=' + String(val);
    }
  });

  Object.keys(obj).forEach(function(k) {
    if (!props.hasOwnProperty(k)) {
      throw 'Invalid property found:' + k;
    }
  });
}
1177000
function (preserveExistingProperties) {
  var result = undefined;
  for (var i = 1; i < arguments.length; i++) {
    obj = arguments[i];

    // set initial result object to the first argument given
    if (!result) {
      result = obj;
      continue;
    }

    for (prop in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, prop)) {
        // preserve preexisting child properties if specified
        if (preserveExistingProperties &&
            Object.prototype.hasOwnProperty.call(result, prop)) {
              continue;
            }
        result[prop] = obj[prop];
      }
    }
  }

  return result;
}
935333
function(a, b, aParent, bParent, prop, compares, options){
		if(typeof compares === "function") {
			var compareResult = compares(a, b, aParent, bParent, prop, options);
			if(typeof compareResult === "boolean") {
				return compareResult;
			} else if(compareResult && typeof compareResult === "object"){
				if( compareResult.getSubset ) {
					if(h.indexOf.call(options.getSubsets, compareResult.getSubset) === -1) {
						options.getSubsets.push(compareResult.getSubset);
					}
				}
				if(compareResult.intersection === h.ignoreType || compareResult.difference === h.ignoreType) { // as in the case of a sort props
					return true;
				}
				// A \ B subset intersects in both directions
				// but does not diff from
				if( ("intersection" in compareResult) && !("difference" in compareResult)) {
					var reverseResult =  compares(b, a,bParent, aParent, prop, options);
					return ("intersection" in reverseResult);
				}
				return false;
			}
			return compareResult;
		}
	}