コード例 #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);
            }

            var t = a.GetEnumerator();
            var 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);
        }
コード例 #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);
            }

            var t = this.GetEnumerator();
            var 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);
        }