Exemple #1
0
 public PixelRow()
 {
     InitializeComponent();
     tableLayoutPanel.SuspendLayout();
     SuspendLayout();
     labelCollection = Vec.Init(Count, i => {
         var label = new Label {
             BackColor   = Color.FromArgb(50 + i * 50, 50 + i * 50, 50 + i * 50),
             Dock        = DockStyle.Fill,
             FlatStyle   = FlatStyle.Flat,
             ForeColor   = Color.Transparent,
             BorderStyle = BorderStyle.None,
             Location    = new Point(1, 1),
             Margin      = new Padding(0),
             Name        = "label_" + i,
             Size        = new Size(24, 24),
             TabIndex    = i,
         };
         label.MouseDown   += label_MouseDown;
         label.DoubleClick += label_DoubleClicked;
         tableLayoutPanel.Controls.Add(label, i, 0);
         return(label);
     });
     tableLayoutPanel.ResumeLayout(false);
     ResumeLayout(false);
 }
Exemple #2
0
        public void AlphaTest()
        {
            var(elapsed, result) = Strategies.Run(
                (int)1E+4,
                Seq.From <(string, Func <string[], string[]>)>(
                    ("cla", vec => vec.Map(x => "-" + x)),
                    ("arc", vec => vec.ParaMapArc(x => "-" + x)),
                    ("edg", vec => vec.ParaMapEdg(x => "-" + x)),
                    ("fut", vec => vec.ParaMapFut(x => "-" + x))
                    ),
                Seq.From(
                    ("alpha", Vec.From("foo", "bar", "zen", "eck", "van", "sto", "knu")),
                    ("beta", Vec.Init(256, x => x.ToString("000"))),
                    ("gamma", Vec.Init(1024, x => x.ToString("0000")))
                    // ("delta", Vec.Init(16384, x => x.ToString("00000")))
                    )
                );

            elapsed.Deco(presets: (Presets.Subtle, Presets.Fresh)).Says("Elapsed");
            result.Deco(presets: (Presets.Subtle, Presets.Fresh)).Says("Results");
            var candidates = Seq.From(
                ("alpha", "cla"),
                ("alpha", "arc"),
                ("alpha", "edg"),
                ("alpha", "fut")
                );

            foreach (var(side, head) in candidates)
            {
                result[side, head].Deco().Says(side + "-" + head);
            }
        }
Exemple #3
0
        public void Test()
        {
            var mx     = Vec.Init(3, i => Vec.Init(4, j => i + j));
            var target = mx.NestToMatrix();

            target.Deco().Logger();
        }
        public void RefPushColumnTest()
        {
            var mx = Vec.Init(3, i => Vec.Init(4, j => i + j));

            NestedVectorExt.PushColumn(ref mx, Vec.Init(3, i => 0));
            mx.NestToMatrix()
            .Deco()
            .Logger();
        }
        public void PushColumnTest()
        {
            var mx = Vec.Init(3, i => Vec.Init(4, j => i + j));

            mx
            .PushColumn(Vec.Init(3, i => 0))
            .NestToMatrix()
            .Deco()
            .Logger();
        }
Exemple #6
0
        public int IndexHead(string y)
        {
            var ci = this.Head.IndexOf(y);

            if (ci >= 0)
            {
                return(ci);
            }
            Ext.PushColumn(ref this.Rows, Vec.Init(this.Rows.Height(), i => this.Init()));
            return(ci + Vec.Push(ref this.Head, y));
        }
Exemple #7
0
        public int IndexSide(string x)
        {
            var ri = this.Side.IndexOf(x);

            if (ri >= 0)
            {
                return(ri);
            }
            Ext.PushRow(ref this.Rows, Vec.Init(this.Rows.Width(), j => this.Init()));
            return(ri + Vec.Push(ref this.Side, x));
        }
Exemple #8
0
        public void Test()
        {
            var samples = new[, ] {
                { 1, 2, 3, 4, 5 },
                { 10, 20, 30, 40, 50 },
                { 100, 200, 300, 400, 500 },
            };
            var          eta    = new Stopwatch();
            var          record = new Dictionary <String, long>();
            const double count  = (int)2E+6;

            eta.Start();
            for (var i = 0; i < count; i++)
            {
                var vec = Vec.Init(8, x => x);
            }
            eta.Stop();
            record.Add("Init", eta.ElapsedMilliseconds);


            eta.Restart();
            for (var i = 0; i < count; i++)
            {
                var vec = Vec.V1B <int>(8);
            }
            eta.Stop();
            record.Add("V1B", eta.ElapsedMilliseconds);

            // var vec1B = Inits.V1B<int>(4);
            // var (lo, hi) = (vec1B.LoHi());
            // for (var i = lo; i < hi; i++)
            //   vec1B[i] = i;
            //
            // eta.Restart();
            // for (var i = 0; i < count; i++) {
            //   var vec = vec1B.ZeroOut();
            // }
            // eta.Stop();
            // record.Add("ZeroOut", eta.ElapsedMilliseconds);
            // Console.WriteLine($"{vec1B.ZeroOut()}");
            //
            // eta.Restart();
            // for (int i = 0; i < count; i++) {
            //   var col = samples.IterColumn(2);
            // }
            // eta.Stop();
            // record.Add("IterColumn", eta.ElapsedMilliseconds);

            foreach (var entry in record)
            {
                Console.WriteLine($"[{entry.Key}] ({entry.Value})");
            }
        }