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