Exemplo n.º 1
0
 public int Count(uint type)
 {
     if (Counts.ContainsKey(type))
     {
         return(Counts[type]);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 2
0
        public void SetKey(string Key, string Value)
        {
            if (Capacity <= 0)
            {
                return;
            }

            // If key does exist, we're returning from here
            if (Vals.ContainsKey(Key))
            {
                Vals.Add(Key, Value);
                GetKey(Key);
                return;
            }

            if (Vals.Count >= Capacity)
            {
                IEnumerator <string> enumerator = Lists[Minimum].GetEnumerator();
                if (enumerator.MoveNext())
                {
                    string evit = enumerator.Current;
                    Lists[Minimum].Remove(evit);
                    Vals.Remove(evit);
                    Counts.Remove(evit);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Invalid access at SetKey!");
                }
            }

            Console.WriteLine("Hereererre");

            // If the key is new, insert the value and current
            // min should be 1 of course
            if (!Vals.ContainsKey(Key))
            {
                Vals.Add(Key, Value);
            }

            if (!Counts.ContainsKey(Key))
            {
                Counts.Add(Key, 1);
            }
            Minimum = 1;
            if (!Lists.ContainsKey(Minimum))
            {
                Lists.Add(Minimum, new LinkedHashSet <string>());
            }
            else
            {
                Lists[Minimum].Add(Key);
            }
        }
Exemplo n.º 3
0
 public void Add(T item, int count)
 {
     if (Counts.ContainsKey(item))
     {
         Counts[item] += count;
     }
     else
     {
         Counts[item] = count;
     }
 }
Exemplo n.º 4
0
 public void Add(T item)
 {
     if (Counts.ContainsKey(item))
     {
         Counts[item] += 1;
     }
     else
     {
         Counts[item] = 1;
     }
 }
Exemplo n.º 5
0
 public int this[T key]
 {
     get
     {
         if (Counts.ContainsKey(key))
         {
             return(Counts[key]);
         }
         else
         {
             return(0);
         }
     }
 }
Exemplo n.º 6
0
        public string GetKey(string key)
        {
            if (!Vals.ContainsKey(key))
            {
                return("");
            }

            // Get the count from counts map
            Int64 Count = Counts[key];

            // Increase the counter
            if (!Counts.ContainsKey(key))
            {
                Counts.Add(key, Count + 1);
            }


            // Remove the element from the counter to LinkedHashSet
            Lists[Count].Remove(key);


            // When the current     min does not have any data, next
            // one would be the min
            if (Count == Minimum &&
                Lists[Count].Count == 0)
            {
                Minimum += Minimum + 1;
            }


            if (!Lists.ContainsKey(Count + 1))
            {
                Lists.Add(Count + 1, new LinkedHashSet <string>());
            }

            Lists[Count].Add(key);

            return(Vals[key]);
        }