-
Notifications
You must be signed in to change notification settings - Fork 28
/
print.h
86 lines (73 loc) · 1.53 KB
/
print.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef print_h
#define print_h
#include <iostream>
#include <vector>
#include "./Chap06/Heap.h"
#include "./Chap10/List.h"
#include "./Chap10/Queue.h"
#include "./Chap10/Stack.h"
using namespace std;
void print(int val) {
cout << val << " ";
}
void print(string str) {
for (int i = 0; i < str.length() + 2; i++)
cout << "-";
cout << "\n " << str << " \n";
for (int i = 0; i < str.length() + 2; i++)
cout << "-";
cout << endl;
}
template <typename T>
void print(vector<T>& vec) {
for (int i = 0; i < vec.size(); i++) {
cout << vec[i] << " ";
}
cout << endl;
}
template <typename T>
void print(Heap<T>& A) {
for (int i = 0; i < A.size(); i++) {
cout << A[i] << " ";
}
cout << endl;
}
template <typename T>
void print(Queue<T>& Q) {
for (int i = 0; i < Q.size(); i++) {
cout << Q[i] << " ";
}
cout << "\n";
}
template <typename T>
void print(Stack<T>& S) {
for (int i = 0; i < S.size(); i++) {
cout << S[i] << " ";
}
cout << "\n";
}
template <typename T>
void print(List<T>& L) {
for (ListNode<T>* curr = L.head; curr; curr = curr->next) {
cout << curr->key << " ";
}
cout << "\n";
}
template <typename T>
void print(List_<T>& L) {
for (ListNode<T>* curr = L.nil->next; curr != L.nil; curr = curr->next) {
cout << curr->key << " ";
}
cout << "\n";
}
template <typename T>
void print(vector<vector<T>>& vec) {
for (int i = 0; i < vec.size(); i++) {
for (int j = 0; j < vec[0].size(); j++) {
cout << vec[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
#endif