public virtual void AddAll(Edu.Stanford.Nlp.Util.CollectionValuedMap <K, V> cvm)
 {
     foreach (KeyValuePair <K, ICollection <V> > entry in cvm)
     {
         K key = entry.Key;
         ICollection <V> currentCollection = this[key];
         ICollection <V> newValues         = entry.Value;
         if (treatCollectionsAsImmutable)
         {
             ICollection <V> newCollection = cf.NewCollection();
             if (currentCollection != null)
             {
                 Sharpen.Collections.AddAll(newCollection, currentCollection);
             }
             Sharpen.Collections.AddAll(newCollection, newValues);
             map[key] = newCollection;
         }
         else
         {
             // replacing the old collection
             bool needToAdd = false;
             if (currentCollection == emptyValue)
             {
                 currentCollection = cf.NewCollection();
                 needToAdd         = true;
             }
             Sharpen.Collections.AddAll(currentCollection, newValues);
             // modifying the old collection
             if (needToAdd)
             {
                 map[key] = currentCollection;
             }
         }
     }
 }
 /// <summary>Creates a new CollectionValuedMap with all of the mappings from cvm.</summary>
 /// <param name="cvm">The CollectionValueMap to copy as this object.</param>
 public CollectionValuedMap(Edu.Stanford.Nlp.Util.CollectionValuedMap <K, V> cvm)
 {
     this.mf = cvm.mf;
     this.cf = cvm.cf;
     this.treatCollectionsAsImmutable = cvm.treatCollectionsAsImmutable;
     this.emptyValue = cvm.emptyValue;
     map             = Java.Util.Collections.SynchronizedMap(mf.NewMap());
     foreach (KeyValuePair <K, ICollection <V> > entry in cvm.map)
     {
         K key             = entry.Key;
         ICollection <V> c = entry.Value;
         foreach (V value in c)
         {
             Add(key, value);
         }
     }
 }
 /// <returns>
 /// true iff o is a CollectionValuedMap, and each key maps to the a
 /// Collection of the same objects in o as it does in this
 /// CollectionValuedMap.
 /// </returns>
 public override bool Equals(object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (!(o is Edu.Stanford.Nlp.Util.CollectionValuedMap <object, object>))
     {
         return(false);
     }
     Edu.Stanford.Nlp.Util.CollectionValuedMap <K, V> other = ErasureUtils.UncheckedCast(o);
     if (other.Count != Count)
     {
         return(false);
     }
     try
     {
         foreach (KeyValuePair <K, ICollection <V> > e in this)
         {
             K key = e.Key;
             ICollection <V> value = e.Value;
             if (value == null)
             {
                 if (!(other[key] == null && other.Contains(key)))
                 {
                     return(false);
                 }
             }
             else
             {
                 if (!value.Equals(other[key]))
                 {
                     return(false);
                 }
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }