Beispiel #1
0
        public void WhenNoNodesAdded_ItRetrurnsNull_AsMaximum()
        {
            var rbt = new Rbt <int, int>(Comparer <int> .Create((a, b) => a.CompareTo(b)));

            var max = rbt.Max();

            Assert.IsNull(max);
        }
Beispiel #2
0
        public void WhenTwoNodesAdded_ItRetrurnsMaximum()
        {
            var rbt = new Rbt <int, int>(Comparer <int> .Create((a, b) => a.CompareTo(b)));

            rbt.Insert(1, 1);
            rbt.Insert(10, 10);

            var max = rbt.Max();

            Assert.AreEqual(10, max.Key);
            Assert.AreEqual(10, max.Value);
        }
Beispiel #3
0
        public void WhenSingleNodeAdded_ItIsMaximum()
        {
            const int key = 1;
            const int val = 2;
            var       rbt = new Rbt <int, int>(Comparer <int> .Create((a, b) => a.CompareTo(b)));

            rbt.Insert(key, val);

            var max = rbt.Max();

            Assert.AreEqual(key, max.Key);
            Assert.AreEqual(val, max.Value);
        }