Exemplo n.º 1
0
        public static CountedList <T> ToCountedList <T>(this IEnumerable <T> source)
        {
            var list = new CountedList <T>();

            foreach (var item in source)
            {
                list.Add(item, 1);
            }

            return(list);
        }
        public CandidateComparerCollection <T> Append(T value)
        {
            if (CandidateCount != value.CandidateCount)
            {
                throw new ArgumentException("Candidate Counts must be equal.");
            }

            var second = new CountedList <T>();

            second.Add(value);
            return(new CandidateComparerCollection <T>(CandidateCount, CountedList <T> .Concat(Comparers, second)));
        }
Exemplo n.º 3
0
        public void BasicTest()
        {
            var cc             = 6 * DefaultCount + 3;
            var exepectedCount = 7;

            var count = 0;

            _countedList.MaxIntemsReached = (l, ic) =>
            {
                Assert.IsTrue(ic <= DefaultCount * 4);
                ++count;
            };

            for (int i = 0; i < cc; i++)
            {
                _countedList.Add("Item");
            }

            _countedList.Dispose();
            Assert.AreEqual(exepectedCount, count);
        }