java.util.HashMap#equals ( )源码实例Demo

下面列出了java.util.HashMap#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GregTech   文件: InventoryItemSource.java
private boolean recomputeItemStackCount() {
    if (!checkItemHandlerValid(false)) {
        return false;
    }
    this.lastStoredItemListUpdateTick = world.getTotalWorldTime();
    HashMap<ItemStackKey, Integer> amountMap = new HashMap<>();
    for (int i = 0; i < itemHandler.getSlots(); i++) {
        ItemStack itemStack = itemHandler.getStackInSlot(i);
        if (itemStack.isEmpty()) continue;
        ItemStackKey stackKey = new ItemStackKey(itemStack);
        amountMap.put(stackKey, amountMap.getOrDefault(stackKey, 0) + itemStack.getCount());
    }
    if (amountMap.equals(itemStackByAmountMap)) {
        return false;
    }
    HashSet<ItemStackKey> removedItems = new HashSet<>(itemStackByAmountMap.keySet());
    removedItems.removeAll(amountMap.keySet());
    this.itemStackByAmountMap = amountMap;
    if (changeCallback != null) {
        changeCallback.onStoredItemsUpdated(amountMap, removedItems);
    }
    return true;
}
 
源代码2 项目: ats-framework   文件: ComponentHotDeployTask.java
private boolean needReload() {

        if (!componentLocation.exists() || !componentLocation.isDirectory()) {
            log.error("Component location '" + componentLocation.getAbsolutePath()
                      + "' does not exist or is not a directory - skipping it");
            return false;
        }

        boolean result = false;

        File[] jarFiles = componentLocation.listFiles(new JarFilenameFilter());
        if (jarFiles != null) {
            HashMap<String, Long> currentModificationTimes = getLastModificationTimes(jarFiles);
            if (!currentModificationTimes.equals(lastModificationTimes)) {

                lastModificationTimes = currentModificationTimes;
                result = true;
            }
        }

        return result;
    }
 
源代码3 项目: gemfirexd-oss   文件: WANTestBase.java
public static void checkQueueOnSecondary (final Map primaryUpdatesMap){
  final HashMap secondaryUpdatesMap = new HashMap();
  secondaryUpdatesMap.put("Create", listener1.createList);
  secondaryUpdatesMap.put("Update", listener1.updateList);
  secondaryUpdatesMap.put("Destroy", listener1.destroyList);
  
  WaitCriterion wc = new WaitCriterion() {
    public boolean done() {
      secondaryUpdatesMap.put("Create", listener1.createList);
      secondaryUpdatesMap.put("Update", listener1.updateList);
      secondaryUpdatesMap.put("Destroy", listener1.destroyList);
      if (secondaryUpdatesMap.equals(primaryUpdatesMap)) {
        return true;
      }
      return false;
    }

    public String description() {
      return "Expected seconadry map to be " + primaryUpdatesMap + " but it is " + secondaryUpdatesMap;
    }
  };
  DistributedTestCase.waitForCriterion(wc, 300000, 500, true); 
}
 
源代码4 项目: gemfirexd-oss   文件: WANTestBase.java
public static void checkQueueOnSecondary (final Map primaryUpdatesMap){
  final HashMap secondaryUpdatesMap = new HashMap();
  secondaryUpdatesMap.put("Create", listener1.createList);
  secondaryUpdatesMap.put("Update", listener1.updateList);
  secondaryUpdatesMap.put("Destroy", listener1.destroyList);
  
  WaitCriterion wc = new WaitCriterion() {
    public boolean done() {
      secondaryUpdatesMap.put("Create", listener1.createList);
      secondaryUpdatesMap.put("Update", listener1.updateList);
      secondaryUpdatesMap.put("Destroy", listener1.destroyList);
      if (secondaryUpdatesMap.equals(primaryUpdatesMap)) {
        return true;
      }
      return false;
    }

    public String description() {
      return "Expected seconadry map to be " + primaryUpdatesMap + " but it is " + secondaryUpdatesMap;
    }
  };
  DistributedTestCase.waitForCriterion(wc, 300000, 500, true); 
}
 
源代码5 项目: algorithms101   文件: Anagram.java
public boolean isAnagram1(String text1, String text2) {

        // Map 1
        HashMap<String, Integer> map1 = map(text1);

        // Map 2
        HashMap<String, Integer> map2 = map(text2);

        // Compare letters and frequency of characters in Maps
        return map1.equals(map2);
    }
 
源代码6 项目: kubernetes-client   文件: ResourceCompare.java
public static <T>  boolean equals(T left, T right) {
    ObjectMapper jsonMapper = Serialization.jsonMapper();
    Map<String, Object> leftJson = (Map<String, Object>) jsonMapper.convertValue(left, TYPE_REF);
    Map<String, Object> rightJson = (Map<String, Object>) jsonMapper.convertValue(right, TYPE_REF);

    Map<String, Object> leftLabels = fetchLabels(leftJson);
    Map<String, Object> rightLabels = fetchLabels(rightJson);

    HashMap<String, Object> leftMap = trim(leftJson);
    HashMap<String, Object> rightMap = trim(rightJson);

    return leftMap.equals(rightMap) && leftLabels.equals(rightLabels);
}
 
源代码7 项目: spork   文件: EqualToExpr.java
@SuppressWarnings("unchecked")
private Result doComparison(Result left, Result right) throws ExecException {
    if (left.returnStatus != POStatus.STATUS_OK) {
        return left;
    }
    if (right.returnStatus != POStatus.STATUS_OK) {
        return right;
    }
    // if either operand is null, the result should be
    // null
    if(left.result == null || right.result == null) {
        left.result = null;
        left.returnStatus = POStatus.STATUS_OK;
        return left;
    }

    if (left.result instanceof Comparable && right.result instanceof Comparable){
        if (((Comparable)left.result).compareTo(right.result) == 0) {
            left.result = Boolean.TRUE;
        } else {
            left.result = Boolean.FALSE;
        }
    }else if (left.result instanceof HashMap && right.result instanceof HashMap){
        HashMap leftMap=(HashMap)left.result;
        HashMap rightMap=(HashMap)right.result;
        if (leftMap.equals(rightMap)) {
            left.result = Boolean.TRUE;
        } else {
            left.result = Boolean.FALSE;
        }
    }else{
        throw new ExecException("The left side and right side has the different types");
    }
    illustratorMarkup(null, left.result, (Boolean) left.result ? 0 : 1);
    return left;
}
 
源代码8 项目: spork   文件: NotEqualToExpr.java
@SuppressWarnings("unchecked")
private Result doComparison(Result left, Result right) throws ExecException {
    if (left.returnStatus != POStatus.STATUS_OK) {
        return left;
    }
    if (right.returnStatus != POStatus.STATUS_OK) {
        return right;
    }
    // if either operand is null, the result should be
    // null
    if(left.result == null || right.result == null) {
        left.result = null;
        left.returnStatus = POStatus.STATUS_OK;
        return left;
    }

    if (left.result instanceof Comparable && right.result instanceof Comparable){
        if (((Comparable)left.result).compareTo(right.result) != 0) {
            left.result = Boolean.TRUE;
        } else {
            left.result = Boolean.FALSE;
        }
    }else if (left.result instanceof HashMap && right.result instanceof HashMap){
        HashMap leftMap=(HashMap)left.result;
        HashMap rightMap=(HashMap)right.result;
        if (leftMap.equals(rightMap)) {
            left.result = Boolean.FALSE;
        } else {
            left.result = Boolean.TRUE;
        }
    }else{
        throw new ExecException("The left side and right side has the different types");
    }
    illustratorMarkup(null, left.result, (Boolean) left.result ? 0 : 1);
    return left;
}
 
源代码9 项目: compiler   文件: TreedMapper.java
private void lcs(ArrayList<ASTNode> lM, ArrayList<ASTNode> lN, ArrayList<Integer> lcsM, ArrayList<Integer> lcsN) {
	int lenM = lM.size(), lenN = lN.size();
	int[][] d = new int[2][lenN + 1];
	char[][] p = new char[lenM + 1][lenN + 1];
	for (int j = 0; j <= lenN; j++)
		d[1][j] = 0;
	for (int i = lenM-1; i >= 0; i--) {
		ASTNode nodeM = lM.get(i);
		int hM = treeHeight.get(nodeM);
		HashMap<String, Integer> vM = treeVector.get(nodeM);
		for (int j = 0; j <= lenN; j++)
			d[0][j] = d[1][j];
		for (int j = lenN-1; j >= 0; j--) {
			ASTNode nodeN = lN.get(j);
			int hN = treeHeight.get(nodeN);
			HashMap<String, Integer> vN = treeVector.get(nodeN);
			if (hM == hN && nodeM.getNodeType() == nodeN.getNodeType() && vM.equals(vN) && subtreeMatch(nodeM, nodeN)) {
				d[1][j] = d[0][j + 1] + 1;
				p[i][j] = 'D';
			} else if (d[0][j] >= d[1][j + 1]) {
				d[1][j] = d[0][j];
				p[i][j] = 'U';
			} else {
				d[1][j] = d[1][j + 1];
				p[i][j] = 'R';
			}
		}
	}
	int i = 0, j = 0;
	while (i < lenM && j < lenN) {
		if (p[i][j] == 'D') {
			lcsM.add(i);
			lcsN.add(j);
			i++;
			j++;
		} else if (p[i][j] == 'U')
			i++;
		else
			j++;
	}
}