Exemplo n.º 1
0
        bool FindTeg(string type)
        {
            int left      = 0;
            int right     = _text.Length;
            int checkTegs = 0;

            while ((left < _text.Length) && (right > 1))
            {
                int begin = _text.IndexOf("/" + type, left);
                int end   = _text.LastIndexOf("/!" + type, right);
                if (begin == -1 && end == -1)
                {
                    left  = _text.Length;
                    right = 0;
                }
                else
                {
                    if (begin != -1)
                    {
                        Tegs.Add(new Tegs(begin, "/" + type));
                        left = begin + 3;
                        checkTegs++;
                    }
                    else
                    {
                        left++;
                    }
                    if (end != -1)
                    {
                        Tegs.Add(new Tegs(end, "/!" + type));
                        right = end - 1;
                        checkTegs--;
                    }
                    else
                    {
                        end--;
                    }
                }
            }
            if (checkTegs != 0)
            {
                return(false);
            }
            return(true);
        }
        public static void SortList(ref List <Tegs> list)
        {
            int n = list.Count;
            int d = n / 2;

            while (d > 0)
            {
                bool Ok = true;
                while (Ok)
                {
                    Ok = false;
                    for (int i = 0; i < n - d; i++)
                    {
                        if (list[i].Position > list[i + d].Position)
                        {
                            Tegs t = list[i]; list[i] = list[i + d];
                            list[i + d] = t;
                            Ok          = true;
                        }
                    }
                }
                d = d / 2;
            }
        }