/** {@inheritDoc} */ @Override public V getValue() { return iterator.getValue(); }
@Override public V getValue() { return iterator.getValue(); }
/** * Write the map out using a custom routine. * * @param out the output stream * @throws IOException if an error occurs while writing to the stream */ private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (final MapIterator<?, ?> it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue());
/** * Gets the string form of this map as per AbstractMap. * * @param dataElement either {@link DataElement#KEY} key} * or the {@link DataElement#VALUE value}. * @return the string form of this map */ private String doToString(final DataElement dataElement) { if (nodeCount == 0) { return "{}"; } final StringBuilder buf = new StringBuilder(nodeCount * 32); buf.append('{'); final MapIterator<?, ?> it = getMapIterator(dataElement); boolean hasNext = it.hasNext(); while (hasNext) { final Object key = it.next(); final Object value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=') .append(value == this ? "(this Map)" : value); hasNext = it.hasNext(); if (hasNext) { buf.append(", "); } } buf.append('}'); return buf.toString(); }
/** * Gets the hash code value for this map as per the API. * * @param dataElement either {@link DataElement#KEY} key} * or the {@link DataElement#VALUE value}. * @return the hash code value for this map */ private int doHashCode(final DataElement dataElement) { int total = 0; if (nodeCount > 0) { for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) { final Object key = it.next(); final Object value = it.getValue(); total += key.hashCode() ^ value.hashCode(); } } return total; }
/** * Writes the map data to the stream. This method must be overridden if a * subclass must be setup before <code>put()</code> is used. * <p> * Serialization is not one of the JDK's nicest topics. Normal serialization will * initialise the superclass before the subclass. Sometimes however, this isn't * what you want, as in this case the <code>put()</code> method on read can be * affected by subclass state. * <p> * The solution adopted here is to serialize the state data of this class in * this protected method. This method must be called by the * <code>writeObject()</code> of the first serializable subclass. * <p> * Subclasses may override if they have a specific field that must be present * on read before this implementation will work. Generally, the read determines * what must be serialized here, if anything. * * @param out the output stream * @throws IOException if an error occurs while writing tothe stream */ protected void doWriteObject(final ObjectOutputStream out) throws IOException { out.writeFloat(loadFactor); out.writeInt(data.length); out.writeInt(size); for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue()); } }
while (hasNext) { final K key = it.next(); final V value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=')
@Benchmark public long test9_UsingApacheIterableMap() throws IOException { long i = 0; MapIterator<Integer, Integer> it = iterableMap.mapIterator(); while (it.hasNext()) { i += it.next() + it.getValue(); } return i; }
while (it.hasNext()) { final Object key = it.next(); final Object value = it.getValue(); if (value == null) { if (map.get(key) != null || map.containsKey(key) == false) {
for (final MapIterator<?, ?> it = getMapIterator(dataElement); it.hasNext(); ) { final Object key = it.next(); final Object value = it.getValue(); if (value.equals(other.get(key)) == false) { return false;
MapIterator it = multiKeyMap.mapIterator(); while (it.hasNext()) { it.next(); System.out.println(it.getValue()); }
MultiKeyMap multiKeyMap = new MultiKeyMap(); multiKeyMap.put("Key 1A","Key 1B","Value 1"); multiKeyMap.put("Key 2A","Key 2B","Value 2"); multiKeyMap.put("Key 3A","Key 3B","Value 3"); MapIterator it = multiKeyMap.mapIterator(); while (it.hasNext()) { it.next(); MultiKey mk = (MultiKey) it.getKey(); // Option 1 System.out.println(mk.getKey(0)); System.out.println(mk.getKey(1)); // Option 2 for (Object subkey : mk.getKeys()) System.out.println(subkey); System.out.println(it.getValue()); }
BidiMap aMap = new DualHashBidiMap(); aMap.put("B", "A"); aMap.put("A", "B"); aMap.put("C", "D"); aMap.put("X", "D"); MapIterator it = aMap.mapIterator(); System.out.println("Before Inverse"); while (it.hasNext()) { key = it.next(); value = it.getValue(); out.println(key + " -> " + value); } aMap = aMap.inverseBidiMap(); System.out.println("After Inverse"); it = aMap.mapIterator(); while (it.hasNext()) { key = it.next(); value = it.getValue(); out.println(key + " -> " + value); } Before Inverse A -> B B -> A X -> D After Inverse D -> X A -> B B -> A
private MapIterator<Key, Value> removeFromMapToEmit(MapIterator<Key, Value> iterCache) { if (urm) { if (iterCache == null) iterCache = cache.mapIterator(); iterCache.next(); emitKey = iterCache.getKey(); emitValue = iterCache.getValue(); iterCache.remove(); return iterCache; } else { emitKey = ((LRUMap<Key,Value>)cache).firstKey(); // LRU emitValue = cache.remove(emitKey); return null; } }
public Licence getLicence(Metier metier, Month month) { Licence result = null; for (MapIterator i=list.mapIterator(); i.hasNext();) { MultiKey keys = (MultiKey)i.next(); Metier metierKey = (Metier)keys.getKey(0); Month firstMonth = (Month)keys.getKey(1); Month lastMonth = (Month)keys.getKey(2); if (metier.equals(metierKey) && firstMonth.compareTo(month) <= 0 && month.compareTo(lastMonth) <= 0) { result = (Licence)i.getValue(); break; } } return result; }
List<Node> blogEntries = mit.getValue();
public void removePredictions(Recommender aRecommender) { // Remove incoming predictions if (incomingPredictions != null) { incomingPredictions.removePredictions(aRecommender.getId()); } // Remove active predictions if (activePredictions != null) { activePredictions.removePredictions(aRecommender.getId()); } // Remove trainedModel contexts.remove(aRecommender); // Remove from activeRecommenders map. // We have to do this, otherwise training and prediction continues for the // recommender when a new task is triggered. MultiValuedMap<AnnotationLayer, Recommender> newActiveRecommenders = new HashSetValuedHashMap<>(); MapIterator<AnnotationLayer, Recommender> it = activeRecommenders.mapIterator(); while (it.hasNext()) { AnnotationLayer layer = it.next(); Recommender rec = it.getValue(); if (!rec.equals(aRecommender)) { newActiveRecommenders.put(layer, rec); } } setActiveRecommenders(newActiveRecommenders); } }