Refine search
@Benchmark public TMap<String, String> trove() { int localSize = this.size; float localLoadFactor = this.loadFactor; String[] localElements = this.elements; int defaultInitialCapacity = Constants.DEFAULT_CAPACITY; TMap<String, String> trove = this.isPresized ? new THashMap<>(localSize, localLoadFactor) : new THashMap<>(defaultInitialCapacity, localLoadFactor); for (int i = 0; i < localSize; i++) { trove.put(localElements[i], "dummy"); } return trove; } }
/** * copies the key/value mappings in <tt>map</tt> into this map. * * @param map a <code>Map</code> value */ public void putAll(Map<? extends K, ? extends V> map) { ensureCapacity(map.size()); // could optimize this for cases when map instanceof THashMap for (Map.Entry<? extends K, ? extends V> e : map.entrySet()) { put(e.getKey(), e.getValue()); } }
protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldKeys[] = _set; V oldVals[] = _values; int index = insertKey((K) o); if (index < 0) { throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldKeys); reportPotentialConcurrentMod(size(), oldSize);
/** Use valueOf() instead. */ private Tags(Key tags) { tags_ = unmodifiableMap(tags.stream() .collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (x, y) -> { throw new IllegalStateException("duplicate metric name"); }, () -> new THashMap<String, MetricValue>(tags.size(), LOAD_FACTOR)))); hashCode_ = Objects.hashCode(this.tags_); }
/** * Term from a phrase, beyond the first term. If this is the last term, it indicates a * match, otherwise it does not, and the children must be constructed. */ GazEntry(String[] entries, int i, DictionaryNames n) { if (entries.length == i) { addMatch(n); requiredChildren = null; } else { // this is a new phrase, not just a term, so not a match names = null; // add the children requiredChildren = new THashMap<>(); requiredChildren.put(entries[i], new GazEntry(entries, i + 1, n)); } }
private ExpandingPolytopeEntry[] getOrCreateTwoTriangleArray(THashMap<Point3D, ExpandingPolytopeEntry[]> mapFromStitchVertexToTriangles, Point3D sentryVertexOne) { ExpandingPolytopeEntry[] twoTriangleArray = mapFromStitchVertexToTriangles.get(sentryVertexOne); if (twoTriangleArray == null) { twoTriangleArray = new ExpandingPolytopeEntry[2]; mapFromStitchVertexToTriangles.put(sentryVertexOne, twoTriangleArray); } return twoTriangleArray; }
/** * checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey(Object key) { //noinspection unchecked return contains(key); }
/** * Compares this map with another map for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ @SuppressWarnings({"unchecked", "SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Map)) { return false; } Map<K, V> that = (Map<K, V>) other; if (that.size() != this.size()) { return false; } return forEachEntry(new EqProcedure<K, V>(that)); }
/** * to string prints a representation of every string contained in the gazetteer. * * @return a string representation of the gazetteer. */ public String toString() { StringBuffer printstring = new StringBuffer(); for (String key : gaz.keySet()) { GazEntry ge = gaz.get(key); ge.stringRepresentation(key, key, printstring); } return printstring.toString(); }
private void retainPoints(Point3D pointToKeep) { Point3D point3dOnA = simplexPointToPolytopePointA.get(pointToKeep); Point3D point3dOnB = simplexPointToPolytopePointB.get(pointToKeep); pointOne = null; pointTwo = null; pointThree = null; pointFour = null; pointOne = pointToKeep; simplexPointToPolytopePointA.clear(); simplexPointToPolytopePointB.clear(); simplexPointToPolytopePointA.put(pointToKeep, point3dOnA); simplexPointToPolytopePointB.put(pointToKeep, point3dOnB); }
@Override public void map(Text key, PairOfStrings t, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { if (redirects.size() == 0) throw new IOException("zero redirects"); String entity = t.getLeftElement(); entity = capitalizeFirstChar(entity); reporter.setStatus(entity); ArrayList<String> seen = new ArrayList<String>(); // transitivity while (redirects.contains(entity)) { reporter.incrCounter(Resolve.REDIRECT, 1); String target = redirects.get(entity); // break loops if (seen.contains(target)) { break; } else { seen.add(target); } if (target.equals(entity)) break; entity = target; } // Here we "lose" the key, i.e., from which article the link originated. KEY.set(entity); VALUE.set(t.getRightElement()); output.collect(KEY, VALUE); } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION byte version = in.readByte(); // NOTE: super was not written in version 0 if (version != 0) { super.readExternal(in); } // NUMBER OF ENTRIES int size = in.readInt(); setUp(size); // ENTRIES while (size-- > 0) { //noinspection unchecked K key = (K) in.readObject(); //noinspection unchecked V val = (V) in.readObject(); put(key, val); } } } // THashMap
public void clear() { THashMap.this.clear(); }
@Override public V put(K key, V value) { return delegate.put(key, value); }
/** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>TObjectProcedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey(TObjectProcedure<? super K> procedure) { return forEach(procedure); }
/** * checks for the presence of <tt>val</tt> in the values of the map. * * @param val an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsValue(Object val) { Object[] set = _set; V[] vals = _values; // special case null values so that we don't have to // perform null checks before every call to equals() if (null == val) { for (int i = vals.length; i-- > 0;) { if ((set[i] != FREE && set[i] != REMOVED) && val == vals[i]) { return true; } } } else { for (int i = vals.length; i-- > 0;) { if ((set[i] != FREE && set[i] != REMOVED) && (val == vals[i] || equals(val, vals[i]))) { return true; } } } // end of else return false; }
@Override public void configure(JobConf job) { super.configure(job); try { @SuppressWarnings("deprecation") SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.getLocal(job), new Path("redirs.dat"), job); Text source = new Text(); Text target = new Text(); while (reader.next(source, target)) { redirects.put(source.toString(), target.toString()); } reader.close(); } catch (IOException e) { e.printStackTrace(); redirects.clear(); return; } }
/** * retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ @SuppressWarnings({"unchecked"}) public V get( Object key ) { int index = index( key ); if ( index < 0 || ! equals( _set[index], key ) ) { return null; } return _values[index]; }