Example #1
0
        public static void newBoolValueLayer(out getBoolValueDelegate get_del, out setBoolValueDelegate set_del)
        {
            int c = 0;

            while (true)
            {
                Random r = new Random();

                c = r.Next(int.MaxValue);
                while (b_dlg2id.ContainsValue(c))
                {
                    c = r.Next(int.MaxValue);
                }
                if (!id2nodelist.ContainsKey(c))
                {
                    break;
                }
            }



            get_del = delegate(MetricPoint node)
            {
                MetricPoint n = (MetricPoint)node;
                if (n.b_id2value.ContainsKey(c))
                {
                    return(n.b_id2value[c]);
                }
                else
                {
                    n.b_id2value.Add(c, false);
                    MetricPoint.id2nodelist[c].Add(node);
                }
                return(false);
            };

            b_dlg2id.Add(get_del, c);

            set_del = delegate(MetricPoint node, bool val)
            {
                MetricPoint n = (MetricPoint)node;
                if (n.b_id2value.ContainsKey(c))
                {
                    n.b_id2value[c] = val;
                }
                else
                {
                    n.b_id2value.Add(c, val);
                    MetricPoint.id2nodelist[c].Add(node);
                }
            };

            id2nodelist.Add(c, new List <MetricPoint>());
        }
Example #2
0
        public static void newFloatValueLayer(out getFloatValueDelegate get_del, out setFloatValueDelegate set_del)
        {
            Random r = new Random();

            int c = r.Next(int.MaxValue);

            while (f_dlg2id.ContainsValue(c))
            {
                c = r.Next(int.MaxValue);
            }

            get_del = delegate(MetricPoint node)
            {
                MetricPoint n = (MetricPoint)node;
                if (n.f_id2value.ContainsKey(c))
                {
                    return(n.f_id2value[c]);
                }
                else
                {
                    n.f_id2value.Add(c, double.MaxValue);
                    MetricPoint.id2nodelist[c].Add(node);
                }
                return(double.MaxValue);
            };

            f_dlg2id.Add(get_del, c);

            set_del = delegate(MetricPoint node, double val)
            {
                MetricPoint n = (MetricPoint)node;
                if (n.f_id2value.ContainsKey(c))
                {
                    n.f_id2value[c] = val;
                }
                else
                {
                    n.f_id2value.Add(c, val);
                    MetricPoint.id2nodelist[c].Add(node);
                }
            };

            id2nodelist.Add(c, new List <MetricPoint>());
        }