0001 /****************************************************************************************** 0002 * Quadlist 0003 ******************************************************************************************/ 0004 0005 template <typename T> //元素类型 0006 void UniPrint::p ( Quadlist<T>& q ) { //引用 0007 printf ( "%s[%d]*%03d: ", typeid ( q ).name(), &q, q.size() ); //基本信息 0008 if ( q.size() <= 0 ) { printf ( "\n" ); return; } 0009 QuadlistNode<T>* curr = q.first()->pred; //当前层之header 0010 QuadlistNode<T>* base = q.first(); //当前节点所在 0011 while ( base->below ) base = base->below; //塔底 0012 while ( base->pred ) base = base->pred; //底层之header 0013 for ( int i = 0; i < q.size(); i++ ) { //对于当前层的每一节点 0014 curr = curr->succ; //curr 0015 QuadlistNode<T>* proj = curr; //找到与curr对应的 0016 while ( proj->below ) proj = proj->below; //塔底节点(投影) 0017 while ( ( base = base->succ ) != proj ) //移动base直到proj,期间不断 0018 printf ( "------------" ); //延长水平联接线 0019 print ( curr->entry ); //最后,输出当前层的当前词条 0020 } 0021 printf ( "\n" ); 0022 }