Beispiel #1
0
 public void TransferToEnd(StringBuffer valuesToTransfer)
 {
     while (!valuesToTransfer.IsEmpty)
     {
         PushToEnd(valuesToTransfer.PopFromStart());
     }
 }
Beispiel #2
0
        public void Replace(char[] original, char[] replacement)
        {
            if (IsEmpty)
            {
                return;
            }


            var finalValue = new StringBuffer(this.Count);
            var limbo      = new StringBuffer(this.Count);

            int cIndex = 0;

            int oCount = original.Length;

            do
            {
                if (this.PeekStart() == original[cIndex])
                {
                    limbo.PushToEnd(this.PopFromStart());
                    cIndex++;

                    if (cIndex == oCount) // Full match
                    {
                        foreach (char c in replacement)
                        {
                            finalValue.PushToEnd(c);
                        }

                        limbo.Clear();
                        cIndex = 0;
                    }
                }
                else
                {
                    cIndex = 0;

                    while (!limbo.IsEmpty)
                    {
                        finalValue.PushToEnd(limbo.PopFromStart());
                    }

                    finalValue.PushToEnd(this.PopFromStart());
                }
            } while (!this.IsEmpty);

            do
            {
                this.PushToEnd(finalValue.PopFromStart());
            } while (!finalValue.IsEmpty);
        }