微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.google.common.collect.ImmutableMapEntry.NonTerminalImmutableMapEntry的实例源码

项目:guava-mock    文件RegularImmutableMap.java   
/**
 * Creates a RegularImmutableMap from the first n entries in entryArray.  This implementation
 * may replace the entries in entryArray with its own entry objects (though they will have the
 * same key/value contents),and may take ownership of entryArray.
 */
static <K,V> RegularImmutableMap<K,V> fromEntryArray(int n,Entry<K,V>[] entryArray) {
  checkPositionIndex(n,entryArray.length);
  if (n == 0) {
    return (RegularImmutableMap<K,V>) EMPTY;
  }
  Entry<K,V>[] entries;
  if (n == entryArray.length) {
    entries = entryArray;
  } else {
    entries = createEntryArray(n);
  }
  int tableSize = Hashing.closedTableSize(n,MAX_LOAD_FACTOR);
  ImmutableMapEntry<K,V>[] table = createEntryArray(tableSize);
  int mask = tableSize - 1;
  for (int entryIndex = 0; entryIndex < n; entryIndex++) {
    Entry<K,V> entry = entryArray[entryIndex];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key,value);
    int tableIndex = Hashing.smear(key.hashCode()) & mask;
    @Nullable ImmutableMapEntry<K,V> existing = table[tableIndex];
    // prepend,not append,so the entries can be immutable
    ImmutableMapEntry<K,V> newEntry;
    if (existing == null) {
      boolean reusable =
          entry instanceof ImmutableMapEntry && ((ImmutableMapEntry<K,V>) entry).isReusable();
      newEntry =
          reusable ? (ImmutableMapEntry<K,V>) entry : new ImmutableMapEntry<K,V>(key,value);
    } else {
      newEntry = new NonTerminalImmutableMapEntry<K,value,existing);
    }
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInKeyBucket(key,newEntry,existing);
  }
  return new RegularImmutableMap<K,V>(entries,table,mask);
}
项目:googles-monorepo-demo    文件RegularImmutableMap.java   
/**
 * Creates a RegularImmutableMap from the first n entries in entryArray.  This implementation
 * may replace the entries in entryArray with its own entry objects (though they will have the
 * same key/value contents),entryArray.length);
  Entry<K,mask);
}
项目:codebuff    文件RegularImmutableMap.java   
/**
   * Creates a RegularImmutableMap from the first n entries in entryArray.  This implementation
   * may replace the entries in entryArray with its own entry objects (though they will have the
   * same key/value contents),and may take ownership of entryArray.
   */


  static <K,V>[] entryArray) {
    checkPositionIndex(n,entryArray.length);
    Entry<K,V>[] entries;
    if (n == entryArray.length) {
      entries = entryArray;
    } else {
      entries = createEntryArray(n);
    }
    int tableSize = Hashing.closedTableSize(n,MAX_LOAD_FACTOR);
    ImmutableMapEntry<K,V>[] table = createEntryArray(tableSize);
    int mask = tableSize - 1;
    for (int entryIndex = 0; entryIndex < n; entryIndex++) {
      Entry<K,V> entry = entryArray[entryIndex];
      K key = entry.getKey();
      V value = entry.getValue();
      checkEntryNotNull(key,value);
      int tableIndex = Hashing.smear(key.hashCode()) & mask;
      @Nullable ImmutableMapEntry<K,V> existing = table[tableIndex];
      // prepend,so the entries can be immutable
      ImmutableMapEntry<K,V> newEntry;
      if (existing == null) {
        boolean reusable =
          entry instanceof ImmutableMapEntry
&& ((ImmutableMapEntry<K,V>) entry).isReusable();
        newEntry = reusable ? (ImmutableMapEntry<K,value);
      } else {
        newEntry = new NonTerminalImmutableMapEntry<K,existing);
      }
      table[tableIndex] = newEntry;
      entries[entryIndex] = newEntry;
      checkNoConflictInKeyBucket(key,existing);
    }
    return new RegularImmutableMap<K,mask);
  }
项目:codebuff    文件RegularImmutableMap.java   
/**
 * Creates a RegularImmutableMap from the first n entries in entryArray.  This implementation
 * may replace the entries in entryArray with its own entry objects (though they will have the
 * same key/value contents),and may take ownership of entryArray.
 */


static <K,V> newEntry;
    if (existing == null) {
      boolean reusable =
        entry instanceof ImmutableMapEntry
        && ((ImmutableMapEntry<K,V>) entry).isReusable();
      newEntry = reusable ? (ImmutableMapEntry<K,mask);
}
项目:codebuff    文件RegularImmutableMap.java   
/**
 * Creates a RegularImmutableMap from the first n entries in entryArray.  This implementation
 * may replace the entries in entryArray with its own entry objects (though they will have the
 * same key/value contents),mask);
}
项目:VectorAttackScanner    文件RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that makes no assumptions about the input entries.
 */
RegularImmutableMap(int size,Entry<?,?>[] theEntries) {
  checkPositionIndex(size,theEntries.length);
  entries = createEntryArray(size);
  int tableSize = Hashing.closedTableSize(size,MAX_LOAD_FACTOR);
  table = createEntryArray(tableSize);
  mask = tableSize - 1;
  for (int entryIndex = 0; entryIndex < size; entryIndex++) {
    @SuppressWarnings("unchecked") // all our callers carefully put in only Entry<K,V>s
    Entry<K,V> entry = (Entry<K,V>) theEntries[entryIndex];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key,V> newEntry;
    if (existing == null) {
      boolean reusable = entry instanceof ImmutableMapEntry 
          && ((ImmutableMapEntry<K,existing);
  }
}
项目:guava    文件RegularImmutableMap.java   
/**
 * Creates an ImmutableMap from the first n entries in entryArray. This implementation may replace
 * the entries in entryArray with its own entry objects (though they will have the same key/value
 * contents),V> ImmutableMap<K,value);
    int tableIndex = Hashing.smear(key.hashCode()) & mask;
    @NullableDecl ImmutableMapEntry<K,V> newEntry =
        (existing == null)
            ? makeImmutable(entry,key,value)
            : new NonTerminalImmutableMapEntry<K,existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    int bucketSize = checkNoConflictInKeyBucket(key,existing);
    if (bucketSize > MAX_HASH_BUCKET_LENGTH) {
      // probable hash flooding attack,fall back to j.u.HM based implementation and use its
      // implementation of hash flooding protection
      return JdkBackedImmutableMap.create(n,entryArray);
    }
  }
  return new RegularImmutableMap<>(entries,mask);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。