Пример #1
0
        protected override CStyleString OnExecute(CStyleString arg)
        {
            var lastIndex = 0;

            While(() => arg[lastIndex] != CStyleString.NullCharacter, () => lastIndex++);
            lastIndex--;
            var firstIndex = 0;

            While(() => firstIndex < lastIndex, () =>
            {
                var tmp         = arg[firstIndex];
                arg[firstIndex] = arg[lastIndex];
                arg[lastIndex]  = tmp;
                firstIndex++;
                lastIndex--;
            });

            return(arg);
        }
Пример #2
0
        protected override CStyleString OnExecute(CStyleString arg)
        {
            if (arg == null)
            {
                throw new ArgumentNullException();
            }

            if (arg[0] == CStyleString.NullCharacter || arg[1] == CStyleString.NullCharacter)
            {
                return(arg);
            }

            var tail = 1;
            int i    = 1;


            while (arg[i] != CStyleString.NullCharacter)
            {
                IncrementIteration();
                int j;
                for (j = 0; j < tail; ++j)
                {
                    IncrementIteration();
                    if (arg[i] == arg[j])
                    {
                        break;
                    }
                }

                if (j == tail)
                {
                    arg[tail] = arg[i];
                    tail++;
                }
                i++;
            }

            arg[tail] = CStyleString.NullCharacter;

            return(arg);
        }