count() public method

Gets the number of items in the collection.
public count ( ) : int
return int
        public void PopOnSmallReturnsOneLess()
        {
            Range r = new Range(2, 20);
            PersistentVector v = PersistentVector.create(r);
            IPersistentStack s = v.pop();

            Expect(v.count(),EqualTo(r.count()));
            Expect(s.count(),EqualTo(v.count()-1));
        }
        public void PopOnBigWorks()
        {
            Range r = new Range(0, 100000);
            PersistentVector v = PersistentVector.create(r);
            IPersistentStack s = v;
            for (int i = 16; i < 100000; i++)
                s = s.pop();

            Expect(v.count(), EqualTo(r.count()));
            Expect(s.count(), EqualTo(16));
        }
        public void CreateOnISeqReturnsCorrectCount()
        {
            Range r = new Range(2,5);
            PersistentVector v = PersistentVector.create(r);

            Expect(v.count(),EqualTo(r.count()));
        }
        public void CreateOnISeqWithManyManyItemsWorks()
        {
            // Want to bust out of the first tail, so need to insert more than 32 elements.
            // Let's get out of the second level, too.

            Range r = new Range(2, 100000);
            PersistentVector v = PersistentVector.create(r);

            Expect(v.count(), EqualTo(r.count()));
            for (int i = 0; i < v.count(); ++i)
                Expect(v.nth(i), EqualTo(i + 2));
        }
Beispiel #5
0
        public void Range_has_correct_count()
        {
            Range r = new Range(2, 20);

            Expect(r.count(), EqualTo(18));
        }