没有登录
中国开发网: 论坛: 程序员情感CBD: 贴子 398467
周星驰
活活,把以前写的一个C++的容器移植到C#下了,保持了STL的风格。
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();
}
}
}
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录