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

How to use
ObjectIntHashMap
in
com.carrotsearch.hppcrt.maps

Best Java code snippets using com.carrotsearch.hppcrt.maps.ObjectIntHashMap (Showing top 20 results out of 315)

origin: com.github.vsonnier/hppcrt

/**
 * If <code>key</code> exists, <code>putValue</code> is inserted into the map,
 * otherwise any existing value is incremented by <code>additionValue</code>.
 *
 * @param key
 *          The key of the value to adjust.
 * @param putValue
 *          The value to put if <code>key</code> does not exist.
 * @param incrementValue
 *          The value to add to the existing value if <code>key</code> exists.
 * @return Returns the current value associated with <code>key</code> (after
 *         changes).
 */
@SuppressWarnings("cast")
@Override
public int putOrAdd(final KType key, int putValue, final int incrementValue) {
  if (containsKey(key)) {
    putValue = get(key);
    putValue = (int) (((putValue) + (incrementValue)));
  }
  put(key, putValue);
  return putValue;
}
origin: com.github.vsonnier/hppcrt

/**
 * Creates a hash map from two index-aligned arrays of key-value pairs. Default load factor is used.
 */
public static <KType> ObjectIntHashMap<KType> from(final KType[] keys, final int[] values) {
  if (keys.length != values.length) {
    throw new IllegalArgumentException("Arrays of keys and values must have an identical length.");
  }
  final ObjectIntHashMap<KType> map = new ObjectIntHashMap<KType>(keys.length);
  for (int i = 0; i < keys.length; i++) {
    map.put(keys[i], values[i]);
  }
  return map;
}
origin: com.github.vsonnier/hppcrt

/**
 * {@inheritDoc}
 */
@Override
public int putAll(final Iterable<? extends ObjectIntCursor<? extends KType>> iterable) {
  final int count = this.size();
  for (final ObjectIntCursor<? extends KType> c : iterable) {
    put(c.key, c.value);
  }
  return this.size() - count;
}
origin: com.github.vsonnier/hppcrt

/**
 * {@inheritDoc}
 */
@Override
public boolean putIfAbsent(final KType key, final int value) {
  if (!containsKey(key)) {
    put(key, value);
    return true;
  }
  return false;
}
origin: com.github.vsonnier/hppcrt

/**
 * {@inheritDoc}
 */
@Override
public ObjectIntHashMap<KType> clone() {
  //clone to size() to prevent some cases of exponential sizes,
  final ObjectIntHashMap<KType> cloned = new ObjectIntHashMap<KType>(this.size(), this.loadFactor);
  //We must NOT clone because of independent perturbations seeds
  cloned.putAll(this);
  return cloned;
}
origin: owlcs/owlapi

static ObjectIntHashMap<IRI> initMap() {
  ObjectIntHashMap<IRI> predicates = new ObjectIntHashMap<>();
  AtomicInteger nextId = new AtomicInteger(1);
  List<OWLRDFVocabulary> ORDERED_URIS = Arrays.asList(RDF_TYPE, RDFS_LABEL, OWL_DEPRECATED,
    RDFS_COMMENT, RDFS_IS_DEFINED_BY, RDF_FIRST, RDF_REST, OWL_EQUIVALENT_CLASS,
    OWL_EQUIVALENT_PROPERTY, RDFS_SUBCLASS_OF, RDFS_SUB_PROPERTY_OF, RDFS_DOMAIN,
    RDFS_RANGE, OWL_DISJOINT_WITH, OWL_ON_PROPERTY, OWL_DATA_RANGE, OWL_ON_CLASS,
    OWL_ANNOTATED_SOURCE, OWL_ANNOTATED_PROPERTY, OWL_ANNOTATED_TARGET);
  ORDERED_URIS.forEach(iri -> predicates.put(iri.getIRI(), nextId.getAndIncrement()));
  Stream.of(OWLRDFVocabulary.values())
    .forEach(iri -> predicates.putIfAbsent(iri.getIRI(), nextId.getAndIncrement()));
  return predicates;
}
origin: owlcs/owlapi

private static int comparePredicates(RDFResourceIRI predicate, RDFResourceIRI otherPredicate) {
  IRI predicateIRI = predicate.getIRI();
  int specialPredicateRank = specialPredicateRanks.get(predicateIRI);
  IRI otherPredicateIRI = otherPredicate.getIRI();
  int otherSpecialPredicateRank = specialPredicateRanks.get(otherPredicateIRI);
  if (specialPredicateRank != specialPredicateRanks.getDefaultValue()) {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return Integer.compare(specialPredicateRank, otherSpecialPredicateRank);
    } else {
      return -1;
    }
  } else {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return +1;
    } else {
      return predicateIRI.compareTo(otherPredicateIRI);
    }
  }
}
origin: owlcs/owlapi

@Override
public Set<OWLAxiom> getPrincipalIdeal(Atom atom) {
  return asSet(getAtomModule(atomIndex.get(atom)));
}
origin: net.sourceforge.owlapi/owlapi-distribution

/**
 * @param axioms axioms
 * @param type type
 */
public AtomicDecompositionImpl(List<OWLAxiom> axioms, ModuleType type) {
  this.type = type;
  decomposer = new Decomposer(AxiomSelector.wrap(axioms), new SyntacticLocalityChecker());
  int size = decomposer.getAOS(this.type).size();
  atoms = new ArrayList<>();
  for (int i = 0; i < size; i++) {
    final Atom atom = new Atom(asSet(decomposer.getAOS().get(i).getAtomAxioms()));
    atoms.add(atom);
    atomIndex.put(atom, i);
    for (OWLEntity e : atom.getSignature()) {
      termBasedIndex.put(e, atom);
    }
  }
  for (int i = 0; i < size; i++) {
    Set<OntologyAtom> dependentIndexes = decomposer.getAOS().get(i).getDependencies();
    for (OntologyAtom j : dependentIndexes) {
      dependencies.put(atoms.get(i), atoms.get(j.getId()));
      dependents.put(atoms.get(j.getId()), atoms.get(i));
    }
  }
}
origin: com.github.vsonnier/hppcrt

if (other.size() != this.size()) {
  return false;
final EntryIterator it = this.iterator();
  if (!other.containsKey(c.key)) {
  final int otherValue = other.get(c.key);
origin: com.github.vsonnier/hppcrt

/**
 * Create a new hash map without providing the full generic signature
 * (constructor shortcut).
 */
public static <KType> ObjectIntHashMap<KType> newInstance() {
  return new ObjectIntHashMap<KType>();
}
origin: com.github.vsonnier/hppcrt

final int[] oldValues = ((this.values));
allocateBuffers(HashContainers.nextBufferSize(this.keys.length, this.assigned, this.loadFactor));
    slot = (BitMixer.mix(hashKey((key)) , (perturb))) & mask;
      existing_distance = probe_distance(slot, cached);
origin: com.github.vsonnier/hppcrt

/**
 * Creates a hash map with the given initial capacity,
 * load factor.
 *
 * @param loadFactor The load factor (greater than zero and smaller than 1).
 */
public ObjectIntHashMap(final int initialCapacity, final double loadFactor) {
  this.loadFactor = loadFactor;
  //take into account of the load factor to guarantee no reallocations before reaching  initialCapacity.
  allocateBuffers(HashContainers.minBufferSize(initialCapacity, loadFactor));
}
origin: net.sourceforge.owlapi/owlapi-distribution

static ObjectIntHashMap<IRI> initMap() {
  ObjectIntHashMap<IRI> predicates = new ObjectIntHashMap<>();
  AtomicInteger nextId = new AtomicInteger(1);
  List<OWLRDFVocabulary> ORDERED_URIS = Arrays.asList(RDF_TYPE, RDFS_LABEL, OWL_DEPRECATED,
    RDFS_COMMENT, RDFS_IS_DEFINED_BY, RDF_FIRST, RDF_REST, OWL_EQUIVALENT_CLASS,
    OWL_EQUIVALENT_PROPERTY, RDFS_SUBCLASS_OF, RDFS_SUB_PROPERTY_OF, RDFS_DOMAIN,
    RDFS_RANGE, OWL_DISJOINT_WITH, OWL_ON_PROPERTY, OWL_DATA_RANGE, OWL_ON_CLASS,
    OWL_ANNOTATED_SOURCE, OWL_ANNOTATED_PROPERTY, OWL_ANNOTATED_TARGET);
  ORDERED_URIS.forEach(iri -> predicates.put(iri.getIRI(), nextId.getAndIncrement()));
  Stream.of(OWLRDFVocabulary.values())
    .forEach(iri -> predicates.putIfAbsent(iri.getIRI(), nextId.getAndIncrement()));
  return predicates;
}
origin: net.sourceforge.owlapi/owlapi-osgidistribution

private static int comparePredicates(RDFResourceIRI predicate, RDFResourceIRI otherPredicate) {
  IRI predicateIRI = predicate.getIRI();
  int specialPredicateRank = specialPredicateRanks.get(predicateIRI);
  IRI otherPredicateIRI = otherPredicate.getIRI();
  int otherSpecialPredicateRank = specialPredicateRanks.get(otherPredicateIRI);
  if (specialPredicateRank != specialPredicateRanks.getDefaultValue()) {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return Integer.compare(specialPredicateRank, otherSpecialPredicateRank);
    } else {
      return -1;
    }
  } else {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return +1;
    } else {
      return predicateIRI.compareTo(otherPredicateIRI);
    }
  }
}
origin: net.sourceforge.owlapi/owlapi-tools

@Override
public Set<OWLAxiom> getPrincipalIdeal(Atom atom) {
  return asSet(getAtomModule(atomIndex.get(atom)));
}
origin: owlcs/owlapi

/**
 * @param axioms axioms
 * @param type type
 */
public AtomicDecompositionImpl(List<OWLAxiom> axioms, ModuleType type) {
  this.type = type;
  decomposer = new Decomposer(AxiomSelector.wrap(axioms), new SyntacticLocalityChecker());
  int size = decomposer.getAOS(this.type).size();
  atoms = new ArrayList<>();
  for (int i = 0; i < size; i++) {
    final Atom atom = new Atom(asSet(decomposer.getAOS().get(i).getAtomAxioms()));
    atoms.add(atom);
    atomIndex.put(atom, i);
    for (OWLEntity e : atom.getSignature()) {
      termBasedIndex.put(e, atom);
    }
  }
  for (int i = 0; i < size; i++) {
    Set<OntologyAtom> dependentIndexes = decomposer.getAOS().get(i).getDependencies();
    for (OntologyAtom j : dependentIndexes) {
      dependencies.put(atoms.get(i), atoms.get(j.getId()));
      dependents.put(atoms.get(j.getId()), atoms.get(i));
    }
  }
}
origin: com.github.vsonnier/hppcrt

/**
 * Create a hash map from another associative container. (constructor shortcut) Default load factor is used.
 */
public static <KType> ObjectIntHashMap<KType> from(
    final ObjectIntAssociativeContainer<KType> container) {
  return new ObjectIntHashMap<KType>(container);
}
origin: net.sourceforge.owlapi/owlapi-osgidistribution

static ObjectIntHashMap<IRI> initMap() {
  ObjectIntHashMap<IRI> predicates = new ObjectIntHashMap<>();
  AtomicInteger nextId = new AtomicInteger(1);
  List<OWLRDFVocabulary> ORDERED_URIS = Arrays.asList(RDF_TYPE, RDFS_LABEL, OWL_DEPRECATED,
    RDFS_COMMENT, RDFS_IS_DEFINED_BY, RDF_FIRST, RDF_REST, OWL_EQUIVALENT_CLASS,
    OWL_EQUIVALENT_PROPERTY, RDFS_SUBCLASS_OF, RDFS_SUB_PROPERTY_OF, RDFS_DOMAIN,
    RDFS_RANGE, OWL_DISJOINT_WITH, OWL_ON_PROPERTY, OWL_DATA_RANGE, OWL_ON_CLASS,
    OWL_ANNOTATED_SOURCE, OWL_ANNOTATED_PROPERTY, OWL_ANNOTATED_TARGET);
  ORDERED_URIS.forEach(iri -> predicates.put(iri.getIRI(), nextId.getAndIncrement()));
  Stream.of(OWLRDFVocabulary.values())
    .forEach(iri -> predicates.putIfAbsent(iri.getIRI(), nextId.getAndIncrement()));
  return predicates;
}
origin: net.sourceforge.owlapi/owlapi-distribution

private static int comparePredicates(RDFResourceIRI predicate, RDFResourceIRI otherPredicate) {
  IRI predicateIRI = predicate.getIRI();
  int specialPredicateRank = specialPredicateRanks.get(predicateIRI);
  IRI otherPredicateIRI = otherPredicate.getIRI();
  int otherSpecialPredicateRank = specialPredicateRanks.get(otherPredicateIRI);
  if (specialPredicateRank != specialPredicateRanks.getDefaultValue()) {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return Integer.compare(specialPredicateRank, otherSpecialPredicateRank);
    } else {
      return -1;
    }
  } else {
    if (otherSpecialPredicateRank != specialPredicateRanks.getDefaultValue()) {
      return +1;
    } else {
      return predicateIRI.compareTo(otherPredicateIRI);
    }
  }
}
com.carrotsearch.hppcrt.mapsObjectIntHashMap

Javadoc

A hash map of Object to int, implemented using open addressing with linear probing for collision resolution.

In addition, the hashing strategy can be changed by overriding ( #equalKeys(Object,Object) and #hashKey(Object)) together, which then replaces the usual ( #equals(Object) and #hashCode()) from the keys themselves. This is useful to define the equivalence of keys when the user has no control over the keys implementation.

The internal buffers of this implementation ( #keys, #values), are always allocated to the nearest size that is a power of two. When the capacity exceeds the given load factor, the buffer size is doubled.

This implementation supports null keys.

Important note. The implementation uses power-of-two tables and linear probing, which may cause poor performance (many collisions) if hash values are not properly distributed.

Robin-Hood hashing algorithm is also used to minimize variance in insertion and search-related operations, for an all-around smother operation at the cost of smaller peak performance:

- Pedro Celis (1986) for the original Robin-Hood hashing paper,

- MoonPolySoft/Cliff Moon for the initial Robin-hood on HPPC implementation,

- Vincent Sonnier for the present implementation using cached hashes.

Most used methods

  • get
  • put
  • <init>
    Create a hash map from all key-value pairs of another container.
  • getDefaultValue
    Returns the "default value" value used in containers methods returning "default value"
  • putIfAbsent
  • allocateBuffers
    Allocate internal buffers for a given capacity.
  • containsKey
  • equalKeys
    Override this method together with #hashKey(Object)to customize the hashing strategy. Note that this
  • expandAndPut
    Expand the internal storage buffers (capacity) and rehash.
  • hashKey
    Override this method, together with #equalKeys(Object,Object)to customize the hashing strategy. Note
  • iterator
  • probe_distance
  • iterator,
  • probe_distance,
  • putAll,
  • putOrAdd,
  • remove,
  • shiftConflictingKeys,
  • size

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ImageIO (javax.imageio)
  • JFrame (javax.swing)
  • 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