예제 #1
0
        /// <summary>
        /// Compares this term link with another.
        /// </summary>
        public bool Equals
        (
            [NotNull] TermLink other
        )
        {
            Sure.NotNull(other, "other");

            return(Mfn == other.Mfn &&
                   Tag == other.Tag &&
                   Occurrence == other.Occurrence &&
                   Index == other.Index);
        }
예제 #2
0
        public static TermLink[] FromPostings
        (
            [NotNull][ItemNotNull] TermPosting[] postings
        )
        {
            Sure.NotNull(postings, "postings");

            TermLink[] result = new TermLink[postings.Length];
            for (int i = 0; i < postings.Length; i++)
            {
                result[i] = FromPosting(postings[i]);
            }

            return(result);
        }
예제 #3
0
        public static TermLink Read
        (
            [NotNull] Stream stream
        )
        {
            Sure.NotNull(stream, "stream");

            TermLink result = new TermLink
            {
                Mfn        = stream.ReadInt32Network(),
                Tag        = stream.ReadInt32Network(),
                Occurrence = stream.ReadInt32Network(),
                Index      = stream.ReadInt32Network()
            };

            return(result);
        }
예제 #4
0
        public static TermLink FromPosting
        (
            [NotNull] TermPosting posting
        )
        {
            Sure.NotNull(posting, "posting");

            TermLink result = new TermLink
            {
                Mfn        = posting.Mfn,
                Tag        = posting.Tag,
                Occurrence = posting.Occurrence,
                Index      = posting.Count
            };

            return(result);
        }
예제 #5
0
        /// <summary>
        /// Convert array of MFN into array of <see cref="TermLink"/>s.
        /// </summary>
        /// <returns></returns>
        public static TermLink[] FromMfn
        (
            [NotNull] int[] array
        )
        {
            Sure.NotNull(array, "array");

            TermLink[] result = new TermLink[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = new TermLink
                {
                    Mfn = array[i]
                };
            }

            return(result);
        }
예제 #6
0
        /// <inheritdoc cref="object.Equals(object)"/>
        public override bool Equals
        (
            object obj
        )
        {
            if (ReferenceEquals(null, obj))
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            TermLink termLink = obj as TermLink;

            return(!ReferenceEquals(termLink, null) &&
                   Equals(termLink));
        }