コード例 #1
0
    public static void Main()
    {
        // Creates and initializes a new Array and a new custom comparer.
        String[]  myKeys     = { "red", "GREEN", "YELLOW", "BLUE", "purple", "black", "orange" };
        String[]  myValues   = { "strawberries", "PEARS", "LIMES", "BERRIES", "grapes", "olives", "cantaloupe" };
        IComparer myComparer = new myReverserClass();

        // Displays the values of the Array.
        Console.WriteLine("The Array initially contains the following values:");
        PrintKeysAndValues(myKeys, myValues);

        // Sorts a section of the Array using the default comparer.
        Array.Sort(myKeys, myValues, 1, 3);
        Console.WriteLine("After sorting a section of the Array using the default comparer:");
        PrintKeysAndValues(myKeys, myValues);

        // Sorts a section of the Array using the reverse case-insensitive comparer.
        Array.Sort(myKeys, myValues, 1, 3, myComparer);
        Console.WriteLine("After sorting a section of the Array using the reverse case-insensitive comparer:");
        PrintKeysAndValues(myKeys, myValues);

        // Sorts the entire Array using the default comparer.
        Array.Sort(myKeys, myValues);
        Console.WriteLine("After sorting the entire Array using the default comparer:");
        PrintKeysAndValues(myKeys, myValues);

        // Sorts the entire Array using the reverse case-insensitive comparer.
        Array.Sort(myKeys, myValues, myComparer);
        Console.WriteLine("After sorting the entire Array using the reverse case-insensitive comparer:");
        PrintKeysAndValues(myKeys, myValues);
    }
コード例 #2
0
    public static void Main()
    {
        // Creates and initializes a new ArrayList.
        ArrayList myAL = new ArrayList();

        myAL.Add("The");
        myAL.Add("QUICK");
        myAL.Add("BROWN");
        myAL.Add("FOX");
        myAL.Add("jumps");
        myAL.Add("over");
        myAL.Add("the");
        myAL.Add("lazy");
        myAL.Add("dog");

        // Displays the values of the ArrayList.
        Console.WriteLine("The ArrayList initially contains the following values:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the default comparer.
        myAL.Sort(1, 3, null);
        Console.WriteLine("After sorting from index 1 to index 3 with the default comparer:");
        PrintIndexAndValues(myAL);

        // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
        IComparer myComparer = new myReverserClass();

        myAL.Sort(1, 3, myComparer);
        Console.WriteLine("After sorting from index 1 to index 3 with the reverse case-insensitive comparer:");
        PrintIndexAndValues(myAL);
    }
コード例 #3
0
        public ActionResult Index(FormCollection collection)
        {
            ArrayList Numero = new ArrayList();

            Numero.Add(Convert.ToInt32(collection["Numero1"]));
            Numero.Add(Convert.ToInt32(collection["Numero2"]));
            Numero.Add(Convert.ToInt32(collection["Numero3"]));

            IComparer myComparer = new myReverserClass();

            Numero.Sort(myComparer);

            Questao8Model resposta = new Questao8Model();

            if (Numero.Count > 0)
            {
                string Ordem = "";

                foreach (var Item in Numero)
                {
                    Ordem = Ordem + Item + ", ";
                }

                Ordem = Ordem.Substring(0, Ordem.Length - 2);

                resposta.Ordem = Ordem;

                return View(resposta);
            }

            return RedirectToAction("Index");
        }
コード例 #4
0
ファイル: SocketHandler.cs プロジェクト: 22hours/typress
        public static DataPacket SelectUsingReader(MySqlConnection cn, DataPacket pk)
        {
            DataPacket p = new DataPacket();

            cn.Open();
            string sql1 = "SELECT * FROM typress.members WHERE ID='" + pk.Id + "' AND PW='" + pk.Pw + "';";
            string sql2 = "SELECT * FROM typress.rank ORDER BY 'USAGE' DESC;";
            //string sql = "SELECT * FROM members";
            MySqlCommand    cmd1 = new MySqlCommand(sql1, cn);
            MySqlCommand    cmd2 = new MySqlCommand(sql2, cn);
            MySqlDataReader rdr1 = cmd1.ExecuteReader();

            while (rdr1.Read())
            {
                p.IsLogin        = true;
                p.Id             = (string)rdr1["ID"];
                p.Pw             = (string)rdr1["PW"];
                p.Name           = (string)rdr1["NAME"];
                p.Group          = (string)rdr1["GROUP"];
                p.Major          = (string)rdr1["MAJOR"];
                p.Money          = (int)rdr1["MONEY"];
                p.Memo           = (string)rdr1["MEMO"];
                p.JoinDate       = (DateTime)rdr1["JOINDATE"];
                p.ThreeWeekUsage = (int)rdr1["THREEUSAGE"];
                p.TwoWeekUsage   = (int)rdr1["TWOUSAGE"];
                p.OneWeekUsage   = (int)rdr1["ONEUSAGE"];
                p.TotalUsage     = (int)rdr1["TOTALUSAGE"];
            }
            rdr1.Close();
            MySqlDataReader rdr2 = cmd2.ExecuteReader();

            Ranking[] _rankers = new Ranking[100];
            // Ranking[] rs = new Ranking[3];
            int i = 0;

            while (rdr2.Read())
            {
                _rankers[i].Usage = (int)rdr2["USAGE"] * (-1);
                _rankers[i].Name  = (string)rdr2["NAME"];
                i++;
            }
            IComparer myComparer = new myReverserClass();

            Array.Sort(_rankers, myComparer);

            for (int k = 0; k < 3; k++)
            {
                p.rankers[k].Usage = _rankers[k].Usage * (-1);
                p.rankers[k].Name  = _rankers[k].Name;
            }

            _rankers = null;
            rdr2.Close();
            return(p);
        }
コード例 #5
0
    public static void Main()
    {
        String[]  myArr      = { "this", "is", "a", "test", "this", "is", "another", "test", "z" };
        IComparer myComparer = new myReverserClass();

        PrintIndexAndValues(myArr);

        Array.Sort(myArr, 1, 3);
        PrintIndexAndValues(myArr);

        // Sorts a section of the Array using the reverse case-insensitive comparer.
        Array.Sort(myArr, 1, 3, myComparer);
        PrintIndexAndValues(myArr);

        // Sorts the entire Array using the default comparer.
        Array.Sort(myArr);
        PrintIndexAndValues(myArr);

        // Sorts the entire Array using the reverse case-insensitive comparer.
        Array.Sort(myArr, myComparer);
        PrintIndexAndValues(myArr);
    }
コード例 #6
0
        public void GeometryDetection(Image <Bgr, Byte> src, Image <Bgr, Byte> dest, double upperCircleRadius, double lowerCircleRadius, out CircleF[] closeCircle, out double[] STD)
        {
            /*
             * Purpose : detection geometry radius
             * closeCircle[0]=upper close circle
             * closeCircle[1]=lower close circle
             * closeCircle[2]=upper max circle
             * closeCircle[3]=upper min circle
             * closeCircle[4]=lower max circle
             * closeCircle[5]=lower min circle
             *
             * STD[0]=upper close circle STD
             * STD[1]=lower close circle STD
             */
            //Gray level
            Image <Gray, Byte> grayImage = src.Convert <Gray, Byte>();
            //Otsu
            Image <Gray, Byte> otsuImage = grayImage.CopyBlank();

            CvInvoke.Threshold(grayImage, otsuImage, 128, 255, ThresholdType.Otsu);
            //contour
            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();

            CvInvoke.FindContours(otsuImage, contours, null, RetrType.External, ChainApproxMethod.ChainApproxNone);
            //otsuImage.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE, RETR_TYPE.CV_RETR_LIST);
            ArrayList contoursArrayList = new ArrayList();

            for (int i = 0; i < contours.Size; i++)
            {
                //dest.Draw(contours.ApproxPoly(1), new Bgr(Color.Blue), 1);
                contoursArrayList.Add(contours[i]);
            }
            IComparer mycomparer = new myReverserClass();

            contoursArrayList.Sort(mycomparer);
            closeCircle = new CircleF[6];
            STD         = new double[2];
            //最小平方圓
            closeCircle[0] = GetCloseCircle(((VectorOfPoint)contoursArrayList[0]).ToArray());
            List <Point> upperContour = new List <Point>(), lowerContour = new List <Point>();

            if (closeCircle[0].Radius <upperCircleRadius * 0.99 && closeCircle[0].Radius> lowerCircleRadius * 1.01)
            {
                Point[] points   = ((VectorOfPoint)contoursArrayList[0]).ToArray();
                double  r        = Math.Pow(closeCircle[0].Radius, 2);
                double  x        = closeCircle[0].Center.X;
                double  y        = closeCircle[0].Center.Y;
                double  distance = 0.0;
                foreach (var item in points)
                {
                    distance = Math.Pow(item.X - x, 2) + Math.Pow(item.Y - y, 2);
                    if (distance > r)
                    {
                        upperContour.Add(item);
                    }
                    else if (distance < r)
                    {
                        lowerContour.Add(item);
                    }
                }
                closeCircle[0] = GetCloseCircle(upperContour.ToArray());
                closeCircle[1] = GetCloseCircle(lowerContour.ToArray());
                closeCircle[2] = GetMaxMinCircle(upperContour.ToArray(), closeCircle[0], 0);
                closeCircle[3] = GetMaxMinCircle(upperContour.ToArray(), closeCircle[0], 1);
                closeCircle[4] = GetMaxMinCircle(lowerContour.ToArray(), closeCircle[1], 0);
                closeCircle[5] = GetMaxMinCircle(lowerContour.ToArray(), closeCircle[1], 1);
                //DrewCloseCircle(ref dest, closeCircle[0], Color.Yellow);
                //DrewCloseCircle(ref dest, closeCircle[1], Color.Yellow, 1);
                //DrewCloseCircle(ref dest, closeCircle[2], Color.Red, 2);
                //DrewCloseCircle(ref dest, closeCircle[3], Color.Green, 3);
                //DrewCloseCircle(ref dest, closeCircle[4], Color.Red, 4);
                //DrewCloseCircle(ref dest, closeCircle[5], Color.Green, 5);
                STD[0] = CalculateSTD(upperContour.ToArray(), closeCircle[0]);
                STD[1] = CalculateSTD(lowerContour.ToArray(), closeCircle[1]);
            }
            else
            {
                closeCircle[1] = GetCloseCircle(((VectorOfPoint)contoursArrayList[1]).ToArray());
                closeCircle[2] = GetMaxMinCircle(((VectorOfPoint)contoursArrayList[0]).ToArray(), closeCircle[0], 0);
                closeCircle[3] = GetMaxMinCircle(((VectorOfPoint)contoursArrayList[0]).ToArray(), closeCircle[0], 1);
                closeCircle[4] = GetMaxMinCircle(((VectorOfPoint)contoursArrayList[1]).ToArray(), closeCircle[1], 0);
                closeCircle[5] = GetMaxMinCircle(((VectorOfPoint)contoursArrayList[1]).ToArray(), closeCircle[1], 1);
                //DrewCloseCircle(ref dest, closeCircle[0], Color.Yellow);
                //DrewCloseCircle(ref dest, closeCircle[1], Color.Yellow, 1);
                //DrewCloseCircle(ref dest, closeCircle[2], Color.Red, 2);
                //DrewCloseCircle(ref dest, closeCircle[3], Color.Green, 3);
                //DrewCloseCircle(ref dest, closeCircle[4], Color.Red, 4);
                //DrewCloseCircle(ref dest, closeCircle[5], Color.Green, 5);
                STD[0] = CalculateSTD(((VectorOfPoint)contoursArrayList[0]).ToArray(), closeCircle[0]);
                STD[1] = CalculateSTD(((VectorOfPoint)contoursArrayList[1]).ToArray(), closeCircle[1]);
            }
        }
コード例 #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        // OK lets  create the handler for the web request
        // You could modify the end if this string for your different thingys,,relic etc
        // not the change to the URL to  prefgix with RAW  so  we just get the JSON
        HttpWebRequest request = wfmRequest("https://raw.githubusercontent.com/WFCD/warframe-drop-data/gh-pages/data/relics/" + relicTierHiddenField1.Value.ToString() + "/" + relicTierHiddenField2.Value.ToString() + ".json");

        // now send the http posst and get the acual respnse, here is where we send the request
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        // the respinse is a stream of data we need to out into a string
        // if there is an error , check what is returned here in the string
        string warframeResponse = (new StreamReader(response.GetResponseStream()).ReadToEnd());

        // we have a JSON object we need to  deserialsie it.. into something we can work with, rather than lots of subsring etc,
        JavaScriptSerializer serializer = new JavaScriptSerializer();

        // using our deserialer  we create a dynamic OBJECT.. in C#  this means when i runs it creates the type.. ratjer handy when you
        // dont know what to expect
        dynamic jsonObject = serializer.Deserialize <dynamic>(warframeResponse);

        // now we can access the data.
        // if you run in debig and pasue here.. you  can inspect the jsonobjext to see what you have
        // lets grba the tier and name.  we identifythe hson part  by the tag.. these are Dictionary objects..
        string tier = jsonObject["tier"]; // result is Dictionary<string,object> user with fields name, teamname, email and players with their values
        string name = jsonObject["name"]; // result is asdf

        // get  array if rewards
        dynamic rewards = jsonObject["rewards"]; //  rewards array with its values

        // get each rewards type array
        dynamic intactRewards      = rewards["Intact"];      // result is object[] rewards with its values
        dynamic exceptionalRewards = rewards["Exceptional"]; // result is object[] rewards with its values
        dynamic flawlessRewards    = rewards["Flawless"];    // result is object[] rewards with its values
        dynamic radiantRewards     = rewards["Radiant"];     // result is object[] rewards with its values


        //now we can access them.. you could use a foreach loop here to put into the lsit
        // or if clever youcan bind the lisstbox to the array

        string[]  relicName   = new string[6];
        decimal[] relicRarity = new decimal[6];

        for (int i = 0; i < 6; i++)
        {
            relicName[i]   = intactRewards[i]["itemName"];
            relicRarity[i] = intactRewards[i]["chance"];
        }

        IComparer myComparer = new myReverserClass();

        Array.Sort(relicRarity, relicName, myComparer);

        ListBox1.Items.Clear();
        ListBox1.Items.Add(relicTierHiddenField1.Value.ToString() + " " + relicTierHiddenField2.Value.ToString());
        ListBox1.Items.Add(relicName[0] + ": Common");
        ListBox1.Items.Add(relicName[1] + ": Common");
        ListBox1.Items.Add(relicName[2] + ": Common");
        ListBox1.Items.Add(relicName[3] + ": Uncommon");
        ListBox1.Items.Add(relicName[4] + ": Uncommon");
        ListBox1.Items.Add(relicName[5] + ": Rare");
    }
コード例 #8
0
        public List <EP_KEYWORD> NHanNanum(string file)
        {
            try
            {
                string   newFileName     = "/";
                string   newFileLocation = HttpContext.Server.MapPath(newFileName);
                Workflow workflow        = new Workflow(newFileLocation);

                workflow.appendPlainTextProcessor(new kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.PlainTextProcessor.SentenceSegmentor.SentenceSegmentor(), null);
                workflow.appendPlainTextProcessor(new kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.PlainTextProcessor.InformalSentenceFilter.InformalSentenceFilter(), null);

                workflow.setMorphAnalyzer(new kr.ac.kaist.swrc.jhannanum.plugin.MajorPlugin.MorphAnalyzer.ChartMorphAnalyzer.ChartMorphAnalyzer(), "conf/plugin/MajorPlugin/MorphAnalyzer/ChartMorphAnalyzer.json");
                workflow.appendMorphemeProcessor(new kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.MorphemeProcessor.UnknownMorphProcessor.UnknownProcessor(), null);

                workflow.setPosTagger(new kr.ac.kaist.swrc.jhannanum.plugin.MajorPlugin.PosTagger.HmmPosTagger.HMMTagger(), "conf/plugin/MajorPlugin/PosTagger/HmmPosTagger.json");
                workflow.appendPosProcessor(new kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.PosProcessor.NounExtractor.NounExtractor(), null);
                //workflow = WorkflowFactory.getPredefinedWorkflow(WorkflowFactory.WORKFLOW_NOUN_EXTRACTOR);

                /* Activate the work flow in the thread mode */
                workflow.activateWorkflow(true);

                //string document = System.IO.File.ReadAllText(file);
                string document = file;
                document.Trim();

                var      article_result = new List <EP_KEYWORD>(50);
                string[] docu_split     = document.Split(" ");

                for (int i = 0; i < docu_split.Length; i++)
                {
                    if (docu_split[i].Length > 85)
                    {
                        return(article_result);
                    }
                }


                /* Analysis using the work flow */
                workflow.analyze(document);

                int                   cnt        = 1;
                List <Record>         records    = new List <Record>();
                LinkedList <Sentence> resultList = workflow.getResultOfDocument(new Sentence(0, 0, false));
                foreach (Sentence s in resultList)
                {
                    Eojeol[] eojeolArray = s.Eojeols;
                    for (int i = 0; i < eojeolArray.Length; i++)
                    {
                        if (eojeolArray[i].length > 0)
                        {
                            String[] morphemes = eojeolArray[i].Morphemes;
                            for (int j = 0; j < morphemes.Length; j++)
                            {
                                //sb.Append(morphemes[j]);
                                records.Add(new Record()
                                {
                                    Id = cnt, Value = morphemes[j]
                                });
                                cnt++;
                                //sb.Append(", ");
                            }
                        }
                    }
                }

                var query = from r in records
                            group r by r.Value into g
                            select new { Count = g.Count(), Value = g.Key };
                query = query.OrderByDescending(a => a.Count);

                foreach (var v in query)
                {
                    if (v.Count > 1 && v.Value[0].ToString() != @"\" && v.Value[0].ToString() != @"&" && v.Value.Length != 1)
                    {
                        result_sb += v.Value + "|";
                    }
                }

                workflow.close();

                string[] array = result_sb.Split('|');
                if (array.Length == 0)
                {
                    return(article_result);
                }

                //var keyword_list = db.EP_KEYWORD.ToList().Where(e => e.Keyword.Contains(insert)).OrderByDescending(e => e.Count);
                DD[] map = new DD[46870];
                for (int i = 0; i < 46870; i++)
                {
                    map[i].value = i;
                }

                for (int i = 0; i < 5; i++)
                {
                    if (array.Length - 1 <= i)
                    {
                        break;
                    }
                    string insert       = array[i];
                    var    keyword_list = (from o in db.EP_KEYWORD
                                           //where o.Keyword.Contains(insert)
                                           where o.Keyword == insert
                                           select o.ArticleID).ToList();
                    foreach (int idx in keyword_list)
                    {
                        map[idx].key += 5 - i;
                    }
                }

                IComparer myComparer = new myReverserClass();
                Array.Sort(map, myComparer);
                Array.Reverse(map);

                for (int i = 0; i < 50; i++)
                {
                    if (map[i].key == 0)
                    {
                        break;
                    }
                    else if (map[i].key != 0)
                    {
                        int article = map[i].value;
                        article_result.AddRange(from o in db.EP_KEYWORD
                                                where o.ArticleID == article && o.Count == -1
                                                select o);
                        //article_list.AddRange(article_result.ToList());
                    }
                }
                //키워드 추출 후 블로그 포스트 추출된 부분
                //return article_list;
                return(article_result);
            }
            catch (Exception) { List <EP_KEYWORD> article_list = new List <EP_KEYWORD>(); return(article_list); }
        }
コード例 #9
0
ファイル: Book.cs プロジェクト: RemyCarivenc/Inventaire
    // Use this for initialization
    void Start()
    {
        gm = GameManager.Instance;

        /**_ Recover all Sprite on folder Resources _**/
        gm.Empty   = Resources.Load <Sprite>("Sprites/Empty");
        gm.WeaponS = Resources.LoadAll <Sprite>("Sprites/Weapon");
        gm.ArmorS  = Resources.LoadAll <Sprite>("Sprites/Armor");
        gm.UtilS   = Resources.LoadAll <Sprite>("Sprites/Util");
        gm.SpellsS = Resources.LoadAll <Sprite>("Sprites/Spells");
        gm.QuestS  = Resources.LoadAll <Sprite>("Sprites/Quest");
        gm.UniqueS = Resources.LoadAll <Sprite>("Sprites/Unique");

        /**_ Sorting Sprites _**/
        IComparer myComparer = new myReverserClass();

        Array.Sort(gm.WeaponS, myComparer);
        Array.Sort(gm.ArmorS, myComparer);
        Array.Sort(gm.UtilS, myComparer);
        Array.Sort(gm.SpellsS, myComparer);
        Array.Sort(gm.QuestS, myComparer);
        Array.Sort(gm.UniqueS, myComparer);


        /**_ Add all Sprite sorted on gm.AllSprite _**/
        for (int i = 0; i < gm.ArmorS.Length; i++)
        {
            gm.AllSprite.Add(gm.ArmorS[i]);
        }
        for (int i = 0; i < gm.WeaponS.Length; i++)
        {
            gm.AllSprite.Add(gm.WeaponS[i]);
        }
        for (int i = 0; i < gm.UtilS.Length; i++)
        {
            gm.AllSprite.Add(gm.UtilS[i]);
        }
        for (int i = 0; i < gm.SpellsS.Length; i++)
        {
            gm.AllSprite.Add(gm.SpellsS[i]);
        }
        for (int i = 0; i < gm.QuestS.Length; i++)
        {
            gm.AllSprite.Add(gm.QuestS[i]);
        }
        for (int i = 0; i < gm.UniqueS.Length; i++)
        {
            gm.AllSprite.Add(gm.UniqueS[i]);
        }

        currentAllSprites = new Sprite[gm.AllSprite.Count];
        for (int i = 0; i < gm.AllSprite.Count; i++)
        {
            currentAllSprites[i] = gm.AllSprite[i];
        }

        SpriteRenderer sprite;

        for (int i = 0; i < 6; i++)
        {
            sprite = pageGauche.transform.GetChild(0).GetChild(i).transform.GetComponent <SpriteRenderer>();
            if (nbCard > currentAllSprites.Length - 1)
            {
                sprite.sprite = gm.Empty;
            }
            else
            {
                sprite.sprite = currentAllSprites[nbCard];
            }
            nbCard++;
        }
        for (int i = 0; i < 6; i++)
        {
            sprite = pageDroite.transform.GetChild(0).GetChild(i).transform.GetComponent <SpriteRenderer>();
            if (nbCard > currentAllSprites.Length - 1)
            {
                sprite.sprite = gm.Empty;
            }
            else
            {
                sprite.sprite = currentAllSprites[nbCard];
            }
            nbCard++;
        }
    }