当前位置: 首页>>代码示例>>C#>>正文


C# BlockList.AddItem方法代码示例

本文整理汇总了C#中BlockList.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# BlockList.AddItem方法的具体用法?C# BlockList.AddItem怎么用?C# BlockList.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlockList的用法示例。


在下文中一共展示了BlockList.AddItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAddRejectsBadIndexes

 public virtual void TestAddRejectsBadIndexes()
 {
     BlockList<int> list = new BlockList<int>(4);
     list.AddItem(Sharpen.Extensions.ValueOf(41));
     try
     {
         list.Add(-1, Sharpen.Extensions.ValueOf(42));
     }
     catch (IndexOutOfRangeException badIndex)
     {
         NUnit.Framework.Assert.AreEqual((-1).ToString(), badIndex.Message);
     }
     try
     {
         list.Add(4, Sharpen.Extensions.ValueOf(42));
     }
     catch (IndexOutOfRangeException badIndex)
     {
         NUnit.Framework.Assert.AreEqual(4.ToString(), badIndex.Message);
     }
 }
开发者ID:ashmind,项目名称:ngit,代码行数:21,代码来源:BlockListTest.cs

示例2: TestGet

		public virtual void TestGet()
		{
			BlockList<string> list = new BlockList<string>(4);
			string b;
			try
			{
				b = list[-1];
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual((-1).ToString(), badIndex.Message);
			}
			try
			{
				b = list[0];
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(0.ToString(), badIndex.Message);
			}
			try
			{
				b = list[4];
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(4.ToString(), badIndex.Message);
			}
			string fooStr = "foo";
			string barStr = "bar";
			string foobarStr = "foobar";
			list.AddItem(fooStr);
			list.AddItem(barStr);
			list.AddItem(foobarStr);
			NUnit.Framework.Assert.AreSame(fooStr, list[0]);
			NUnit.Framework.Assert.AreSame(barStr, list[1]);
			NUnit.Framework.Assert.AreSame(foobarStr, list[2]);
			try
			{
				b = list[3];
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(3.ToString(), badIndex.Message);
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:46,代码来源:BlockListTest.cs

示例3: TestFastIterator

		public virtual void TestFastIterator()
		{
			BlockList<int> list = new BlockList<int>(4);
			int cnt = BlockList<int>.BLOCK_SIZE * 3;
			for (int i = 0; i < cnt; i++)
			{
				list.AddItem(Sharpen.Extensions.ValueOf(42 + i));
			}
			NUnit.Framework.Assert.AreEqual(cnt, list.Count);
			Iterator<int> itr = list.Iterator();
			for (int i_1 = 0; i_1 < cnt; i_1++)
			{
				NUnit.Framework.Assert.IsTrue(itr.HasNext());
				NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_1), itr.Next());
			}
			NUnit.Framework.Assert.IsFalse(itr.HasNext());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:17,代码来源:BlockListTest.cs

示例4: TestAddAllFromOtherList

		public virtual void TestAddAllFromOtherList()
		{
			BlockList<int> src = new BlockList<int>(4);
			int cnt = BlockList<int>.BLOCK_SIZE * 2;
			for (int i = 0; i < cnt; i++)
			{
				src.AddItem(Sharpen.Extensions.ValueOf(42 + i));
			}
			src.AddItem(Sharpen.Extensions.ValueOf(1));
			BlockList<int> dst = new BlockList<int>(4);
			dst.AddItem(Sharpen.Extensions.ValueOf(255));
			dst.AddAll(src);
			NUnit.Framework.Assert.AreEqual(cnt + 2, dst.Count);
			for (int i_1 = 0; i_1 < cnt; i_1++)
			{
				NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_1), dst[i_1 + 1
					]);
			}
			NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(1), dst[dst.Count - 1]
				);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:21,代码来源:BlockListTest.cs

示例5: TestAddRemoveAdd

		public virtual void TestAddRemoveAdd()
		{
			BlockList<int> list = new BlockList<int>();
			for (int i = 0; i < BlockList<int>.BLOCK_SIZE + 1; i++)
			{
				list.AddItem(Sharpen.Extensions.ValueOf(i));
			}
			NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(BlockList<int>.BLOCK_SIZE), 
				list.Remove(list.Count - 1));
			NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(BlockList<int>.BLOCK_SIZE -
				 1), list.Remove(list.Count - 1));
			NUnit.Framework.Assert.IsTrue(list.AddItem(Sharpen.Extensions.ValueOf(1)));
			NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(1), list[list.Count - 
				1]);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:15,代码来源:BlockListTest.cs

示例6: TestRemoveSlowPath

		public virtual void TestRemoveSlowPath()
		{
			BlockList<string> list = new BlockList<string>(4);
			string fooStr = "foo";
			string barStr = "bar";
			string foobarStr = "foobar";
			list.AddItem(fooStr);
			list.AddItem(barStr);
			list.AddItem(foobarStr);
			NUnit.Framework.Assert.AreSame(barStr, list.Remove(1));
			NUnit.Framework.Assert.AreEqual(2, list.Count);
			NUnit.Framework.Assert.AreSame(fooStr, list[0]);
			NUnit.Framework.Assert.AreSame(foobarStr, list[1]);
			NUnit.Framework.Assert.AreSame(fooStr, list.Remove(0));
			NUnit.Framework.Assert.AreEqual(1, list.Count);
			NUnit.Framework.Assert.AreSame(foobarStr, list[0]);
			NUnit.Framework.Assert.AreSame(foobarStr, list.Remove(0));
			NUnit.Framework.Assert.AreEqual(0, list.Count);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:19,代码来源:BlockListTest.cs

示例7: TestAddSlowPath

		public virtual void TestAddSlowPath()
		{
			BlockList<string> list = new BlockList<string>(4);
			string fooStr = "foo";
			string barStr = "bar";
			string foobarStr = "foobar";
			string firstStr = "first";
			string zeroStr = "zero";
			list.AddItem(fooStr);
			list.AddItem(barStr);
			list.AddItem(foobarStr);
			NUnit.Framework.Assert.AreEqual(3, list.Count);
			list.Add(1, firstStr);
			NUnit.Framework.Assert.AreEqual(4, list.Count);
			NUnit.Framework.Assert.AreSame(fooStr, list[0]);
			NUnit.Framework.Assert.AreSame(firstStr, list[1]);
			NUnit.Framework.Assert.AreSame(barStr, list[2]);
			NUnit.Framework.Assert.AreSame(foobarStr, list[3]);
			list.Add(0, zeroStr);
			NUnit.Framework.Assert.AreEqual(5, list.Count);
			NUnit.Framework.Assert.AreSame(zeroStr, list[0]);
			NUnit.Framework.Assert.AreSame(fooStr, list[1]);
			NUnit.Framework.Assert.AreSame(firstStr, list[2]);
			NUnit.Framework.Assert.AreSame(barStr, list[3]);
			NUnit.Framework.Assert.AreSame(foobarStr, list[4]);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:26,代码来源:BlockListTest.cs

示例8: TestAddToEnd

		public virtual void TestAddToEnd()
		{
			BlockList<int> list = new BlockList<int>(4);
			int cnt = BlockList<int>.BLOCK_SIZE * 3;
			for (int i = 0; i < cnt; i++)
			{
				list.AddItem(Sharpen.Extensions.ValueOf(42 + i));
			}
			NUnit.Framework.Assert.AreEqual(cnt, list.Count);
			for (int i_1 = 0; i_1 < cnt; i_1++)
			{
				NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_1), list[i_1]);
			}
			list.Clear();
			NUnit.Framework.Assert.AreEqual(0, list.Count);
			NUnit.Framework.Assert.IsTrue(list.IsEmpty());
			for (int i_2 = 0; i_2 < cnt; i_2++)
			{
				list.Add(i_2, Sharpen.Extensions.ValueOf(42 + i_2));
			}
			NUnit.Framework.Assert.AreEqual(cnt, list.Count);
			for (int i_3 = 0; i_3 < cnt; i_3++)
			{
				NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_3), list[i_3]);
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:26,代码来源:BlockListTest.cs


注:本文中的BlockList.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。