Пример #1
0
 public void Reverse()
 {
     foreach (var v in List)
     {
         v.Data = new HyperEquation(v.Data[0], v.Data[2], v.Data[1], v.Data.FromEquations);
     }
     List = List.Reverse().Link;
 }
Пример #2
0
        private static MonoLinker <KeyValuePair <char, string> > SplitSome(string s, string separats, string conducts, string dflt, bool rvrs = false)
        {
            if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(separats) ||
                string.IsNullOrEmpty(conducts) || separats.Length < 2)
            {
                return(null);
            }
            char[] sprt = separats.ToCharArray(), cndc = conducts.ToCharArray();
            char   flag = (char)(sprt[0] ^ sprt[1]), chng = sprt[1];
            MonoLinker <KeyValuePair <char, string> > ms = null;
            int i = 0, len = s.Length, br = 0;

            do
            {
                var sign = sprt[0];
                while (i < len && Array.Exists(sprt, s[i].Equals))
                {
                    if (s[i++] == chng)
                    {
                        sign ^= flag;
                    }
                }
                var start = i;
                while (i < len && (br > 0 || !Array.Exists(sprt, s[i].Equals)))
                {
                    if (s[i] == '(')
                    {
                        ++br;
                    }
                    if (s[i] == ')')
                    {
                        --br;
                    }
                    if (br > 0 || !Array.Exists(cndc, s[i].Equals))
                    {
                        ++i;
                    }
                    else
                    {
                        while (++i < len && Array.Exists(sprt, s[i].Equals))
                        {
                        }
                    }
                }
                if (br < 0)
                {
                    i = len;
                }
                ms = new MonoLinker <KeyValuePair <char, string> >(new KeyValuePair <char, string>(sign, i == start ? dflt : s.Substring(start, i - start)), ms);
            } while(i < len);
            return(rvrs ? ms : ms.Reverse());
        }