コード例 #1
0
ファイル: RefListTest.cs プロジェクト: ststeiger/ngit-core
        private RefList <Ref> ToList(params Ref[] refs)
        {
            RefListBuilder <Ref> b = new RefListBuilder <Ref>(refs.Length);

            b.AddAll(refs, 0, refs.Length);
            return(b.ToRefList());
        }
コード例 #2
0
        /// <summary>
        /// Obtain a builder initialized with the first
        /// <code>n</code>
        /// elements.
        /// <p>
        /// Copies the first
        /// <code>n</code>
        /// elements from this list into a new builder,
        /// which can be used by the caller to add additional elements.
        /// </summary>
        /// <param name="n">the number of elements to copy.</param>
        /// <returns>
        /// a new builder with the first
        /// <code>n</code>
        /// elements already added.
        /// </returns>
        public RefListBuilder <T> Copy(int n)
        {
            RefListBuilder <T> r = new RefListBuilder <T>(Math.Max(16, n));

            r.AddAll(list, 0, n);
            return(r);
        }
コード例 #3
0
ファイル: RefListTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestBuilder_AddAll()
        {
            RefListBuilder <Ref> builder = new RefListBuilder <Ref>(1);

            Ref[] src = new Ref[] { REF_A, REF_B, REF_c, REF_A };
            builder.AddAll(src, 1, 2);
            RefList <Ref> list = builder.ToRefList();

            NUnit.Framework.Assert.AreEqual(2, list.Size());
            NUnit.Framework.Assert.AreSame(REF_B, list.Get(0));
            NUnit.Framework.Assert.AreSame(REF_c, list.Get(1));
        }