Example #1
0
        void load_dict3()
        {
            string       path = @"Assets/hvchubothu.js";
            myTextReader rd   = new myTextReader();

            rd.Reading += Rd_OnReading;
            rd.Open(getUri(path));
            int startTC = Environment.TickCount;
            var dict    = new myDictBT(0);
            var line    = rd.ReadLine(); //read header

            line = rd.ReadLine();
            string[] buff = { line, "" };
            line    = rd.ReadLine();
            buff[1] = line;
            uint iCur  = 1;
            int  count = 2;

            for (; line != null;)
            {
                dict.add(buff[iCur ^ 1]);
                iCur       = iCur ^ 1;
                line       = rd.ReadLine();
                buff[iCur] = line;
                count++;
            }
            //Console.WriteLine("hvchubothu.js {0} {1}", dict.count, Environment.TickCount - startTC);
            rd.Close();
            rd.Dispose();
            hvbt = dict;
        }
Example #2
0
        void load_dict1()
        {
            string       path = @"Assets/hv_org.csv";
            myTextReader rd   = new myTextReader();

            rd.Reading += Rd_OnReading;
            rd.Open(getUri(path));
            myDictHVORG dict1 = new myDictHVORG(0);
            var         line  = rd.ReadLine(); //read header

            for (line = rd.ReadLine(); line != null; line = rd.ReadLine())
            {
                dict1.add(line);
            }
            //Debug.WriteLine("hv_org.csv {0} {1}", dict1.count, Environment.TickCount - startTC);
            rd.Close();
            hv_org = dict1;
            rd.Dispose();
        }
Example #3
0
        void load_dict(myDictBase dict, myTextReader rd, string path)
        {
            //var fs = await StorageFile.GetFileFromPathAsync(path);
            //var lines = await FileIO.ReadLinesAsync(fs);
            Task t = Task.Run(() => rd.Open(getUri(path)));

            int      startTC = Environment.TickCount;
            wrkState s       = wrkState.init;
            string   line;

            for (int i = 0; s != wrkState.end;)
            {
                Debug.WriteLine("i {0} s {1}", i, s.ToString());
                switch (s)
                {
                case wrkState.init:
                    if (rd.lineCount > 0)
                    {
                        s = wrkState.begin;
                    }
                    else if (t.Status == TaskStatus.RanToCompletion)
                    {
                        s = wrkState.end;
                    }
                    break;

                case wrkState.begin:
                    line = rd.ReadLine();       //ignore first line
                    i++;
                    if (i < rd.lineCount)
                    {
                        s = wrkState.parsing;
                    }
                    else
                    {
                        s = wrkState.wait4read;
                    }
                    break;

                case wrkState.wait4read:
                    if (i < rd.lineCount)
                    {
                        s = wrkState.parsing;
                    }
                    else if (t.Status == TaskStatus.RanToCompletion)
                    {
                        s = wrkState.end;
                    }
                    Task.Delay(1);
                    break;

                case wrkState.parsing:
                    var c = rd.lineCount;
                    for (; i < c;)
                    {
                        line = rd.ReadLine();
                        dict.add(line);
                        i++;
                    }
                    if (i == rd.lineCount)
                    {
                        s = wrkState.wait4read;
                    }
                    break;
                }
            }
            rd.Close();
            rd.Dispose();
        }