public override bool Contains(string s, out PeopleIKnowMetadata metadata)
        {
            this.tracer.TraceDebug((long)this.traceId, "BinarySearchableEmailAddressCollection.Contains: entering");
            metadata = null;
            if (this.Data == null)
            {
                this.tracer.TraceDebug((long)this.traceId, "this.Data is null; returning false");
                return(false);
            }
            if (string.IsNullOrEmpty(s))
            {
                this.tracer.TraceDebug((long)this.traceId, "s is null or empty; returning false");
                return(false);
            }
            byte[] array  = this.NormalizeAndConvertToUTF8(s);
            byte[] array2 = new byte[array.Length + 1];
            Array.Copy(array, 0, array2, 0, array.Length);
            int i   = 0;
            int num = this.Count - 1;

            while (i <= num)
            {
                int num2 = (i + num) / 2;
                int num3 = (int)this.ReadUShortFromDataArray(3 + num2 * 2);
                int num4 = BinarySearchableEmailAddressCollection.byteArrayComparer.CompareNullTerminatedByteStrings(this.Data, num3, array2, 0);
                if (num4 < 0)
                {
                    i = num2 + 1;
                }
                else
                {
                    if (num4 <= 0)
                    {
                        this.tracer.TraceDebug((long)this.traceId, "BinarySearchableEmailAddressCollection.Contains: search string was found; returning true");
                        while (this.Data[num3++] != 0)
                        {
                        }
                        byte[] array3 = new byte[this.MetadataSerializer.SizeOfMetadata];
                        Array.Copy(this.Data, num3, array3, 0, this.MetadataSerializer.SizeOfMetadata);
                        metadata = this.MetadataSerializer.Deserialize(array3);
                        return(true);
                    }
                    num = num2 - 1;
                }
            }
            this.tracer.TraceDebug((long)this.traceId, "BinarySearchableEmailAddressCollection.Contains: search string was not found; returning false");
            return(false);
        }
Exemplo n.º 2
0
 public abstract bool Contains(string s, out PeopleIKnowMetadata metadata);