Exemple #1
0
        private static bool BufferEqualToString(StringBuffer a, string b)
        {
            if (a is null)
            {
                return(b is null);
            }

            if (a.Count != b?.Length)
            {
                return(false);
            }

            Enumerator     t = a.GetEnumerator();
            CharEnumerator o = b.GetEnumerator();

            bool result = true;

            while (o.MoveNext() && t.MoveNext())
            {
                if (t.Current != o.Current)
                {
                    result = false;
                    break;
                }
            }

            t.Dispose();
            //o.Dispose();

            return(result);
        }
Exemple #2
0
        public bool Equals(StringBuffer other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (Count != other.Count)
            {
                return(false);
            }

            Enumerator t = this.GetEnumerator();
            Enumerator o = other.GetEnumerator();

            bool result = true;

            while (o.MoveNext() && t.MoveNext())
            {
                if (t.Current != o.Current)
                {
                    result = false;
                    break;
                }
            }

            t.Dispose();
            o.Dispose();

            return(result);
        }