コード例 #1
0
        static void Main()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add("Manesh");
            list.Add("Akshay");
            list.Add("Vikash");
            list.Add("Anuj");
            list.Add("Dharmesh");
            list.Add("Raman");

            Console.WriteLine("Initial arraylist contents:");
            foreach (string v in list)
            {
                Console.WriteLine(v);
            }
            list.Reverse();
            Console.WriteLine("Arraylist contents after reversing:");
            foreach (string v in list)
            {
                Console.WriteLine(v);
            }
            list.Sort();
            Console.WriteLine(list.BinarySearch("Raman"));  //searcher
            Console.WriteLine("Arraylist contents after sorting:");
            foreach (string v in list)
            {
                Console.WriteLine(v);
            }
            Console.ReadKey();
        }
コード例 #2
0
        protected void addToSortedRewriteList(string programName, RewriteOperation op)
        {
            ArrayList rewrites = (ArrayList)getProgram(programName);

            // if at or beyond last op's index, just append
            if (op.index >= getLastRewriteTokenIndex(programName))
            {
                rewrites.Add(op);                 // append to list of operations
                // record the index of this operation for next time through
                setLastRewriteTokenIndex(programName, op.index);
                return;
            }
            // not after the last one, so must insert to ordered list
            int pos = rewrites.BinarySearch(op, RewriteOperationComparer.Default);

            if (pos < 0)
            {
                rewrites.Insert(-pos - 1, op);
            }
        }
コード例 #3
0
 ///<summary>
 ///Uses a binary search algorithm to locate a specific element in the sorted base_scopeArrayList or a portion of it.
 ///</summary>
 ///<param name="value">The Object to locate. The value can be a null reference.<param>
 ///<returns>The zero-based index of value in the sorted base_scopeArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.</returns>
 public int BinarySearch(base_scope value)
 {
     return(arr.BinarySearch(value));
 }
コード例 #4
0
        private void Button_SaveKeyBinding_Click(object sender, RoutedEventArgs e)
        {
            if (ComboBox_FolderExplorer.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_FolderExplorer.Focus();
                return;
            }
            if (ComboBox_Outline.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_Outline.Focus();
                return;
            }
            if (ComboBox_OutlineMarginRight.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_OutlineMarginRight.Focus();
                return;
            }
            if (ComboBox_RunLuaExe.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_RunLuaExe.Focus();
                return;
            }
            var keyFolderExplorer = ComboBox_FolderExplorer.SelectedItem.ToString();
            var keyOutline = ComboBox_Outline.SelectedItem.ToString();
//            var keyOutlineMarginLeft = ComboBox_OutlineMarginLeft.SelectedItem.ToString();
            var keyOutlineMarginRight = ComboBox_OutlineMarginRight.SelectedItem.ToString();
            var keyRunLuaExe = ComboBox_RunLuaExe.SelectedItem.ToString();

            System.Collections.ArrayList names = new System.Collections.ArrayList() { };
            names.Add(keyFolderExplorer);
            names.Add(keyOutline);
//            names.Add(keyOutlineMarginLeft);
            names.Add(keyOutlineMarginRight);
            names.Add(keyRunLuaExe);
            System.Collections.ArrayList judge = new System.Collections.ArrayList() { };
            foreach (object ob in names)
            {
                if (judge.BinarySearch(ob) >= 0)
                {
                    System.Windows.MessageBox.Show("Can't set same key binding");
                    return;
                }
                judge.Add(ob);
            }


            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindFolder, keyFolderExplorer);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindOutline, keyOutline);
//            BabePackage.Setting.SetBindingKey("OutlineMarginLeft", keyOutlineMarginLeft);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindEditorOutlineRight, keyOutlineMarginRight);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindRunExec, keyRunLuaExe);
            BabePackage.Setting.Save();

            System.Windows.MessageBox.Show("Save key binding");
        }
コード例 #5
0
        private void Compute(bool comp_x, bool comp_y, object btn)
        {
            m_Running = true;
            EnableButtons(btn);
            m_Stop           = false;
            pbProgress.Value = 0.0;
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
            {
                try
                {
                    SySal.Processing.QuickMapping.QuickMapper QM    = new SySal.Processing.QuickMapping.QuickMapper();
                    SySal.Processing.QuickMapping.Configuration qmc = (SySal.Processing.QuickMapping.Configuration)QM.Config;
                    qmc.FullStatistics       = false;
                    qmc.UseAbsoluteReference = true;
                    qmc.PosTol   = S.PosTolerance;
                    qmc.SlopeTol = 1.0;
                    QM.Config    = qmc;
                    System.Collections.ArrayList xconv = new System.Collections.ArrayList();
                    System.Collections.ArrayList yconv = new System.Collections.ArrayList();
                    int sfi;
                    for (sfi = 0; sfi < SummaryFiles.Length; sfi++)
                    {
                        QuasiStaticAcquisition Q = new QuasiStaticAcquisition(SummaryFiles[sfi]);
                        foreach (QuasiStaticAcquisition.Sequence seq in Q.Sequences)
                        {
                            int ly;
                            SySal.Imaging.Cluster[] prevC = FilterClusters(seq.Layers[0].ReadClusters());
                            SySal.Imaging.Cluster[] nextC = null;
                            SySal.BasicTypes.Vector prevP = seq.Layers[0].Position;
                            SySal.BasicTypes.Vector nextP = new SySal.BasicTypes.Vector();
                            for (ly = 1; ly < seq.Layers.Length; ly++)
                            {
                                if (m_Stop)
                                {
                                    throw new Exception("Stopped.");
                                }
                                nextC = FilterClusters(seq.Layers[ly].ReadClusters());
                                nextP = seq.Layers[ly].Position;
                                this.Invoke(new dSetValue(SetValue), 100.0 * (((double)seq.Id + (double)(ly - 1) / (double)(seq.Layers.Length - 1)) / (double)(Q.Sequences.Length) + sfi) / SummaryFiles.Length);
                                SySal.BasicTypes.Vector2 dp   = new SySal.BasicTypes.Vector2(seq.Layers[ly].Position - seq.Layers[ly - 1].Position);
                                SySal.BasicTypes.Vector2 dp1  = dp; dp1.X /= S.MinConv; dp1.Y /= S.MinConv;
                                SySal.BasicTypes.Vector2 dp2  = dp; dp2.X /= S.MaxConv; dp2.Y /= S.MaxConv;
                                SySal.BasicTypes.Vector2 da   = new SySal.BasicTypes.Vector2(); da.X = 0.5 * (dp1.X + dp2.X); da.Y = 0.5 * (dp1.Y + dp2.Y);
                                SySal.BasicTypes.Vector2 dext = new SySal.BasicTypes.Vector2(); dext.X = Math.Abs(dp1.X - dp2.X); dext.Y = Math.Abs(dp1.Y - dp2.Y);
                                SySal.Tracking.MIPEmulsionTrackInfo[] prevmap = new SySal.Tracking.MIPEmulsionTrackInfo[prevC.Length];
                                int i;
                                for (i = 0; i < prevC.Length; i++)
                                {
                                    SySal.Tracking.MIPEmulsionTrackInfo info = new SySal.Tracking.MIPEmulsionTrackInfo();
                                    info.Intercept.X = prevC[i].X;
                                    info.Intercept.Y = prevC[i].Y;
                                    prevmap[i]       = info;
                                }
                                SySal.Tracking.MIPEmulsionTrackInfo[] nextmap = new SySal.Tracking.MIPEmulsionTrackInfo[nextC.Length];
                                for (i = 0; i < nextC.Length; i++)
                                {
                                    nextmap[i] = new SySal.Tracking.MIPEmulsionTrackInfo();
                                }
                                double[,] convopt = new double[, ] {
                                    { 1.0, 1.0 }, { -1.0, 1.0 }, { -1.0, -1.0 }, { 1.0, -1.0 }
                                };
                                int o;
                                SySal.Scanning.PostProcessing.PatternMatching.TrackPair[] bestpairs = new SySal.Scanning.PostProcessing.PatternMatching.TrackPair[0];
                                SySal.BasicTypes.Vector2 bestda = new SySal.BasicTypes.Vector2();
                                for (o = 0; o < convopt.GetLength(0); o++)
                                {
                                    try
                                    {
                                        for (i = 0; i < nextC.Length; i++)
                                        {
                                            SySal.Tracking.MIPEmulsionTrackInfo info = nextmap[i];
                                            info.Intercept.X = nextC[i].X + da.X * convopt[o, 0];
                                            info.Intercept.Y = nextC[i].Y + da.Y * convopt[o, 1];
                                            nextmap[i]       = info;
                                        }
                                        SySal.Scanning.PostProcessing.PatternMatching.TrackPair[] prs = QM.Match(prevmap, nextmap, 0.0, dext.X, dext.Y);
                                        if (prs.Length > bestpairs.Length)
                                        {
                                            bestda.X  = da.X * convopt[o, 0];
                                            bestda.Y  = da.Y * convopt[o, 1];
                                            bestpairs = prs;
                                        }
                                    }
                                    catch (Exception xc) { }
                                }

                                if (bestpairs.Length >= S.MinMatches)
                                {
                                    double[] deltas = new double[bestpairs.Length];
                                    for (i = 0; i < bestpairs.Length; i++)
                                    {
                                        deltas[i] = bestpairs[i].First.Info.Intercept.X - nextC[bestpairs[i].Second.Index].X;
                                    }
                                    bestda.X = NumericalTools.Fitting.Quantiles(deltas, new double[] { 0.5 })[0];
                                    if (bestda.X != 0.0)
                                    {
                                        double v = dp.X / bestda.X;
                                        int pos  = xconv.BinarySearch(v);
                                        if (pos < 0)
                                        {
                                            pos = ~pos;
                                        }
                                        xconv.Insert(pos, v);
                                    }
                                    for (i = 0; i < bestpairs.Length; i++)
                                    {
                                        deltas[i] = bestpairs[i].First.Info.Intercept.Y - nextC[bestpairs[i].Second.Index].Y;
                                    }
                                    bestda.Y = NumericalTools.Fitting.Quantiles(deltas, new double[] { 0.5 })[0];
                                    if (bestda.Y != 0.0)
                                    {
                                        double v = dp.Y / bestda.Y;
                                        int pos  = yconv.BinarySearch(v);
                                        if (pos < 0)
                                        {
                                            pos = ~pos;
                                        }
                                        yconv.Insert(pos, v);
                                    }
                                    if (comp_x && xconv.Count > 0)
                                    {
                                        int bmin, bmax;
                                        bmin = (int)Math.Ceiling(xconv.Count * 0.16);
                                        bmax = (int)Math.Floor(xconv.Count * 0.84);
                                        if (bmax < bmin)
                                        {
                                            bmin = bmax;
                                        }
                                        double[] sample1s = (double[])xconv.GetRange(bmin, bmax - bmin + 1).ToArray(typeof(double));
                                        XConv             = NumericalTools.Fitting.Average(sample1s);
                                        this.Invoke(new dSetConv(SetConv), new object[] { true, XConv, 0.5 * (sample1s[sample1s.Length - 1] - sample1s[0]) / Math.Sqrt(sample1s.Length) });
                                    }
                                    if (comp_y && yconv.Count > 0)
                                    {
                                        int bmin, bmax;
                                        bmin = (int)Math.Ceiling(yconv.Count * 0.16);
                                        bmax = (int)Math.Floor(yconv.Count * 0.84);
                                        if (bmax < bmin)
                                        {
                                            bmin = bmax;
                                        }
                                        double[] sample1s = (double[])yconv.GetRange(bmin, bmax - bmin + 1).ToArray(typeof(double));
                                        YConv             = NumericalTools.Fitting.Average(sample1s);
                                        this.Invoke(new dSetConv(SetConv), new object[] { false, YConv, 0.5 * (sample1s[sample1s.Length - 1] - sample1s[0]) / Math.Sqrt(sample1s.Length) });
                                    }
                                }
                                prevP = nextP;
                                prevC = nextC;
                            }
                        }
                    }
                }
                catch (Exception xc1)
                {
                    iLog.Log("Compute", xc1.ToString());
                }
                m_Running = false;
                this.Invoke(new dEnableButtons(EnableButtons), btn);
            }));
            thread.Start();
        }
コード例 #6
0
 ///<summary>
 ///Uses a binary search algorithm to locate a specific element in the sorted unit_nodeArrayList or a portion of it.
 ///</summary>
 ///<param name="value">The Object to locate. The value can be a null reference.<param>
 ///<returns>The zero-based index of value in the sorted unit_nodeArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.</returns>
 public int BinarySearch(unit_node value)
 {
     return(arr.BinarySearch(value));
 }
コード例 #7
0
        private void Button_SaveKeyBinding_Click(object sender, RoutedEventArgs e)
        {
            if (ComboBox_FolderExplorer.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_FolderExplorer.Focus();
                return;
            }
            if (ComboBox_Outline.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_Outline.Focus();
                return;
            }
            if (ComboBox_OutlineMarginRight.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_OutlineMarginRight.Focus();
                return;
            }
            if (ComboBox_RunLuaExe.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Must select one key binding");
                ComboBox_RunLuaExe.Focus();
                return;
            }
            var keyFolderExplorer = ComboBox_FolderExplorer.SelectedItem.ToString();
            var keyOutline        = ComboBox_Outline.SelectedItem.ToString();
//            var keyOutlineMarginLeft = ComboBox_OutlineMarginLeft.SelectedItem.ToString();
            var keyOutlineMarginRight = ComboBox_OutlineMarginRight.SelectedItem.ToString();
            var keyRunLuaExe          = ComboBox_RunLuaExe.SelectedItem.ToString();

            System.Collections.ArrayList names = new System.Collections.ArrayList()
            {
            };
            names.Add(keyFolderExplorer);
            names.Add(keyOutline);
//            names.Add(keyOutlineMarginLeft);
            names.Add(keyOutlineMarginRight);
            names.Add(keyRunLuaExe);
            System.Collections.ArrayList judge = new System.Collections.ArrayList()
            {
            };
            foreach (object ob in names)
            {
                if (judge.BinarySearch(ob) >= 0)
                {
                    System.Windows.MessageBox.Show("Can't set same key binding");
                    return;
                }
                judge.Add(ob);
            }


            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindFolder, keyFolderExplorer);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindOutline, keyOutline);
//            BabePackage.Setting.SetBindingKey("OutlineMarginLeft", keyOutlineMarginLeft);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindEditorOutlineRight, keyOutlineMarginRight);
            BabePackage.Setting.SetBindingKey(SettingConstants.SettingKeys.KeyBindRunExec, keyRunLuaExe);
            BabePackage.Setting.Save();

            System.Windows.MessageBox.Show("Save key binding");
        }
コード例 #8
0
 ///<summary>
 ///Uses a binary search algorithm to locate a specific element in the sorted using_namespaceArrayList or a portion of it.
 ///</summary>
 ///<param name="value">The Object to locate. The value can be a null reference.<param>
 ///<returns>The zero-based index of value in the sorted using_namespaceArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.</returns>
 public int BinarySearch(using_namespace value)
 {
     return(arr.BinarySearch(value));
 }
コード例 #9
0
        /// <summary>
        /// Prepare an xml file and insert the records...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _btnPrepareData_Click(object sender, EventArgs e)
        {
            AWAPI_BusinessLibrary.library.ContestLibrary           lib  = new AWAPI_BusinessLibrary.library.ContestLibrary();
            IList <AWAPI_Data.CustomEntities.ContestEntryExtended> list = lib.GetContestEntryListByGroupId(Convert.ToInt64(_groupId.Text), "", null);

            if (list == null || list.Count == 0)
            {
                Response.Write("<font color='#ff0000'>No entries has been found</font><br/>");
                return;
            }

            //filter based on start and end dates
            DateTime?dtStart = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_startDate.Text);
            DateTime?dtEnd   = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_endDate.Text);

            if (dtStart == null || dtEnd == null)
            {
                Response.Write("<font color='#ff0000'>Start and End dates are required</font><br/>");
                return;
            }
            var tmpList = from l in list
                          where l.createDate >= dtStart.Value && l.createDate <= dtEnd.Value
                          orderby l.email
                          select l;

            if (tmpList == null || tmpList.Count() == 0)
            {
                Response.Write("<font color='#ff0000'>No entries has been found in the date range</font><br/>");
                return;
            }
            list = tmpList.ToList();

            //Write the results to the xml
            System.Data.DataTable dt = new System.Data.DataTable("contestentries");
            dt.Columns.Add("email");
            dt.Columns.Add("firstname");
            dt.Columns.Add("lastname");
            dt.Columns.Add("createdate");
            dt.Columns.Add("sent");

            System.IO.TextWriter         tw     = new System.IO.StreamWriter("c:\\emaillist.txt");
            System.Collections.ArrayList emails = new System.Collections.ArrayList();
            foreach (AWAPI_Data.CustomEntities.ContestEntryExtended ent in list)
            {
                string email = ent.email.ToLower().Trim();
                if (isEmail(email))
                {
                    if (emails.BinarySearch(email) >= 0)
                    {
                        continue;
                    }

                    System.Data.DataRow dr = dt.NewRow();
                    dr["email"]     = email;
                    dr["firstname"] = ent.firstName;
                    dr["lastname"]  = ent.lastName;
                    dr["sent"]      = "0";

                    dt.Rows.Add(dr);
                    emails.Add(email);

                    tw.Write(email + ",");
                }
            }
            dt.WriteXml(XML_Path);
            tw.Close();
            _prepareDataResult.Text = "Number of records : " + dt.Rows.Count.ToString() + "<br/>" +
                                      "Files location: " + XML_Path;

            _resultList.DataSource = dt;
            _resultList.DataBind();
        }
コード例 #10
0
 ///<summary>
 ///Uses a binary search algorithm to locate a specific element in the sorted SymbolInfoArrayList or a portion of it.
 ///</summary>
 ///<param name="value">The Object to locate. The value can be a null reference.<param>
 ///<returns>The zero-based index of value in the sorted SymbolInfoArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.</returns>
 public int BinarySearch(SymbolInfo value)
 {
     return(arr.BinarySearch(value));
 }