Exemple #1
0
        public void UnitRdx_TryGetValueIndex()
        {
            var rd = new RankedDictionary <int, int>();

            rd.Capacity = 5;
            for (int ii = 0; ii < 500; ii += 2)
            {
                rd.Add(ii, ii + 1000);
            }

            for (int ii = 0; ii < 500; ii += 2)
            {
                bool isOk = rd.TryGetValueAndIndex(ii, out int v1, out int i1);

                Assert.IsTrue(isOk);
                Assert.AreEqual(ii / 2, i1);
                Assert.AreEqual(ii + 1000, v1);
            }

            bool isOkNot = rd.TryGetValueAndIndex(111, out int v2, out int i2);

            Assert.IsFalse(isOkNot);
        }