Creates a {@link RubyHash} by given key-value pair.

@param <K>
the type of the key elements
@param <V>
the type of the value elements
@param key
of entry
@param value
of entry
@return {@link RubyHash}
973701
public static <K, V> RubyHash<K, V> rh(K key, V value) {
    RubyHash<K, V> rh = newRubyHash();
    rh.put(key, value);
    return rh;
  }
643832
@VisibleForTesting
  ReferenceEntry<K, V> newEntry(K key, int hash, @Nullable ReferenceEntry<K, V> next) {
    return segmentFor(hash).newEntry(key, hash, next);
  }
517158
@SuppressWarnings("unchecked")
    static final <K,V> HashEntry<K,V> entryForHash(Segment<K,V> seg, int h) {
        HashEntry<K,V>[] tab;
        return (seg == null || (tab = seg.table) == null) ? null :
            (HashEntry<K,V>) UNSAFE.getObjectVolatile
            (tab, ((long)(((tab.length - 1) & h)) << TSHIFT) + TBASE);
    }
723455
public static <K, V> HashMap<K, V> newHashMap(K key, V value) {
        HashMap<K, V> map = new HashMap<K, V>();
        map.put(key, value);
        return map;
    }
780972
public int[] hash(Key k){
      byte[] b = k.getBytes();
      if (b == null) {
        throw new NullPointerException("buffer reference is null");
      }
      if (b.length == 0) {
        throw new IllegalArgumentException("key length must be > 0");
      }
      int[] result = new int[nbHash];
      for (int i = 0, initval = 0; i < nbHash; i++) {
	  initval = hashFunction.hash(b, initval);
	  result[i] = Math.abs(initval % maxValue);
      }
      return result;
  }
1037744
public T put(final T value) {
		expungeStaleEntries();
		//
		final int hash = value.hashCode();
		int index = (hash & 0x7FFFFFFF) % elementData.length;
		Entry<T> entry = elementData[index];
		while (entry != null && !eq(value, entry.get())) {
			entry = entry.nextInSlot;
		}

		if (entry == null) {
			if (++elementCount > threshold) {
				expandElementArray(elementData.length);
				index = (hash & 0x7FFFFFFF) % elementData.length;
			}
			entry = createHashedEntry(value, index);
			return null;
		}

		final T result = entry.get();
		return result;
	}
577889
@Override
    void createEntry(int hash, K key, V value, int bucketIndex) {
	HashMapPro.Entry<K, V> old = table[bucketIndex];
	Entry<K, V> e = new Entry<K, V>(hash, key, value, old);
	table[bucketIndex] = e;
	e.addBefore(header);
	size++;
    }
1224961
public static <K> int hash(final K value, final int mask)
    {
        final int hash = value.hashCode();

        return hash & mask;
    }
1051996
public static Expression newLinkedHashMap(
      Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
    return newMap(keys, values, ConstructorRef.LINKED_HASH_MAP_CAPACITY, LINKED_HASH_MAP_TYPE);
  }
101972
@SuppressWarnings("MagicNumber")
    public static int calculateHashCode(Map<? extends CharSequence, Object> values) {
        int hashCode = 0;

        for (Map.Entry<? extends CharSequence, Object> member : values.entrySet()) {
            Object value = member.getValue();

            int nameHashCode = member.getKey().hashCode();

            int valueHashCode =
                !value.getClass().isArray() ? value.hashCode() :
                    value.getClass() == boolean[].class ? Arrays.hashCode((boolean[]) value) :
                        value.getClass() == byte[].class ? Arrays.hashCode((byte[]) value) :
                            value.getClass() == char[].class ? Arrays.hashCode((char[]) value) :
                                value.getClass() == double[].class ? Arrays.hashCode((double[]) value) :
                                    value.getClass() == float[].class ? Arrays.hashCode((float[]) value) :
                                        value.getClass() == int[].class ? Arrays.hashCode((int[]) value) :
                                            value.getClass() == long[].class ? Arrays.hashCode(
                                                (long[]) value
                                            ) :
                                                value.getClass() == short[].class ? Arrays
                                                    .hashCode((short[]) value) :
                                                    Arrays.hashCode((Object[]) value);

            hashCode += 127 * nameHashCode ^ valueHashCode;
        }

        return hashCode;
    }
353395
public Object put(String key, JsonHash value) {
		if (value == null) {
			stateMap.put(key, Type.NULL);
		} else {
			stateMap.put(key, Type.HASH);
		}

		return super.put(key, value);
	}
198116
def to_hash_with_values
      keys = table_header_keys
      values = self
      @hash_with_values = {}
      keys.each_with_index {|k,i| v=values[i]; v=v.value if v; @hash_with_values[k]=v}
      return @hash_with_values
    end
77271
private static int memberValueHashCode(Object value) {
		Class<?> type = value.getClass();
		if (!type.isArray()) // primitive, string, class, enum const,
								// or annotation
			return value.hashCode();

		if (type == byte[].class)
			return Arrays.hashCode((byte[]) value);
		if (type == char[].class)
			return Arrays.hashCode((char[]) value);
		if (type == double[].class)
			return Arrays.hashCode((double[]) value);
		if (type == float[].class)
			return Arrays.hashCode((float[]) value);
		if (type == int[].class)
			return Arrays.hashCode((int[]) value);
		if (type == long[].class)
			return Arrays.hashCode((long[]) value);
		if (type == short[].class)
			return Arrays.hashCode((short[]) value);
		if (type == boolean[].class)
			return Arrays.hashCode((boolean[]) value);
		return Arrays.hashCode((Object[]) value);
	}
847320
def hash_of?(key_clause, value_clause)
      all_keys   = many_with_map?(key_clause, "all keys")     { |kv| kv[0] }
      all_values = many_with_map?(value_clause, "all values") { |kv| kv[1] }
      all? Hash, all_keys, all_values
    end
441723
function (ki, key, value, index, literal) {
		// ki is the key information from _find_key
		var i, value_hash, vhash_val, info,
			key_index = ki.i, // where the key is in the hash array
			hash_values = ki.hv, // the hash array
			hash = ki.h; // the hash value

		if (key_index >= 0) { // The key was already in this map
			// get the information
			info = hash_values[key_index];

			if (this._vhash) { // If we're hashing values, the new value has to get re-hashed
				var old_value = info.value.get(),
					old_value_hash = this._valuehash(old_value),
					old_vhash_val = this._vhash[old_value_hash];
				value_hash = this._valuehash(value);

				if (old_vhash_val) { // This should probably always be true, unless something went wrong...
					var len = old_vhash_val.length;
					for (i = 0; i < len; i += 1) {
						if (old_vhash_val[i] === info) { // wohoo, found it
							old_vhash_val.splice(i, 1);
							if (old_vhash_val.length === 0) {
								delete this._vhash[old_value_hash]; // don't keep the old hash array
							}
							break;
						}
					}
				}

				// Put the new value has in
				vhash_val = this._vhash[value_hash]; // hash array
				if (vhash_val) {
					vhash_val.push(info); // add onto the hash array
				} else {
					this._vhash[value_hash] = [info]; // create a new hash array
				}
			}

			info.value.set(value); // set the value constraint to the new value

			if (isPositiveInteger(index)) { // But they also specified an index...
				var old_index = info.index.get();
				if(old_index !== index) { // great...now we have to move it too
					// take out the old value
					this._ordered_values.splice(old_index, 1);
					// and re-add it
					this._ordered_values.splice(index, 0, info);

					// Properly iterate regardless of whether moving higher or lower
					var low = Math.min(old_index, index);
					var high = Math.max(old_index, index);
					// update the indicies of every thing between that might have been affected
					for (i = low; i <= high; i += 1) {
						_set_index(this._ordered_values[i], i);
					}
					this.$keys.invalidate(); // Keys are now invalid
				}
			}
		} else {
			// They didn't specify an index or at least they specified it wrong...
			if (!isPositiveInteger(index)) {
				index = this._ordered_values.length; // just set it to the 
			}
			// Check to see if there was an unsubstantiated item
			var unsubstantiated_index = ki.ui;

			if (unsubstantiated_index >= 0) { // Found it! Now let's remove it from the list of unsubstantiated items
				var unsubstantiated_hash_values = ki.uhv,
					unsubstantiated_info = unsubstantiated_hash_values[unsubstantiated_index];

				unsubstantiated_hash_values.splice(unsubstantiated_index, 1);
				if (unsubstantiated_hash_values.length === 0) {
					delete this._unsubstantiated_values[hash];
				}

				info = unsubstantiated_info; // re-use the same object to keep dependencies
			} else {
				// Nothing in unsubstantiated; just create it from scratch
				info = {
					key: new Constraint(key, {literal: true}),
					value: new Constraint(value, {literal: literal === undefined ? this._default_literal_values : !!literal}),
					index: new Constraint(index, {literal: true})
				};
			}

			if(hash_values) { // There was already a hash array
				hash_values.push(info);
			} else { // Have to create the hash array
				hash_values = this._khash[hash] = [info];
			}

			//If we're hashing values...
			if (this._vhash) {
				value_hash = this._valuehash(value);
				vhash_val = this._vhash[value_hash];
				// Add the item to the value hash
				if (vhash_val) {
					vhash_val.push(info);
				} else {
					this._vhash[value_hash] = [info];
				}
			}

			//  insert into values
			this._ordered_values.splice(index, 0, info);

			if (unsubstantiated_index >= 0) {
				info.value.set(value); // but update its value and index
				info.index.set(index);
			}

			// Push the index of every item that I spliced before up
			for (i = index + 1; i < this._ordered_values.length; i += 1) {
				_set_index(this._ordered_values[i], i);
			}
			// Now, size and keys are invalid
			this.$size.invalidate();
			this.$keys.invalidate();
		}
		this.$values.invalidate();
		this.$entries.invalidate();
	}
1324537
private static <K, V> Map.Entry<K, V> createEntry(K key, V value) {
		return new Map.Entry<K, V>() {
			@Override
			public K getKey() {
				return key;
			}

			@Override
			public V getValue() {
				return value;
			}

			@Override
			public V setValue(V value) {
				throw new UnsupportedOperationException();
			}
		};
	}
951236
public static <K, V> HashMap<K, V> newHashMap(@NotNull final K[] keys, @NotNull final V[] values) {
		Validate.isTrue(keys.length == values.length, "keys.length is %d but values.length is %d", keys.length,
				values.length);

		HashMap<K, V> map = new HashMap<K, V>(keys.length * 2);

		for (int i = 0; i < keys.length; i++) {
			map.put(keys[i], values[i]);
		}

		return map;
	}