Insert() public method

public Insert ( int index, object value ) : void
index int
value object
return void
コード例 #1
0
		public void Insert2()
		{
			LinkedList list = new LinkedList();
			
			list.Add( "1" );
			list.Add( "2" );
			list.Add( "3" );
			list.Insert(2, "x");

			Assert.AreEqual( 4, list.Count );
			
			String[] array = (String[]) list.ToArray( typeof(String) );
			Assert.AreEqual( "1,2,x,3", String.Join(",", array) );
		}
コード例 #2
0
		public void Insert2bis()
		{
			LinkedList list = new LinkedList();
			
			list.Add( "0" );
			list.Add( "1" );
			list.Add( "2" );
			list.Add( "3" );
			list.Add( "4" );
			list.Add( "5" );
			list.Insert(2, "x");

			Assert.AreEqual( 7, list.Count );
			
			String[] array = (String[]) list.ToArray( typeof(String) );
			Assert.AreEqual( "0,1,x,2,3,4,5", String.Join(",", array) );
		}
コード例 #3
0
		public void Insert1_AfterReplacingHeadWithAddFirst()
		{
			LinkedList list = new LinkedList();

			list.Add("2");
			list.AddFirst("1");
			list.Insert(1, "x");

			Assert.AreEqual(3, list.Count);

			String[] array = (String[])list.ToArray(typeof(String));
			Assert.AreEqual("1,x,2", String.Join(",", array));
		}