Beispiel #1
0
        public void RemoveAt(int index)
        {
            if (index >= list.Count || index < 0)
            {
                throw new ArgumentOutOfRangeException("index", "Index Out Of Range (0-" + list.Count + "): " + index);
            }

            TKey key = list[index].item1;
            int  num = list[index].item2;

            List <TValue> sub = dict[key];

            sub.RemoveAt(num);
            if (sub.Count == 0)
            {
                dict.Remove(key);
            }

            list.RemoveAt(index);

            //shifting all of the nums
            int listCount = list.Count;

            for (int i = 0; i < listCount; i++)
            {
                TKey ikey = list[i].item1;
                int  inum = list[i].item2;
                if (Equals(key, ikey) && inum >= num)
                {
                    list[i] = new TupleSet <TKey, int, TValue>(ikey, inum - 1, list[i].item3);
                }
            }
        }
Beispiel #2
0
        public TValue this[TKey key, int num]
        {
            get { return(dict[key][num]); }
            set {
                if (dict.ContainsKey(key))
                {
                    List <TValue> sub = dict[key];

                    if (num >= sub.Count || num < 0)
                    {
                        throw new ArgumentOutOfRangeException("num", "Index Out Of Range (0-" + sub.Count + "): " + num);
                    }

                    if (num == sub.Count)
                    {
                        Add(key, value);                                      //adding right after the last
                    }
                    else
                    {
                        dict[key][num] = value;
                        list[IndexOfKeyNum(key, num)] = new TupleSet <TKey, int, TValue>(key, num, value);
                    }
                }
                else if (num == 0)
                {
                    Add(key, value);
                }
                else
                {
                    throw new ArgumentException("key", "Key Not Found: " + key);
                }
            }
        }
Beispiel #3
0
 public void Set(TKey key, T1 val1, T2 val2)
 {
     if (!dict.ContainsKey(key))
     {
         dict.Add(key, new TupleSet <T1, T2>(val1, val2));
     }
     else
     {
         dict[key] = new TupleSet <T1, T2>(val1, val2);
     }
 }                                                                                                                                                                                    //same as add with owerwrite
Beispiel #4
0
 public void CheckAdd(TKey key, T1 val1, T2 val2, bool overwrite = false)
 {
     if (!dict.ContainsKey(key))
     {
         dict.Add(key, new TupleSet <T1, T2>(val1, val2));
     }
     else if (overwrite)
     {
         dict[key] = new TupleSet <T1, T2>(val1, val2);
     }
 }
Beispiel #5
0
 public TValue this[TKey key]
 {
     get { return(dict[key]); }
     set {
         if (dict.ContainsKey(key))
         {
             dict[key]             = value;
             list[IndexOfKey(key)] = new TupleSet <TKey, TValue>(key, value);
         }
         else
         {
             Add(key, value);
         }
     }
 }
Beispiel #6
0
        public TValue this[int index]
        {
            get {
                if (index >= list.Count || index < 0)
                {
                    throw new ArgumentOutOfRangeException("index", "Index Out Of Range (0-" + list.Count + "): " + index);
                }
                return(list[index].item2);
            }
            set {
                if (index >= list.Count || index < 0)
                {
                    throw new ArgumentOutOfRangeException("index", "Index Out Of Range (0-" + list.Count + "): " + index);
                }

                TKey key = list[index].item1;

                list[index] = new TupleSet <TKey, TValue>(key, value);
                dict[key]   = value;
            }
        }
Beispiel #7
0
        public static void GetProgresByTag(string tag, out float contained, out float calculated, out float ready)
        {
            if (profile)
            {
                Profiler.BeginSample("Get Progress Tag");
            }

            DictTuple <string, bool, bool> dict = new DictTuple <string, bool, bool>();

            int queueCount = queue.Count;

            contained = 0; calculated = 0; ready = 0;

            for (int i = 0; i < queueCount; i++)
            {
                ThreadWorker worker = queue[i];
                if (worker.stage == Stage.stop || worker.stage == Stage.blank)
                {
                    continue;
                }
                if (!worker.tag.Contains(tag))
                {
                    continue;
                }

                //contains
                if (!dict.ContainsKey(worker.tag))
                {
                    dict.Add(worker.tag, true, true);
                }

                //calculated
                TupleSet <bool, bool> tuple = dict[worker.tag];
                if (worker.stage != Stage.applyEnqueued && worker.stage != Stage.coroutineEnqueued && worker.stage != Stage.coroutineRunning && worker.stage != Stage.ready)
                {
                    tuple.item1 = false; tuple.item2 = false; dict[worker.tag] = tuple;
                }

                //ready
                if (worker.stage != Stage.ready)
                {
                    tuple.item2 = false; dict[worker.tag] = tuple;
                }
            }

            //calculating total statistics
            contained = dict.Count;
            foreach (TupleSet <bool, bool> tuple in dict.Values())
            {
                if (tuple.item1)
                {
                    calculated++;
                }
                if (tuple.item2)
                {
                    ready++;
                }
            }

            if (profile)
            {
                Profiler.EndSample();
            }
        }
Beispiel #8
0
 public void SetVal2(TKey key, T2 val)
 {
     TupleSet <T1, T2> tuple = dict[key]; tuple.item2 = val; dict[key] = tuple;
 }