Java 类com.google.common.collect.ImmutableMapEntry.TerminalEntry 实例源码

项目:bts    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableMap(int size, TerminalEntry<?, ?>[] theEntries) {
  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")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) theEntries[entryIndex];
    K key = entry.getKey();
    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 = (existing == null)
        ? entry
        : new NonTerminalMapEntry<K, V>(entry, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:bts    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that makes no assumptions about the input entries.
 */
RegularImmutableMap(Entry<?, ?>[] theEntries) {
  int 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, 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 = (existing == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalMapEntry<K, V>(key, value, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:guava-libraries    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableMap(int size, TerminalEntry<?, ?>[] theEntries) {
  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")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) theEntries[entryIndex];
    K key = entry.getKey();
    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 = (existing == null)
        ? entry
        : new NonTerminalMapEntry<K, V>(entry, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInKeyBucket(key, newEntry, existing);
  }
}
项目:guava-libraries    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that makes no assumptions about the input entries.
 */
RegularImmutableMap(Entry<?, ?>[] theEntries) {
  int 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, 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 = (existing == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalMapEntry<K, V>(key, value, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInKeyBucket(key, newEntry, existing);
  }
}
项目:cnGuava    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableMap(int size, TerminalEntry<?, ?>[] theEntries) {
  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")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) theEntries[entryIndex];
    K key = entry.getKey();
    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 = (existing == null)
        ? entry
        : new NonTerminalMapEntry<K, V>(entry, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:cnGuava    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that makes no assumptions about the input entries.
 */
RegularImmutableMap(Entry<?, ?>[] theEntries) {
  int 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, 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 = (existing == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalMapEntry<K, V>(key, value, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:org.openntf.domino    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableMap(int size, TerminalEntry<?, ?>[] theEntries) {
  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")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) theEntries[entryIndex];
    K key = entry.getKey();
    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 = (existing == null)
        ? entry
        : new NonTerminalMapEntry<K, V>(entry, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:org.openntf.domino    文件:RegularImmutableMap.java   
/**
 * Constructor for RegularImmutableMap that makes no assumptions about the input entries.
 */
RegularImmutableMap(Entry<?, ?>[] theEntries) {
  int 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, 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 = (existing == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalMapEntry<K, V>(key, value, existing);
    table[tableIndex] = newEntry;
    entries[entryIndex] = newEntry;
    checkNoConflictInBucket(key, newEntry, existing);
  }
}
项目:bts    文件:ImmutableMap.java   
/**
 * Associates {@code key} with {@code value} in the built map. Duplicate
 * keys are not allowed, and will cause {@link #build} to fail.
 */
public Builder<K, V> put(K key, V value) {
  ensureCapacity(size + 1);
  TerminalEntry<K, V> entry = entryOf(key, value);
  // don't inline this: we want to fail atomically if key or value is null
  entries[size++] = entry;
  return this;
}
项目:guava-libraries    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableBiMap(int n, TerminalEntry<?, ?>[] entriesToAdd) {
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();

    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    checkNoConflictInKeyBucket(key, entry, nextInKeyBucket);
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    checkNoConflictInValueBucket(value, entry, nextInValueBucket);
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? entry
        : new NonTerminalBiMapEntry<K, V>(entry, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:guava-libraries    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that makes no assumptions about the input entries.
 */
RegularImmutableBiMap(Entry<?, ?>[] entriesToAdd) {
  int n = entriesToAdd.length;
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    Entry<K, V> entry = (Entry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key, value);
    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    checkNoConflictInKeyBucket(key, entry, nextInKeyBucket);
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    checkNoConflictInValueBucket(value, entry, nextInValueBucket);
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalBiMapEntry<K, V>(key, value, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:guava-libraries    文件:ImmutableMap.java   
/**
 * Associates {@code key} with {@code value} in the built map. Duplicate
 * keys are not allowed, and will cause {@link #build} to fail.
 */
public Builder<K, V> put(K key, V value) {
  ensureCapacity(size + 1);
  TerminalEntry<K, V> entry = entryOf(key, value);
  // don't inline this: we want to fail atomically if key or value is null
  entries[size++] = entry;
  return this;
}
项目:cnGuava    文件:ImmutableMap.java   
/**
 * Associates {@code key} with {@code value} in the built map. Duplicate
 * keys are not allowed, and will cause {@link #build} to fail.
 */
public Builder<K, V> put(K key, V value) {
  ensureCapacity(size + 1);
  TerminalEntry<K, V> entry = entryOf(key, value);
  // don't inline this: we want to fail atomically if key or value is null
  entries[size++] = entry;
  return this;
}
项目:org.openntf.domino    文件:ImmutableMap.java   
/**
 * Associates {@code key} with {@code value} in the built map. Duplicate
 * keys are not allowed, and will cause {@link #build} to fail.
 */
public Builder<K, V> put(K key, V value) {
  ensureCapacity(size + 1);
  TerminalEntry<K, V> entry = entryOf(key, value);
  // don't inline this: we want to fail atomically if key or value is null
  entries[size++] = entry;
  return this;
}
项目:bts    文件:RegularImmutableBiMap.java   
RegularImmutableBiMap(TerminalEntry<?, ?>... entriesToAdd) {
  this(entriesToAdd.length, entriesToAdd);
}
项目:bts    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableBiMap(int n, TerminalEntry<?, ?>[] entriesToAdd) {
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();

    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? entry
        : new NonTerminalBiMapEntry<K, V>(entry, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:bts    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that makes no assumptions about the input entries.
 */
RegularImmutableBiMap(Entry<?, ?>[] entriesToAdd) {
  int n = entriesToAdd.length;
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    Entry<K, V> entry = (Entry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key, value);
    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalBiMapEntry<K, V>(key, value, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:bts    文件:ImmutableMap.java   
@SuppressWarnings("unchecked")
Builder(int initialCapacity) {
  this.entries = new TerminalEntry[initialCapacity];
  this.size = 0;
}
项目:bts    文件:RegularImmutableMap.java   
RegularImmutableMap(TerminalEntry<?, ?>... theEntries) {
  this(theEntries.length, theEntries);
}
项目:guava-libraries    文件:RegularImmutableBiMap.java   
RegularImmutableBiMap(TerminalEntry<?, ?>... entriesToAdd) {
  this(entriesToAdd.length, entriesToAdd);
}
项目:guava-libraries    文件:ImmutableSortedMap.java   
private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V>
    ofEntries(TerminalEntry<K, V>... entries) {
  return fromEntries(Ordering.natural(), false, entries, entries.length);
}
项目:guava-libraries    文件:ImmutableMap.java   
@SuppressWarnings("unchecked")
Builder(int initialCapacity) {
  this.entries = new TerminalEntry[initialCapacity];
  this.size = 0;
}
项目:guava-libraries    文件:RegularImmutableMap.java   
RegularImmutableMap(TerminalEntry<?, ?>... theEntries) {
  this(theEntries.length, theEntries);
}
项目:cnGuava    文件:RegularImmutableBiMap.java   
RegularImmutableBiMap(TerminalEntry<?, ?>... entriesToAdd) {
  this(entriesToAdd.length, entriesToAdd);
}
项目:cnGuava    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableBiMap(int n, TerminalEntry<?, ?>[] entriesToAdd) {
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();

    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? entry
        : new NonTerminalBiMapEntry<K, V>(entry, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:cnGuava    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that makes no assumptions about the input entries.
 */
RegularImmutableBiMap(Entry<?, ?>[] entriesToAdd) {
  int n = entriesToAdd.length;
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    Entry<K, V> entry = (Entry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key, value);
    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalBiMapEntry<K, V>(key, value, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:cnGuava    文件:ImmutableMap.java   
@SuppressWarnings("unchecked")
Builder(int initialCapacity) {
  this.entries = new TerminalEntry[initialCapacity];
  this.size = 0;
}
项目:cnGuava    文件:RegularImmutableMap.java   
RegularImmutableMap(TerminalEntry<?, ?>... theEntries) {
  this(theEntries.length, theEntries);
}
项目:org.openntf.domino    文件:RegularImmutableBiMap.java   
RegularImmutableBiMap(TerminalEntry<?, ?>... entriesToAdd) {
  this(entriesToAdd.length, entriesToAdd);
}
项目:org.openntf.domino    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that takes as input an array of {@code TerminalEntry}
 * entries.  Assumes that these entries have already been checked for null.
 * 
 * <p>This allows reuse of the entry objects from the array in the actual implementation.
 */
RegularImmutableBiMap(int n, TerminalEntry<?, ?>[] entriesToAdd) {
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    TerminalEntry<K, V> entry = (TerminalEntry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();

    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? entry
        : new NonTerminalBiMapEntry<K, V>(entry, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:org.openntf.domino    文件:RegularImmutableBiMap.java   
/**
 * Constructor for RegularImmutableBiMap that makes no assumptions about the input entries.
 */
RegularImmutableBiMap(Entry<?, ?>[] entriesToAdd) {
  int n = entriesToAdd.length;
  int tableSize = Hashing.closedTableSize(n, MAX_LOAD_FACTOR);
  this.mask = tableSize - 1;
  ImmutableMapEntry<K, V>[] keyTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] valueTable = createEntryArray(tableSize);
  ImmutableMapEntry<K, V>[] entries = createEntryArray(n);
  int hashCode = 0;

  for (int i = 0; i < n; i++) {
    @SuppressWarnings("unchecked")
    Entry<K, V> entry = (Entry<K, V>) entriesToAdd[i];
    K key = entry.getKey();
    V value = entry.getValue();
    checkEntryNotNull(key, value);
    int keyHash = key.hashCode();
    int valueHash = value.hashCode();
    int keyBucket = Hashing.smear(keyHash) & mask;
    int valueBucket = Hashing.smear(valueHash) & mask;

    ImmutableMapEntry<K, V> nextInKeyBucket = keyTable[keyBucket];
    for (ImmutableMapEntry<K, V> keyEntry = nextInKeyBucket; keyEntry != null;
         keyEntry = keyEntry.getNextInKeyBucket()) {
      checkNoConflict(!key.equals(keyEntry.getKey()), "key", entry, keyEntry);
    }
    ImmutableMapEntry<K, V> nextInValueBucket = valueTable[valueBucket];
    for (ImmutableMapEntry<K, V> valueEntry = nextInValueBucket; valueEntry != null;
         valueEntry = valueEntry.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueEntry.getValue()), "value", entry, valueEntry);
    }
    ImmutableMapEntry<K, V> newEntry =
        (nextInKeyBucket == null && nextInValueBucket == null)
        ? new TerminalEntry<K, V>(key, value)
        : new NonTerminalBiMapEntry<K, V>(key, value, nextInKeyBucket, nextInValueBucket);
    keyTable[keyBucket] = newEntry;
    valueTable[valueBucket] = newEntry;
    entries[i] = newEntry;
    hashCode += keyHash ^ valueHash;
  }

  this.keyTable = keyTable;
  this.valueTable = valueTable;
  this.entries = entries;
  this.hashCode = hashCode;
}
项目:org.openntf.domino    文件:ImmutableMap.java   
@SuppressWarnings("unchecked")
Builder(int initialCapacity) {
  this.entries = new TerminalEntry[initialCapacity];
  this.size = 0;
}
项目:org.openntf.domino    文件:RegularImmutableMap.java   
RegularImmutableMap(TerminalEntry<?, ?>... theEntries) {
  this(theEntries.length, theEntries);
}
项目:bts    文件:ImmutableMap.java   
/**
 * Verifies that {@code key} and {@code value} are non-null, and returns a new
 * immutable entry with those values.
 *
 * <p>A call to {@link Map.Entry#setValue} on the returned entry will always
 * throw {@link UnsupportedOperationException}.
 */
static <K, V> TerminalEntry<K, V> entryOf(K key, V value) {
  checkEntryNotNull(key, value);
  return new TerminalEntry<K, V>(key, value);
}
项目:guava-libraries    文件:ImmutableMap.java   
/**
 * Verifies that {@code key} and {@code value} are non-null, and returns a new
 * immutable entry with those values.
 *
 * <p>A call to {@link Map.Entry#setValue} on the returned entry will always
 * throw {@link UnsupportedOperationException}.
 */
static <K, V> TerminalEntry<K, V> entryOf(K key, V value) {
  return new TerminalEntry<K, V>(key, value);
}
项目:cnGuava    文件:ImmutableMap.java   
/**
 * Verifies that {@code key} and {@code value} are non-null, and returns a new
 * immutable entry with those values.
 *
 * <p>A call to {@link Map.Entry#setValue} on the returned entry will always
 * throw {@link UnsupportedOperationException}.
 */
static <K, V> TerminalEntry<K, V> entryOf(K key, V value) {
  checkEntryNotNull(key, value);
  return new TerminalEntry<K, V>(key, value);
}
项目:org.openntf.domino    文件:ImmutableMap.java   
/**
 * Verifies that {@code key} and {@code value} are non-null, and returns a new
 * immutable entry with those values.
 *
 * <p>A call to {@link Map.Entry#setValue} on the returned entry will always
 * throw {@link UnsupportedOperationException}.
 */
static <K, V> TerminalEntry<K, V> entryOf(K key, V value) {
  checkEntryNotNull(key, value);
  return new TerminalEntry<K, V>(key, value);
}