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

How to use
ShortOpenHashSet
in
it.unimi.dsi.fastutil.shorts

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

origin: jtablesaw/tablesaw

@Override
public Selection selectIsIn(Collection<String> strings) {
  ShortOpenHashSet keys = new ShortOpenHashSet(strings.size());
  for (String string : strings) {
    short key = getKeyForValue(string);
    if (key != DEFAULT_RETURN_VALUE) {
      keys.add(key);
    }
  }
  Selection results = new BitmapBackedSelection();
  for (int i = 0; i < values.size(); i++) {
    if (keys.contains(values.getShort(i))) {
      results.add(i);
    }
  }
  return results;
}
origin: jtablesaw/tablesaw

@Override
public int countUnique() {
  ShortSet uniqueElements = new ShortOpenHashSet();
  for (int i = 0; i < size(); i++) {
    short val = getShort(i);
    if (!isMissingValue(val)) {
      uniqueElements.add(val);
    }
  }
  return uniqueElements.size();
}
origin: it.unimi.dsi/fastutil

@Override
public boolean addAll(Collection<? extends Short> c) {
  // The resulting collection will be at least c.size() big
  if (f <= .5)
    ensureCapacity(c.size()); // The resulting collection will be sized for c.size() elements
  else
    tryCapacity(size() + c.size()); // The resulting collection will be tentatively sized for size() + c.size()
                    // elements
  return super.addAll(c);
}
@Override
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash set and fills it with the elements of a given array.
 *
 * @param a
 *            an array whose elements will be used to fill the set.
 * @param offset
 *            the first element to use.
 * @param length
 *            the number of elements to use.
 * @param f
 *            the load factor.
 */
public ShortOpenHashSet(final short[] a, final int offset, final int length, final float f) {
  this(length < 0 ? 0 : length, f);
  ShortArrays.ensureOffsetLength(a, offset, length);
  for (int i = 0; i < length; i++)
    add(a[offset + i]);
}
/**
origin: it.unimi.dsi/fastutil

private boolean removeEntry(final int pos) {
  size--;
  shiftKeys(pos);
  if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE)
    rehash(n / 2);
  return true;
}
private boolean removeNullEntry() {
origin: it.unimi.dsi/fastutil

private boolean removeNullEntry() {
  containsNull = false;
  key[n] = ((short) 0);
  size--;
  if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE)
    rehash(n / 2);
  return true;
}
origin: com.senseidb/sensei-core

@Override
public boolean containsAny(Object set) {
 ShortOpenHashSet setShort = (ShortOpenHashSet) set;
 for (int i = 0; i < this._length; i++)
  if (setShort.contains(((TermShortList) _mTermList).getPrimitiveValue(_buf[i]))) return true;
 return false;
}
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash set copying a given collection.
 *
 * @param c
 *            a {@link Collection} to be copied into the new hash set.
 * @param f
 *            the load factor.
 */
public ShortOpenHashSet(final Collection<? extends Short> c, final float f) {
  this(c.size(), f);
  addAll(c);
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Returns a hash code for this set.
 *
 * This method overrides the generic method provided by the superclass. Since
 * {@code equals()} is not overriden, it is important that the value returned by
 * this method is the same value as the one returned by the overriden method.
 *
 * @return a hash code for this set.
 */
@Override
public int hashCode() {
  int h = 0;
  for (int j = realSize(), i = 0; j-- != 0;) {
    while (((key[i]) == ((short) 0)))
      i++;
    h += (key[i]);
    i++;
  }
  // Zero / null have hash zero.
  return h;
}
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
origin: it.unimi.dsi/fastutil

private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
  final ShortIterator i = iterator();
  s.defaultWriteObject();
  for (int j = size; j-- != 0;)
    s.writeShort(i.nextShort());
}
origin: it.unimi.dsi/fastutil

  @Override
  public void remove() {
    if (last == -1)
      throw new IllegalStateException();
    if (last == n) {
      ShortOpenHashSet.this.containsNull = false;
      ShortOpenHashSet.this.key[n] = ((short) 0);
    } else if (pos >= 0)
      shiftKeys(last);
    else {
      // We're removing wrapped entries.
      ShortOpenHashSet.this.remove(wrapped.getShort(-pos - 1));
      last = -1; // Note that we must not decrement size
      return;
    }
    size--;
    last = -1; // You can no longer remove this entry.
    if (ASSERTS)
      checkTable();
  }
}
origin: jtablesaw/tablesaw

@Override
public ShortColumn unique() {
  final ShortSet values = new ShortOpenHashSet();
  for (int i = 0; i < size(); i++) {
    if (!isMissing(i)) {
      values.add(getShort(i));
    }
  }
  final ShortColumn column = ShortColumn.create(name() + " Unique values");
  for (short value : values) {
    column.append(value);
  }
  return column;
}
origin: it.unimi.dsi/fastutil

@Override
public boolean addAll(ShortCollection c) {
  if (f <= .5)
    ensureCapacity(c.size()); // The resulting collection will be sized for c.size() elements
  else
    tryCapacity(size() + c.size()); // The resulting collection will be tentatively sized for size() + c.size()
                    // elements
  return super.addAll(c);
}
@Override
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash set using elements provided by a type-specific iterator.
 *
 * @param i
 *            a type-specific iterator whose elements will fill the set.
 * @param f
 *            the load factor.
 */
public ShortOpenHashSet(final ShortIterator i, final float f) {
  this(DEFAULT_INITIAL_SIZE, f);
  while (i.hasNext())
    add(i.nextShort());
}
/**
origin: it.unimi.dsi/fastutil

private void ensureCapacity(final int capacity) {
  final int needed = arraySize(capacity, f);
  if (needed > n)
    rehash(needed);
}
private void tryCapacity(final long capacity) {
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash set copying a given type-specific collection.
 *
 * @param c
 *            a type-specific collection to be copied into the new hash set.
 * @param f
 *            the load factor.
 */
public ShortOpenHashSet(final ShortCollection c, final float f) {
  this(c.size(), f);
  addAll(c);
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Rehashes the set.
 *
 * <p>
 * This method implements the basic rehashing strategy, and may be overriden by
 * subclasses implementing different rehashing strategies (e.g., disk-based
 * rehashing). However, you should not override this method unless you
 * understand the internal workings of this class.
 *
 * @param newN
 *            the new size
 */
protected void rehash(final int newN) {
  final short key[] = this.key;
  final int mask = newN - 1; // Note that this is used by the hashing macro
  final short newKey[] = new short[newN + 1];
  int i = n, pos;
  for (int j = realSize(); j-- != 0;) {
    while (((key[--i]) == ((short) 0)));
    if (!((newKey[pos = (it.unimi.dsi.fastutil.HashCommon.mix((key[i]))) & mask]) == ((short) 0)))
      while (!((newKey[pos = (pos + 1) & mask]) == ((short) 0)));
    newKey[pos] = key[i];
  }
  n = newN;
  this.mask = mask;
  maxFill = maxFill(n, f);
  this.key = newKey;
}
/**
origin: jtablesaw/tablesaw

@Override
public Selection selectIsIn(String... strings) {
  ShortOpenHashSet keys = new ShortOpenHashSet(strings.length);
  for (String string : strings) {
    short key = getKeyForValue(string);
    if (key != DEFAULT_RETURN_VALUE) {
      keys.add(key);
    }
  }
  Selection results = new BitmapBackedSelection();
  for (int i = 0; i < values.size(); i++) {
    if (keys.contains(values.getShort(i))) {
      results.add(i);
    }
  }
  return results;
}
origin: org.datavec/datavec-dataframe

public ShortSet asSet() {
  return new ShortOpenHashSet(data);
}
origin: it.unimi.dsi/fastutil

private void tryCapacity(final long capacity) {
  final int needed = (int) Math.min(1 << 30,
      Math.max(2, HashCommon.nextPowerOfTwo((long) Math.ceil(capacity / f))));
  if (needed > n)
    rehash(needed);
}
@Override
it.unimi.dsi.fastutil.shortsShortOpenHashSet

Javadoc

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

Instances of this class use a hash table to represent a set. 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 sets 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 set and fills it with the elements of a given array.
  • add
  • contains
  • addAll
  • ensureCapacity
  • iterator
  • realSize
  • rehash
    Rehashes the set. This method implements the basic rehashing strategy, and may be overriden by subcl
  • remove
  • removeEntry
  • removeNullEntry
  • shiftKeys
    Shifts left entries with the specified hash code, starting at the specified position, and empties th
  • removeNullEntry,
  • shiftKeys,
  • size,
  • toShortArray,
  • tryCapacity

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • onCreateOptionsMenu (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Collectors (java.util.stream)
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • From CI to AI: The AI layer in your organization
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