當前位置: 首頁>>代碼示例>>Java>>正文


Java Key.hashCode方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.Key.hashCode方法的典型用法代碼示例。如果您正苦於以下問題:Java Key.hashCode方法的具體用法?Java Key.hashCode怎麽用?Java Key.hashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.Key的用法示例。


在下文中一共展示了Key.hashCode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: minus

import com.intellij.openapi.util.Key; //導入方法依賴的package包/類
@NotNull
@Override
public KeyFMap minus(@NotNull Key<?> key) {
  int oldSize = size();
  int keyCode = key.hashCode();
  if (!containsKey(keyCode)) {
    return this;
  }
  if (oldSize == ArrayBackedFMap.ARRAY_THRESHOLD + 1) {
    int[] keys = keys();
    Object[] values = getValues();
    int i = ArrayUtil.indexOf(keys, keyCode);
    keys = ArrayUtil.remove(keys, i);
    values = ArrayUtil.remove(values, i);
    return new ArrayBackedFMap(keys, values);
  }
  return new MapBackedFMap(this, keyCode);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:MapBackedFMap.java

示例2: minus

import com.intellij.openapi.util.Key; //導入方法依賴的package包/類
@NotNull
@Override
public KeyFMap minus(@NotNull Key<?> key) {
  int oldSize = size();
  int keyCode = key.hashCode();
  for (int i = 0; i< oldSize; i++) {
    int oldKey = keys[i];
    if (keyCode == oldKey) {
      if (oldSize == 3) {
        int i1 = (2-i)/2;
        int i2 = 3 - (i+2)/2;
        Key<Object> key1 = Key.getKeyByIndex(keys[i1]);
        Key<Object> key2 = Key.getKeyByIndex(keys[i2]);
        if (key1 == null && key2 == null) return EMPTY_MAP;
        if (key1 == null) return new OneElementFMap<Object>(key2, values[i2]);
        if (key2 == null) return new OneElementFMap<Object>(key1, values[i1]);
        return new PairElementsFMap(key1, values[i1], key2, values[i2]);
      }
      int[] newKeys = ArrayUtil.remove(keys, i);
      Object[] newValues = ArrayUtil.remove(values, i, ArrayUtil.OBJECT_ARRAY_FACTORY);
      return new ArrayBackedFMap(newKeys, newValues);
    }
  }
  return this;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:ArrayBackedFMap.java

示例3: plus

import com.intellij.openapi.util.Key; //導入方法依賴的package包/類
@NotNull
@Override
public <V> KeyFMap plus(@NotNull Key<V> key, @NotNull V value) {
  if (key == key1) return new PairElementsFMap(key, value, key2, value2);
  if (key == key2) return new PairElementsFMap(key, value, key1, value1);
  return new ArrayBackedFMap(new int[]{key1.hashCode(), key2.hashCode(), key.hashCode()}, new Object[]{value1, value2, value});
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:PairElementsFMap.java

示例4: plus

import com.intellij.openapi.util.Key; //導入方法依賴的package包/類
@NotNull
@Override
public <V> KeyFMap plus(@NotNull Key<V> key, @NotNull V value) {
  int oldSize = size();
  int keyCode = key.hashCode();
  int[] newKeys = null;
  Object[] newValues = null;
  int i;
  for (i = 0; i < oldSize; i++) {
    int oldKey = keys[i];
    if (keyCode == oldKey) {
      if (value == values[i]) return this;
      newKeys = new int[oldSize];
      newValues = new Object[oldSize];
      System.arraycopy(keys, 0, newKeys, 0, oldSize);
      System.arraycopy(values, 0, newValues, 0, oldSize);
      newValues[i] = value;
      break;
    }
  }
  if (i == oldSize) {
    if (oldSize == ARRAY_THRESHOLD) {
      return new MapBackedFMap(keys, keyCode, values, value);
    }
    newKeys = ArrayUtil.append(keys, keyCode);
    newValues = ArrayUtil.append(values, value, ArrayUtil.OBJECT_ARRAY_FACTORY);
  }
  return new ArrayBackedFMap(newKeys, newValues);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:ArrayBackedFMap.java

示例5: get

import com.intellij.openapi.util.Key; //導入方法依賴的package包/類
@Override
public <V> V get(@NotNull Key<V> key) {
  int oldSize = size();
  int keyCode = key.hashCode();
  for (int i = 0; i < oldSize; i++) {
    int oldKey = keys[i];
    if (keyCode == oldKey) {
      //noinspection unchecked
      return (V)values[i];
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:ArrayBackedFMap.java


注:本文中的com.intellij.openapi.util.Key.hashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。