public static Boolean SelfTest()
{
LinkedList temp_store = new LinkedList();
temp_store.Add( "elem1" );
if ( ! temp_store.Remove( "elem1" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_001" );
}
if ( temp_store.Contains( "elem1" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_002" );
}
if ( temp_store.m_Count != 0 )
{
throw new Exception( "LinkedList implementation incorrect, Err_002a" );
}
temp_store.Add( "a1" );
temp_store.Add( "a2" );
if ( ! temp_store.Remove( "a2" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_002b" );
}
if ( ! temp_store.Remove( "a1" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_002c" );
}
temp_store.Add( "elem1" );
temp_store.Add( "elem2" );
temp_store.Add( "elem3" );
if ( ! temp_store.Remove( "elem2" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_003" );
}
if ( temp_store.Contains( "elem2" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_004" );
}
if ( ! temp_store.Remove( "elem3" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_005" );
}
if ( temp_store.Contains( "elem3" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_006" );
}
if ( temp_store.m_Count != 1 )
{
throw new Exception( "LinkedList implementation incorrect, Err_007" );
}
temp_store = new LinkedList();
temp_store.Add( "a" );
temp_store.Remove( "a" );
temp_store.Add( "b" );
temp_store.Add( "d" );
temp_store.Remove( "b" );
if ( temp_store.Contains( "b" ) )
{
throw new Exception( "LinkedList implementation incorrect, Err_008" );
}
return true;
}
public void Add(Object obj)