Java Code Examples for com.helger.commons.collection.impl.CommonsLinkedHashMap

The following examples show how to use com.helger.commons.collection.impl.CommonsLinkedHashMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ph-commons   Source File: DirectedGraphNode.java    License: Apache License 2.0 6 votes vote down vote up
public void addIncomingRelation (@Nonnull final IMutableDirectedGraphRelation aNewRelation)
{
  ValueEnforcer.notNull (aNewRelation, "NewRelation");
  ValueEnforcer.isTrue (aNewRelation.getTo () == this, "Passed incoming relation is not based on this node");
  if (m_aIncoming != null)
  {
    if (m_aIncoming.containsKey (aNewRelation.getID ()))
      throw new IllegalArgumentException ("The passed relation (" +
                                          aNewRelation +
                                          ") is already contained as an incoming relation");

    // check if the relation from-node is already contained
    for (final IMutableDirectedGraphRelation aRelation : m_aIncoming.values ())
      if (aRelation.getFrom () == aNewRelation.getFrom ())
        throw new IllegalArgumentException ("The from-node of the passed relation (" +
                                            aNewRelation +
                                            ") is already contained");
  }
  else
  {
    m_aIncoming = new CommonsLinkedHashMap <> ();
  }

  // Add!
  m_aIncoming.put (aNewRelation.getID (), aNewRelation);
}
 
Example 2
Source Project: ph-commons   Source File: DirectedGraphNode.java    License: Apache License 2.0 6 votes vote down vote up
public void addOutgoingRelation (@Nonnull final IMutableDirectedGraphRelation aNewRelation)
{
  ValueEnforcer.notNull (aNewRelation, "NewRelation");
  ValueEnforcer.isTrue (aNewRelation.getFrom () == this, "Passed outgoing relation is not based on this node");
  if (m_aOutgoing != null)
  {
    if (m_aOutgoing.containsKey (aNewRelation.getID ()))
      throw new IllegalArgumentException ("The passed relation " +
                                          aNewRelation +
                                          " is already contained as an outgoing relation");
    // check if the relation to-node is already contained
    for (final IMutableDirectedGraphRelation aRelation : m_aOutgoing.values ())
      if (aRelation.getTo () == aNewRelation.getTo ())
        throw new IllegalArgumentException ("The to-node of the passed relation " +
                                            aNewRelation +
                                            " is already contained");
  }
  else
  {
    m_aOutgoing = new CommonsLinkedHashMap <> ();
  }

  // Add!
  m_aOutgoing.put (aNewRelation.getID (), aNewRelation);
}
 
Example 3
Source Project: ph-commons   Source File: GraphNode.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public EChange addRelation (@Nullable final IMutableGraphRelation aRelation)
{
  if (aRelation == null)
    return EChange.UNCHANGED;
  if (!aRelation.isRelatedTo (this))
    throw new IllegalArgumentException ("Relation is not suitable for this node!");

  final String sRelationID = aRelation.getID ();
  if (m_aRelations == null)
    m_aRelations = new CommonsLinkedHashMap <> ();
  else
    if (m_aRelations.containsKey (sRelationID))
      return EChange.UNCHANGED;

  m_aRelations.put (sRelationID, aRelation);
  return EChange.CHANGED;
}
 
Example 4
Source Project: ph-commons   Source File: ConfigurationSourceJson.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
private static ICommonsOrderedMap <String, String> _load (@Nonnull final IReadableResource aRes, @Nonnull final Charset aCharset)
{
  final JsonReader.Builder aBuilder = JsonReader.builder ()
                                                .setSource (aRes, aCharset)
                                                .setCustomizeCallback (aParser -> aParser.setRequireStringQuotes (false)
                                                                                         .setAllowSpecialCharsInStrings (true)
                                                                                         .setAlwaysUseBigNumber (true)
                                                                                         .setTrackPosition (true))
                                                .setCustomExceptionCallback (ex -> LOGGER.error ("Failed to parse '" +
                                                                                                 aRes.getPath () +
                                                                                                 "' to JSON: " +
                                                                                                 ex.getMessage ()));
  final IJsonObject aProps = aBuilder.hasSource () ? aBuilder.readAsObject () : null;
  if (aProps == null)
    return null;

  final ICommonsOrderedMap <String, String> ret = new CommonsLinkedHashMap <> ();
  for (final Map.Entry <String, IJson> aEntry : aProps)
    _recursiveFlattenJson (aEntry.getKey (), aEntry.getValue (), ret);
  return ret;
}
 
Example 5
Source Project: ph-commons   Source File: JsonWriterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMap ()
{
  final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
  aMap.put ("foo", "bar");
  assertEquals ("{\"foo\":\"bar\"}", JsonConverter.convertToJson (aMap).getAsJsonString ());

  final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
  aTreeMap.put ("foo", "bar");
  aTreeMap.put ("foo2", Integer.valueOf (5));
  assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aTreeMap).getAsJsonString ());

  final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
  aLinkedMap.put ("foo", "bar");
  aLinkedMap.put ("foo2", Integer.valueOf (5));
  assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aLinkedMap).getAsJsonString ());
  assertEquals ("{foo:\"bar\",foo2:5}",
                JsonConverter.convertToJson (aLinkedMap).getAsJsonString (new JsonWriterSettings ().setQuoteNames (false)));
}
 
Example 6
Source Project: ph-commons   Source File: JsonWriterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteAndReadMap ()
{
  final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
  aMap.put ("foo", "bar");
  _testWriteAndRead (aMap);

  final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
  aTreeMap.put ("foo", "bar");
  aTreeMap.put ("foo2", Integer.valueOf (5));
  _testWriteAndRead (aTreeMap);

  final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
  aLinkedMap.put ("foo", "bar");
  aLinkedMap.put ("foo2", Integer.valueOf (5));
  _testWriteAndRead (aLinkedMap);
}
 
Example 7
Source Project: ph-commons   Source File: JsonConverterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMap ()
{
  final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
  aMap.put ("foo", "bar");
  aMap.put ("foo2", Integer.valueOf (5));
  assertTrue (JsonConverter.convertToJson (aMap) instanceof JsonObject);

  final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
  aTreeMap.put ("foo", "bar");
  aTreeMap.put ("foo2", Integer.valueOf (5));
  assertTrue (JsonConverter.convertToJson (aTreeMap) instanceof JsonObject);

  final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
  aLinkedMap.put ("foo", "bar");
  aLinkedMap.put ("foo2", Integer.valueOf (5));
  assertTrue (JsonConverter.convertToJson (aLinkedMap) instanceof JsonObject);
}
 
Example 8
Source Project: ph-commons   Source File: EqualsHashcodeFuncTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMap ()
{
  final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
  aMap.put ("foo", "bar");
  _testEqualsHashcode (aMap);

  final ICommonsMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
  aTreeMap.put ("foo", "bar");
  aTreeMap.put ("foo2", Integer.valueOf (5));
  _testEqualsHashcode (aTreeMap);

  final ICommonsMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
  aLinkedMap.put ("foo", "bar");
  aLinkedMap.put ("foo2", Integer.valueOf (5));
  _testEqualsHashcode (aLinkedMap);
}
 
Example 9
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> CommonsLinkedHashMap <ELEMENTTYPE, ELEMENTTYPE> newOrderedMap (@Nullable final ELEMENTTYPE... aValues)
{
  if (ArrayHelper.isEmpty (aValues))
    return newOrderedMap (0);

  if ((aValues.length % 2) != 0)
    throw new IllegalArgumentException ("The passed array needs an even number of elements!");

  final CommonsLinkedHashMap <ELEMENTTYPE, ELEMENTTYPE> ret = newOrderedMap (aValues.length / 2);
  for (int i = 0; i < aValues.length; i += 2)
    ret.put (aValues[i], aValues[i + 1]);
  return ret;
}
 
Example 10
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve a map that is ordered in the way the parameter arrays are passed
 * in. Note that key and value arrays need to have the same length.
 *
 * @param <KEYTYPE>
 *        The key type.
 * @param <VALUETYPE>
 *        The value type.
 * @param aKeys
 *        The key array to use. May not be <code>null</code>.
 * @param aValues
 *        The value array to use. May not be <code>null</code>.
 * @return A {@link CommonsLinkedHashMap} containing the passed key-value
 *         entries. Never <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, VALUETYPE> CommonsLinkedHashMap <KEYTYPE, VALUETYPE> newOrderedMap (@Nullable final KEYTYPE [] aKeys,
                                                                                            @Nullable final VALUETYPE [] aValues)
{
  final int nKeys = ArrayHelper.getSize (aKeys);
  final int nValues = ArrayHelper.getSize (aValues);

  // Check for identical size
  if (nKeys != nValues)
    throw new IllegalArgumentException ("The passed arrays have different length (" +
                                        nKeys +
                                        " keys and " +
                                        nValues +
                                        " values)!");

  // Are both empty?
  if (nKeys == 0)
    return newOrderedMap (0);

  final CommonsLinkedHashMap <KEYTYPE, VALUETYPE> ret = newOrderedMap (nKeys);
  for (int i = 0; i < aKeys.length; ++i)
    ret.put (aKeys[i], aValues[i]);
  return ret;
}
 
Example 11
@Override
@Nonnull
@ReturnsMutableCopy
protected CommonsLinkedHashMap <KEYTYPE2, VALUETYPE> createNewInnerMap ()
{
  return new CommonsLinkedHashMap <> ();
}
 
Example 12
Source Project: ph-commons   Source File: MultiTreeMapLinkedHashMapBased.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@ReturnsMutableCopy
protected CommonsLinkedHashMap <KEYTYPE2, VALUETYPE> createNewInnerMap ()
{
  return new CommonsLinkedHashMap <> ();
}
 
Example 13
Source Project: ph-commons   Source File: MultiHashMapLinkedHashMapBased.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@ReturnsMutableCopy
protected CommonsLinkedHashMap <KEYTYPE2, VALUETYPE> createNewInnerMap ()
{
  return new CommonsLinkedHashMap <> ();
}
 
Example 14
Source Project: ph-commons   Source File: Graph.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedMap <String, IMutableGraphRelation> getAllRelations ()
{
  final ICommonsOrderedMap <String, IMutableGraphRelation> ret = new CommonsLinkedHashMap <> ();
  for (final IMutableGraphNode aNode : m_aNodes.values ())
    aNode.forEachRelation (x -> ret.put (x.getID (), x));
  return ret;
}
 
Example 15
Source Project: ph-commons   Source File: DirectedGraph.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedMap <String, IMutableDirectedGraphRelation> getAllRelations ()
{
  final ICommonsOrderedMap <String, IMutableDirectedGraphRelation> ret = new CommonsLinkedHashMap <> ();
  for (final IMutableDirectedGraphNode aNode : m_aNodes.values ())
    aNode.forEachRelation (x -> ret.put (x.getID (), x));
  return ret;
}
 
Example 16
Source Project: ph-commons   Source File: XMLHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static ICommonsOrderedMap <String, String> getAllAttributesAsMap (@Nullable final Element aSrcNode)
{
  final ICommonsOrderedMap <String, String> ret = new CommonsLinkedHashMap <> ();
  // Cast needed for Oracle JDK 8
  forAllAttributes (aSrcNode, (BiConsumer <? super String, ? super String>) ret::put);
  return ret;
}
 
Example 17
Source Project: ph-commons   Source File: XMLResourceBundle.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static ICommonsOrderedMap <String, String> readFromPropertiesXML (@Nonnull @WillClose final InputStream aIS)
{
  final ICommonsOrderedMap <String, String> ret = new CommonsLinkedHashMap <> ();
  final IMicroDocument aDoc = MicroReader.readMicroXML (aIS);
  if (aDoc != null)
    for (final IMicroElement eChild : aDoc.getDocumentElement ().getAllChildElements ("entry"))
      ret.put (eChild.getAttributeValue ("key"), eChild.getTextContent ());
  return ret;
}
 
Example 18
Source Project: ph-commons   Source File: MicroElement.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableCopy
public ICommonsOrderedMap <IMicroQName, String> getAllQAttributes ()
{
  if (hasNoAttributes ())
    return null;
  return new CommonsLinkedHashMap <> (m_aAttrs.values (),
                                      IMicroAttribute::getAttributeQName,
                                      IMicroAttribute::getAttributeValue);
}
 
Example 19
Source Project: ph-commons   Source File: MicroElement.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public MicroElement setAttribute (@Nonnull final IMicroQName aAttrName, @Nullable final String sAttrValue)
{
  ValueEnforcer.notNull (aAttrName, "AttrName");
  if (sAttrValue != null)
  {
    if (m_aAttrs == null)
      m_aAttrs = new CommonsLinkedHashMap <> ();
    m_aAttrs.put (aAttrName, new MicroAttribute (aAttrName, sAttrValue));
  }
  else
    removeAttribute (aAttrName);
  return this;
}
 
Example 20
Source Project: ph-commons   Source File: MicroElement.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement getClone ()
{
  final MicroElement ret = new MicroElement (m_sNamespaceURI, m_sTagName);

  // Copy attributes
  if (m_aAttrs != null)
    ret.m_aAttrs = new CommonsLinkedHashMap <> (m_aAttrs);

  // Deep clone all child nodes
  forAllChildren (aChildNode -> ret.appendChild (aChildNode.getClone ()));
  return ret;
}
 
Example 21
Source Project: ph-css   Source File: MainReadAllCSSOnDisc.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressFBWarnings ("DMI_HARDCODED_ABSOLUTE_FILENAME")
public static void main (final String [] args)
{
  int nFilesOK = 0;
  int nFilesError = 0;
  final ICommonsOrderedMap <File, ParseException> aErrors = new CommonsLinkedHashMap<> ();
  final Wrapper <File> aCurrentFile = new Wrapper<> ();
  final ICSSParseExceptionCallback aHdl = ex -> aErrors.put (aCurrentFile.get (), ex);
  for (final File aFile : new FileSystemRecursiveIterator (new File ("/")).withFilter (IFileFilter.filenameEndsWith (".css")))
  {
    if (false)
      LOGGER.info (aFile.getAbsolutePath ());
    aCurrentFile.set (aFile);
    final CascadingStyleSheet aCSS = CSSReader.readFromFile (aFile, StandardCharsets.UTF_8, ECSSVersion.CSS30, aHdl);
    if (aCSS == null)
    {
      nFilesError++;
      LOGGER.warn ("  " + aFile.getAbsolutePath () + " failed!");
    }
    else
      nFilesOK++;
  }

  LOGGER.info ("Done");
  for (final Map.Entry <File, ParseException> aEntry : aErrors.entrySet ())
    LOGGER.info ("  " + aEntry.getKey ().getAbsolutePath () + ":\n" + aEntry.getValue ().getMessage () + "\n");
  LOGGER.info ("OK: " + nFilesOK + "; Error: " + nFilesError);
}
 
Example 22
Source Project: ph-commons   Source File: JsonObject.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject (@Nonnull final ObjectInputStream aOIS) throws IOException
{
  final int nInitialSize = aOIS.readInt ();
  m_aValues = new CommonsLinkedHashMap <> (nInitialSize);
  final String sJson = StreamHelper.readSafeUTF (aOIS);
  final JsonObject aJson = (JsonObject) JsonReader.readFromString (sJson);
  if (aJson == null)
    throw new IOException ("Failed to parse JSON object:\n" + sJson);
  m_aValues.putAll (aJson.m_aValues);
}
 
Example 23
Source Project: ph-commons   Source File: JsonObject.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedMap <String, IJson> getClonedValues ()
{
  final ICommonsOrderedMap <String, IJson> ret = new CommonsLinkedHashMap <> ();
  for (final Map.Entry <String, IJson> aEntry : m_aValues.entrySet ())
    ret.put (aEntry.getKey (), aEntry.getValue ().getClone ());
  return ret;
}
 
Example 24
Source Project: ph-commons   Source File: IErrorList.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param aKeyExtractor
 *        the key extractor by which the result is grouped.
 * @return A map with all items mapped from a key to its occurrences.
 * @param <T>
 *        Return list key type
 */
@Nonnull
@ReturnsMutableCopy
default <T> ICommonsOrderedMap <T, ICommonsList <IError>> getGrouped (@Nonnull final Function <? super IError, T> aKeyExtractor)
{
  final ICommonsOrderedMap <T, ICommonsList <IError>> ret = new CommonsLinkedHashMap <> ();
  // create a list for each key, and add the respective entry
  forEach (x -> ret.computeIfAbsent (aKeyExtractor.apply (x), k -> new CommonsArrayList <> ()).add (x));
  return ret;
}
 
Example 25
Source Project: ph-commons   Source File: URLParameterList.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return A new multi map (map from String to List of String) with all
 *         values. Order may be lost. Never <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedMap <String, ICommonsList <String>> getAsMultiMap ()
{
  final ICommonsOrderedMap <String, ICommonsList <String>> ret = new CommonsLinkedHashMap <> ();
  forEach (aParam -> ret.computeIfAbsent (aParam.getName (), x -> new CommonsArrayList <> ())
                        .add (aParam.getValue ()));
  return ret;
}
 
Example 26
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <SRCKEYTYPE, SRCVALUETYPE, DSTKEYTYPE, DSTVALUETYPE> CommonsLinkedHashMap <DSTKEYTYPE, DSTVALUETYPE> newOrderedMapMapped (@Nullable final Map <? extends SRCKEYTYPE, ? extends SRCVALUETYPE> aMap,
                                                                                                                                        @Nonnull final Function <? super SRCKEYTYPE, ? extends DSTKEYTYPE> aKeyMapper,
                                                                                                                                        @Nonnull final Function <? super SRCVALUETYPE, ? extends DSTVALUETYPE> aValueMapper)
{
  if (isEmpty (aMap))
    return newOrderedMap (0);
  return new CommonsLinkedHashMap <> (aMap, aKeyMapper, aValueMapper);
}
 
Example 27
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <SRCTYPE, DSTKEYTYPE, DSTVALUETYPE> CommonsLinkedHashMap <DSTKEYTYPE, DSTVALUETYPE> newOrderedMapMapped (@Nullable final Collection <? extends SRCTYPE> aCollection,
                                                                                                                       @Nonnull final Function <? super SRCTYPE, ? extends DSTKEYTYPE> aKeyMapper,
                                                                                                                       @Nonnull final Function <? super SRCTYPE, ? extends DSTVALUETYPE> aValueMapper)
{
  if (isEmpty (aCollection))
    return newOrderedMap (0);
  return new CommonsLinkedHashMap <> (aCollection, aKeyMapper, aValueMapper);
}
 
Example 28
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, VALUETYPE> CommonsLinkedHashMap <KEYTYPE, VALUETYPE> newOrderedMap (@Nullable final Map <KEYTYPE, VALUETYPE> aMap,
                                                                                            @Nonnull final Predicate <? super Map.Entry <? extends KEYTYPE, ? extends VALUETYPE>> aFilter)
{
  if (isEmpty (aMap))
    return newOrderedMap (0);
  final CommonsLinkedHashMap <KEYTYPE, VALUETYPE> ret = newOrderedMap (aMap.size ());
  ret.putAll (aMap, aFilter);
  return ret;
}
 
Example 29
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, VALUETYPE> CommonsLinkedHashMap <KEYTYPE, VALUETYPE> newOrderedMap (@Nullable final KEYTYPE aKey,
                                                                                            @Nullable final VALUETYPE aValue)
{
  final CommonsLinkedHashMap <KEYTYPE, VALUETYPE> ret = newOrderedMap (1);
  ret.put (aKey, aValue);
  return ret;
}
 
Example 30
Source Project: ph-commons   Source File: CollectionHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, VALUETYPE> CommonsLinkedHashMap <KEYTYPE, VALUETYPE> newOrderedMap (@Nullable final Collection <? extends KEYTYPE> aKeys,
                                                                                            @Nullable final Collection <? extends VALUETYPE> aValues)
{
  final int nKeys = getSize (aKeys);
  final int nValues = getSize (aValues);

  // Check for identical size
  if (nKeys != nValues)
    throw new IllegalArgumentException ("The passed arrays have different length (" +
                                        nKeys +
                                        " keys and " +
                                        nValues +
                                        " values)!");

  // Are both empty?
  if (nKeys == 0)
    return newOrderedMap (0);

  final CommonsLinkedHashMap <KEYTYPE, VALUETYPE> ret = newOrderedMap (nKeys);
  final Iterator <? extends KEYTYPE> itk = aKeys.iterator ();
  final Iterator <? extends VALUETYPE> itv = aValues.iterator ();
  while (itk.hasNext ())
    ret.put (itk.next (), itv.next ());
  return ret;
}