public virtual int GetCount(K1 o1, K2 o2)
        {
            IntCounter <K2> c = GetCounter(o1);

            if (c.TotalCount() == 0 && !c.KeySet().Contains(o2))
            {
                return(DefaultReturnValue());
            }
            return(c.GetIntCount(o2));
        }
        public virtual IntCounter <Pair <K1, K2> > Flatten()
        {
            IntCounter <Pair <K1, K2> > result = new IntCounter <Pair <K1, K2> >();

            result.SetDefaultReturnValue(defaultValue);
            foreach (K1 key1 in FirstKeySet())
            {
                IntCounter <K2> inner = GetCounter(key1);
                foreach (K2 key2 in inner.KeySet())
                {
                    result.SetCount(new Pair <K1, K2>(key1, key2), inner.GetIntCount(key2));
                }
            }
            return(result);
        }
 /// <summary>Produces a new ConditionalCounter.</summary>
 /// <returns>a new ConditionalCounter, where order of indices is reversed</returns>
 public static Edu.Stanford.Nlp.Stats.TwoDimensionalIntCounter <K2, K1> ReverseIndexOrder <K1, K2>(Edu.Stanford.Nlp.Stats.TwoDimensionalIntCounter <K1, K2> cc)
 {
     // the typing on the outerMF is violated a bit, but it'll work....
     Edu.Stanford.Nlp.Stats.TwoDimensionalIntCounter <K2, K1> result = new Edu.Stanford.Nlp.Stats.TwoDimensionalIntCounter((MapFactory)cc.outerMF, (MapFactory)cc.innerMF);
     foreach (K1 key1 in cc.FirstKeySet())
     {
         IntCounter <K2> c = cc.GetCounter(key1);
         foreach (K2 key2 in c.KeySet())
         {
             int count = c.GetIntCount(key2);
             result.SetCount(key2, key1, count);
         }
     }
     return(result);
 }
 public virtual void Clean()
 {
     foreach (K1 key1 in Generics.NewHashSet(map.Keys))
     {
         IntCounter <K2> c = map[key1];
         foreach (K2 key2 in Generics.NewHashSet(c.KeySet()))
         {
             if (c.GetIntCount(key2) == 0)
             {
                 c.Remove(key2);
             }
         }
         if (c.KeySet().IsEmpty())
         {
             Sharpen.Collections.Remove(map, key1);
         }
     }
 }