0001 #include <cstdio> //采用C风格精细控制输出格式 0002 #include "huffman/huffChar.h" //Huffman超字符 0003 #include "BinTree/BinTree.h" //二叉树 0004 #include "Huffman/HuffTree.h" //Huffman树 0005 #include "BST/BST.h" //二叉搜索树 0006 #include "AVL/AVL.h" //AVL树 0007 #include "Splay/Splay.h" //伸展树 0008 #include "redBlack/RedBlack.h" //红黑树 0009 #include "BTree/BTree.h" //二叉搜索树 0010 #include "Entry/Entry.h" //词条 0011 #include "Skiplist/Quadlist.h" //四叉表 0012 #include "Skiplist/Skiplist.h" //跳转表 0013 #include "Hashtable/Hashtable.h" //散列表 0014 #include "PQ_List/PQ_List.h" //基于列表实现的优先级队列 0015 #include "PQ_ComplHeap/PQ_ComplHeap.h" //基于完全堆实现的优先级队列 0016 #include "PQ_LeftHeap/PQ_LeftHeap.h" //基于左式堆实现的优先级队列 0017 #include "graph/Graph.h" //图 0018 #include "graphMatrix/GraphMatrix.h" //基于邻接矩阵实现的图 0019 0020 /****************************************************************************************** 0021 * 数据元素、数据结构通用输出接口 0022 ******************************************************************************************/ 0023 template <typename T> static void print ( T* x ) { x ? print ( *x ) : printf ( " <NULL>" ); } 0024 template <typename T> static void print ( T& x ) { UniPrint::p ( x ); } 0025 template <typename T> static void print ( const T& x ) { UniPrint::p ( x ); } //for Stack 0026 static void print ( char* x ) { printf ( " %s", x ? x : "<NULL>" ); } //字符串特别处理 0027 static void print ( const char* x ) { printf ( " %s", x ? x : "<NULL>" ); } //字符串特别处理 0028 0029 class UniPrint { 0030 public: 0031 static void p ( int ); 0032 static void p ( size_t ); 0033 static void p ( float ); 0034 static void p ( double ); 0035 static void p ( char ); 0036 static void p ( HuffChar& ); //Huffman(超)字符 0037 static void p ( VStatus ); //图顶点的状态 0038 static void p ( EType ); //图边的类型 0039 0040 template <typename K, typename V> static void p( Entry<K, V>& ); // Entry 0041 template <typename T> static void p( BinNode<T>& ); // BinTree节点 0042 template <typename T> static void p( BinTree<T>& ); //二叉树 0043 template <typename T> static void p( BTree<T>& ); // B-树 0044 template <typename T> static void p( BST<T>& ); // BST 0045 template <typename T> static void p( AVL<T>& ); // AVL 0046 template <typename T> static void p( RedBlack<T>& ); // RedBlack 0047 template <typename T> static void p( Splay<T>& ); // Splay 0048 template <typename T> static void p( Quadlist<T>& ); // Quadlist 0049 template <typename K, typename V> static void p( Skiplist<K, V>& ); // Skiplist 0050 template <typename K, typename V> static void p( Hashtable<K, V>& ); // Hashtable 0051 template <typename T> static void p( PQ_List<T>& ); // PQ_List 0052 template <typename T> static void p( PQ_ComplHeap<T>& ); // PQ_ComplHeap 0053 template <typename T> static void p( PQ_LeftHeap<T>& ); // PQ_LeftHeap 0054 template <typename Tv, typename Te> static void p( GraphMatrix<Tv, Te>& ); // Graph 0055 template <typename T> static void p( T& ); //向量、列表等支持traverse()遍历操作的线性结构 0056 template <typename T> static void p( T* s ) //所有指针 0057 { s ? p( *s ) : print( "<NULL>" ); } //统一转为引用 0058 }; //UniPrint