周星驰:
活活,把以前写的一个C++的容器移植到C#下了,保持了STL的风格。
[阅读: 729] 2006-09-13 08:49:34
using System;
using System.Collections.Generic;
using System.Text;
using std;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
tree< string > theTree = new tree< string >();
theTree.insert( "root" );
tree< string >.iterator it = theTree.insert( "|__A" );
theTree.insert( " |__A-1", it );
theTree.insert( " |__A-2", it );
theTree.insert( " |__A-3", it );
it = theTree.insert( "|__B", it );
tree< string >.iterator itPrev = theTree.insert( " |__B-1", it );
theTree.insert( " |__B-3", it );
theTree.insert( " |__B-2", it, itPrev );
for ( tree< string >.iterator i = theTree.begin; i != theTree.end; ++ i )
{
System.Console.Write( i.data );
System.Console.WriteLine();
}
System.Console.WriteLine();
for ( tree< string >.reverse_iterator ri = theTree.rbegin; ri != theTree.rend; ++ ri )
{
System.Console.Write( ri.data );
System.Console.WriteLine();
}
}
}
}