/// <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);
         }
     }
 }
        /// <exception cref="System.TypeLoadException"/>
        /// <exception cref="System.MissingMethodException"/>
        /// <exception cref="System.MemberAccessException"/>
        /// <exception cref="System.Reflection.TargetInvocationException"/>
        /// <exception cref="Java.Lang.InstantiationException"/>
        public static IDictionary <K, V> GetMapFromString <K, V>(string s, MapFactory <K, V> mapFactory)
        {
            System.Type     keyClass   = typeof(K);
            System.Type     valueClass = typeof(V);
            Constructor <K> keyC       = keyClass.GetConstructor(new Type[] { typeof(string) });
            Constructor <V> valueC     = valueClass.GetConstructor(new Type[] { typeof(string) });

            if (s[0] != '{')
            {
                throw new Exception(string.Empty);
            }
            s = Sharpen.Runtime.Substring(s, 1);
            // get rid of first brace
            string[]           fields = s.Split("\\s+");
            IDictionary <K, V> m      = mapFactory.NewMap();

            // populate m
            for (int i = 0; i < fields.Length; i++)
            {
                // log.info("Parsing " + fields[i]);
                fields[i] = Sharpen.Runtime.Substring(fields[i], 0, fields[i].Length - 1);
                // get rid of
                // following
                // comma or
                // brace
                string[] a   = fields[i].Split("=");
                K        key = keyC.NewInstance(a[0]);
                V        value;
                if (a.Length > 1)
                {
                    value = valueC.NewInstance(a[1]);
                }
                else
                {
                    value = valueC.NewInstance(string.Empty);
                }
                m[key] = value;
            }
            return(m);
        }
 /// <summary>Creates a new CollectionValuedMap.</summary>
 /// <param name="mf">A MapFactory which will be used to generate the underlying Map</param>
 /// <param name="cf">
 /// A CollectionFactory which will be used to generate the Collections
 /// in each mapping
 /// </param>
 /// <param name="treatCollectionsAsImmutable">
 /// If true, forces this Map to create new a Collection every time a
 /// new value is added to or deleted from the Collection a mapping.
 /// </param>
 /// <param name="map">
 /// An existing map to use rather than initializing one with mf. If this is non-null it is
 /// used to initialize the map rather than mf.
 /// </param>
 private CollectionValuedMap(MapFactory <K, ICollection <V> > mf, CollectionFactory <V> cf, bool treatCollectionsAsImmutable, IDictionary <K, ICollection <V> > map)
 {
     if (cf == null)
     {
         throw new ArgumentException();
     }
     if (mf == null && map == null)
     {
         throw new ArgumentException();
     }
     this.mf = mf;
     this.cf = cf;
     this.treatCollectionsAsImmutable = treatCollectionsAsImmutable;
     this.emptyValue = cf.NewEmptyCollection();
     if (map != null)
     {
         this.map = map;
     }
     else
     {
         this.map = Java.Util.Collections.SynchronizedMap(mf.NewMap());
     }
 }
 /// <summary>This is very cheap.</summary>
 /// <param name="originalMap">will serve as the basis for this DeltaMap</param>
 public DeltaMap(IDictionary <K, V> originalMap, MapFactory <K, V> mf)
 {
     this.originalMap = Java.Util.Collections.UnmodifiableMap(originalMap);
     // unmodifiable for debugging only
     this.deltaMap = mf.NewMap();
 }
 public BinaryHeapPriorityQueue(MapFactory <E, BinaryHeapPriorityQueue.Entry <E> > mapFactory, int initCapacity)
 {
     indexToEntry = new List <BinaryHeapPriorityQueue.Entry <E> >(initCapacity);
     keyToEntry   = mapFactory.NewMap(initCapacity);
 }
 public BinaryHeapPriorityQueue(MapFactory <E, BinaryHeapPriorityQueue.Entry <E> > mapFactory)
 {
     indexToEntry = new List <BinaryHeapPriorityQueue.Entry <E> >();
     keyToEntry   = mapFactory.NewMap();
 }
 public TwoDimensionalMap(MapFactory <K1, IDictionary <K2, V> > mf1, MapFactory <K2, V> mf2)
 {
     this.mf1 = mf1;
     this.mf2 = mf2;
     this.map = mf1.NewMap();
 }