Tabnine Logo
Object2ShortOpenHashMap
Code IndexAdd Tabnine to your IDE (free)

How to use
Object2ShortOpenHashMap
in
it.unimi.dsi.fastutil.objects

Best Java code snippets using it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap (Showing top 20 results out of 315)

origin: jtablesaw/tablesaw

@Override
public void clear() {
  values.clear();
  keyToValue.clear();
  valueToKey.clear();
}
origin: jtablesaw/tablesaw

private void put(short key, String value) {
  keyToValue.put(key, value);
  valueToKey.put(value, key);
}
origin: jtablesaw/tablesaw

/**
 * Returns true if we have seen this stringValue before, and it hasn't been removed.
 * <p>
 * NOTE: An answer of true does not imply that the column still contains the value, only that
 * it is in the dictionary map
 */
private boolean contains(String stringValue) {
  return valueToKey.containsKey(stringValue);
}
origin: padreati/rapaio

private VarNominal() {
  this.reverse = new Object2ShortOpenHashMap<>();
  this.reverse.put("?", (short) 0);
  this.dict = new ArrayList<>();
  this.dict.add("?");
  data = new short[0];
  rows = 0;
}
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public short mergeShort(final K k, final short v,
    final java.util.function.BiFunction<? super Short, ? super Short, ? extends Short> remappingFunction) {
  java.util.Objects.requireNonNull(remappingFunction);
  final int pos = find(k);
  if (pos < 0) {
    insert(-pos - 1, k, v);
    return v;
  }
  final Short newValue = remappingFunction.apply(Short.valueOf(value[pos]), Short.valueOf(v));
  if (newValue == null) {
    if (((k) == null))
      removeNullEntry();
    else
      removeEntry(pos);
    return defRetValue;
  }
  return value[pos] = (newValue).shortValue();
}
/*
origin: it.unimi.dsi/fastutil

@Override
public void putAll(Map<? extends K, ? extends Short> m) {
  if (f <= .5)
    ensureCapacity(m.size()); // The resulting map will be sized for m.size() elements
  else
    tryCapacity(size() + m.size()); // The resulting map will be tentatively sized for size() + m.size()
                    // elements
  super.putAll(m);
}
@SuppressWarnings("unchecked")
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public short computeShortIfPresent(final K k,
    final java.util.function.BiFunction<? super K, ? super Short, ? extends Short> remappingFunction) {
  java.util.Objects.requireNonNull(remappingFunction);
  final int pos = find(k);
  if (pos < 0)
    return defRetValue;
  final Short newValue = remappingFunction.apply((k), Short.valueOf(value[pos]));
  if (newValue == null) {
    if (((k) == null))
      removeNullEntry();
    else
      removeEntry(pos);
    return defRetValue;
  }
  return value[pos] = (newValue).shortValue();
}
/** {@inheritDoc} */
origin: it.unimi.dsi/fastutil

@Override
public short put(final K k, final short v) {
  final int pos = find(k);
  if (pos < 0) {
    insert(-pos - 1, k, v);
    return defRetValue;
  }
  final short oldValue = value[pos];
  value[pos] = v;
  return oldValue;
}
private short addToValue(final int pos, final short incr) {
origin: it.unimi.dsi/fastutil

if (((k) == null)) {
  if (containsNullKey)
    return addToValue(n, incr);
  pos = n;
  containsNullKey = true;
      return addToValue(pos, incr);
    while (!((curr = key[pos = (pos + 1) & mask]) == null))
      if (((curr).equals(k)))
        return addToValue(pos, incr);
value[pos] = (short) (defRetValue + incr);
if (size++ >= maxFill)
  rehash(arraySize(size + 1, f));
if (ASSERTS)
  checkTable();
origin: jtablesaw/tablesaw

/**
 * Returns a new DictionaryMap that is a deep copy of the original
 */
ShortDictionaryMap(DictionaryMap original) throws NoKeysAvailableException {
  valueToKey.defaultReturnValue(DEFAULT_RETURN_VALUE);
  for (int i = 0; i < original.size(); i++) {
    String value = original.getValueForIndex(i);
    append(value);
  }
}
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public short replace(final K k, final short v) {
  final int pos = find(k);
  if (pos < 0)
    return defRetValue;
  final short oldValue = value[pos];
  value[pos] = v;
  return oldValue;
}
/** {@inheritDoc} */
origin: it.unimi.dsi/fastutil

@Override
public boolean contains(short v) {
  return containsValue(v);
}
@Override
origin: padreati/rapaio

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  rows = in.readInt();
  dict = new ArrayList<>();
  reverse = new Object2ShortOpenHashMap<>();
  int len = in.readInt();
  for (int i = 0; i < len; i++) {
    dict.add(in.readUTF());
    reverse.put(dict.get(i), (short) i);
  }
  data = new short[rows];
  for (int i = 0; i < rows; i++) {
    data[i] = in.readShort();
  }
}
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public short computeShort(final K k,
    final java.util.function.BiFunction<? super K, ? super Short, ? extends Short> remappingFunction) {
  java.util.Objects.requireNonNull(remappingFunction);
  final int pos = find(k);
  final Short newValue = remappingFunction.apply((k), pos >= 0 ? Short.valueOf(value[pos]) : null);
  if (newValue == null) {
    if (pos >= 0) {
      if (((k) == null))
        removeNullEntry();
      else
        removeEntry(pos);
    }
    return defRetValue;
  }
  short newVal = (newValue).shortValue();
  if (pos < 0) {
    insert(-pos - 1, k, newVal);
    return newVal;
  }
  return value[pos] = newVal;
}
/** {@inheritDoc} */
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public short putIfAbsent(final K k, final short v) {
  final int pos = find(k);
  if (pos >= 0)
    return value[pos];
  insert(-pos - 1, k, v);
  return defRetValue;
}
/** {@inheritDoc} */
origin: tech.tablesaw/tablesaw-core

/**
 * Returns a new DictionaryMap that is a deep copy of the original
 */
ShortDictionaryMap(DictionaryMap original) throws NoKeysAvailableException {
  valueToKey.defaultReturnValue(DEFAULT_RETURN_VALUE);
  for (int i = 0; i < original.size(); i++) {
    String value = original.getValueForIndex(i);
    append(value);
  }
}
origin: it.unimi.dsi/fastutil

/** {@inheritDoc} */
@Override
public boolean replace(final K k, final short oldValue, final short v) {
  final int pos = find(k);
  if (pos < 0 || !((oldValue) == (value[pos])))
    return false;
  value[pos] = v;
  return true;
}
/** {@inheritDoc} */
origin: padreati/rapaio

@Override
public void setLevels(String... dict) {
  List<String> oldDict = this.dict;
  if (dict.length > 0 && !dict[0].equals("?")) {
    String[] newDict = new String[dict.length + 1];
    newDict[0] = "?";
    System.arraycopy(dict, 0, newDict, 1, dict.length);
    dict = newDict;
  }
  if (this.dict.size() > dict.length) {
    throw new IllegalArgumentException("new levels does not contains all old labels");
  }
  this.dict = new ArrayList<>();
  this.reverse = new Object2ShortOpenHashMap<>(dict.length);
  this.dict.add("?");
  this.reverse.put("?", (short) 0);
  short[] pos = new short[oldDict.size()];
  for (int i = 0; i < dict.length; i++) {
    String term = dict[i];
    if (!reverse.containsKey(term)) {
      this.dict.add(term);
      this.reverse.put(term, (short) this.reverse.size());
    }
    if (i < oldDict.size())
      pos[i] = this.reverse.getShort(term);
  }
  for (int i = 0; i < rows; i++) {
    data[i] = pos[data[i]];
  }
}
origin: it.unimi.dsi/fastutil

@Override
public void clear() {
  Object2ShortOpenHashMap.this.clear();
}
/** {@inheritDoc} */
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash map using the elements of two parallel arrays.
 *
 * @param k
 *            the array of keys of the new hash map.
 * @param v
 *            the array of corresponding values in the new hash map.
 * @param f
 *            the load factor.
 * @throws IllegalArgumentException
 *             if {@code k} and {@code v} have different lengths.
 */
public Object2ShortOpenHashMap(final K[] k, final short[] v, final float f) {
  this(k.length, f);
  if (k.length != v.length)
    throw new IllegalArgumentException(
        "The key array and the value array have different lengths (" + k.length + " and " + v.length + ")");
  for (int i = 0; i < k.length; i++)
    this.put(k[i], v[i]);
}
/**
it.unimi.dsi.fastutil.objectsObject2ShortOpenHashMap

Javadoc

A type-specific hash map with a fast, small-footprint implementation.

Instances of this class use a hash table to represent a map. The table is filled up to a specified load factor, and then doubled in size to accommodate new entries. If the table is emptied below one fourth of the load factor, it is halved in size; however, the table is never reduced to a size smaller than that at creation time: this approach makes it possible to create maps with a large capacity in which insertions and deletions do not cause immediately rehashing. Moreover, halving is not performed when deleting entries from an iterator, as it would interfere with the iteration process.

Note that #clear() does not modify the hash table size. Rather, a family of #trim() lets you control the size of the table; this is particularly useful if you reuse instances of this class.

Most used methods

  • <init>
    Creates a new hash map using the elements of two parallel arrays.
  • clear
  • put
  • addToValue
  • containsKey
  • containsValue
  • defaultReturnValue
  • ensureCapacity
  • find
  • getShort
  • insert
  • keySet
  • insert,
  • keySet,
  • putAll,
  • realSize,
  • rehash,
  • removeEntry,
  • removeNullEntry,
  • shiftKeys,
  • size,
  • tryCapacity

Popular in Java

  • Making http post requests using okhttp
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Collectors (java.util.stream)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now