Beispiel #1
0
        /// <summary>
        /// Serves as a hash function to combine the JID and node together.
        /// GetHashCode() is suitable for use in hashing algorithms and
        /// data structures like a hash table.
        /// </summary>
        /// <returns>The hash code of this JIDNode.</returns>
        public override int GetHashCode()
        {
            int code = 0;

            if (m_jid != null)
            {
                code = m_jid.GetHashCode();
            }
            if (m_node != null)
            {
                code ^= m_node.GetHashCode();
            }
            return(code);
        }
Beispiel #2
0
        [Test] public void Test_Compare_Equal()
        {
            JID j = new JID("foo@bar/baz");

            Assert.AreEqual(0, j.CompareTo(j));
            Assert.AreEqual(0, j.CompareTo(new JID("foo@bar/baz")));
            j = new JID("foo@bar");
            Assert.AreEqual(0, j.CompareTo(j));
            Assert.AreEqual(0, j.CompareTo(new JID("foo@bar")));
            Assert.IsTrue(j == new JID("foo@bar"));
            Assert.IsTrue(j == new JID("foo@BAR"));
            Assert.IsTrue(j == new JID("FOO@BAR"));
            Assert.IsTrue(j == new JID("FOO@bar"));
            Assert.AreEqual(new JID("FOO@bar").GetHashCode(), j.GetHashCode());
            j = new JID("bar");
            Assert.AreEqual(0, j.CompareTo(j));
            Assert.AreEqual(0, j.CompareTo(new JID("bar")));
            j = new JID("foo/bar");
            Assert.AreEqual(0, j.CompareTo(j));
            Assert.AreEqual(0, j.CompareTo(new JID("foo/bar")));
            Assert.AreEqual(true, j >= new JID("foo/bar"));
            Assert.AreEqual(true, j <= new JID("foo/bar"));
        }
 public override int GetHashCode()
 {
     return(JID.GetHashCode());
 }