finalize documentation
This commit is contained in:
parent
4822c356f8
commit
cd2e1470ca
@ -21,8 +21,6 @@
|
|||||||
#ifndef INC_08_TEAM_PROJECT_BINARYTREENODE_H
|
#ifndef INC_08_TEAM_PROJECT_BINARYTREENODE_H
|
||||||
#define INC_08_TEAM_PROJECT_BINARYTREENODE_H
|
#define INC_08_TEAM_PROJECT_BINARYTREENODE_H
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class BinaryTreeNode {
|
class BinaryTreeNode {
|
||||||
private:
|
private:
|
||||||
|
34
CPU.h
34
CPU.h
@ -1,3 +1,8 @@
|
|||||||
|
// CPU class
|
||||||
|
//
|
||||||
|
// Written by: Kevin Galvan Serrano
|
||||||
|
// Modified by: Iurii Tatishchev
|
||||||
|
|
||||||
#ifndef INC_08_TEAM_PROJECT_CPU_H
|
#ifndef INC_08_TEAM_PROJECT_CPU_H
|
||||||
#define INC_08_TEAM_PROJECT_CPU_H
|
#define INC_08_TEAM_PROJECT_CPU_H
|
||||||
|
|
||||||
@ -72,19 +77,46 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display the CPU object as a table.
|
||||||
|
*
|
||||||
|
* Written by: Iurii Tatishchev
|
||||||
|
*/
|
||||||
void display(const CPU &cpu);
|
void display(const CPU &cpu);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display the CPU object as part of an indented tree.
|
||||||
|
*
|
||||||
|
* Written by: Tuhin Mondal
|
||||||
|
*/
|
||||||
void iDisplay(const std::string &cpuId, int level);
|
void iDisplay(const std::string &cpuId, int level);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display the CPU object as a table row.
|
||||||
|
*
|
||||||
|
* Written by: Iurii Tatishchev
|
||||||
|
*/
|
||||||
void rowDisplay(const CPU &cpu, const std::vector<int> &widths);
|
void rowDisplay(const CPU &cpu, const std::vector<int> &widths);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overload the << operator to display the CPU object.
|
||||||
|
*
|
||||||
|
* Written by: Iurii Tatishchev
|
||||||
|
*/
|
||||||
std::ostream &operator<<(std::ostream &os, const CPU &cpu);
|
std::ostream &operator<<(std::ostream &os, const CPU &cpu);
|
||||||
|
|
||||||
/*~*~*~*
|
/*~*~*~*
|
||||||
Hash function: takes the key and returns the index in the hash table
|
Hash function: takes the key and returns the index in the hash table.
|
||||||
|
|
||||||
|
Written by: Joshiro Lawrence
|
||||||
*~**/
|
*~**/
|
||||||
int key_to_index(const CPU &key, int size);
|
int key_to_index(const CPU &key, int size);
|
||||||
|
|
||||||
|
/*~*~*~*
|
||||||
|
Converts the CPU object to a string.
|
||||||
|
|
||||||
|
Written by: Iurii Tatishchev
|
||||||
|
*~**/
|
||||||
std::string to_string(const CPU &cpu);
|
std::string to_string(const CPU &cpu);
|
||||||
|
|
||||||
#endif // INC_08_TEAM_PROJECT_CPU_H
|
#endif // INC_08_TEAM_PROJECT_CPU_H
|
||||||
|
26
HashNode.h
26
HashNode.h
@ -1,9 +1,13 @@
|
|||||||
|
/*
|
||||||
|
Joshiro Lawrence - Unit 3 (Hash Table)
|
||||||
|
Wrote all functions in this file.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef INC_08_TEAM_PROJECT_HASHNODE_H
|
#ifndef INC_08_TEAM_PROJECT_HASHNODE_H
|
||||||
#define INC_08_TEAM_PROJECT_HASHNODE_H
|
#define INC_08_TEAM_PROJECT_HASHNODE_H
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
class HashNode
|
class HashNode {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
T item;
|
T item;
|
||||||
int occupied; // 1 -> occupied, 0 -> empty from start, -1 -> empty after removal
|
int occupied; // 1 -> occupied, 0 -> empty from start, -1 -> empty after removal
|
||||||
@ -11,31 +15,35 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
HashNode()
|
HashNode() {
|
||||||
{
|
|
||||||
occupied = 0;
|
occupied = 0;
|
||||||
numCollisions = 0;
|
numCollisions = 0;
|
||||||
}
|
}
|
||||||
HashNode(T anItem)
|
|
||||||
{
|
HashNode(T anItem) {
|
||||||
item = anItem;
|
item = anItem;
|
||||||
occupied = 1;
|
occupied = 1;
|
||||||
numCollisions = 0;
|
numCollisions = 0;
|
||||||
}
|
}
|
||||||
HashNode(T anItem, int ocp, int nCol)
|
|
||||||
{
|
HashNode(T anItem, int ocp, int nCol) {
|
||||||
item = anItem;
|
item = anItem;
|
||||||
occupied = ocp;
|
occupied = ocp;
|
||||||
numCollisions = nCol;
|
numCollisions = nCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setItem(const T &anItem) { item = anItem; }
|
void setItem(const T &anItem) { item = anItem; }
|
||||||
|
|
||||||
void setOccupied(int ocp) { occupied = ocp; }
|
void setOccupied(int ocp) { occupied = ocp; }
|
||||||
|
|
||||||
void setNumCollisions(int nCol) { numCollisions = nCol; }
|
void setNumCollisions(int nCol) { numCollisions = nCol; }
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
T getItem() const { return item; }
|
T getItem() const { return item; }
|
||||||
|
|
||||||
int getOccupied() const { return occupied; }
|
int getOccupied() const { return occupied; }
|
||||||
|
|
||||||
int getNumCollisions() const { return numCollisions; }
|
int getNumCollisions() const { return numCollisions; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
25
HashTable.h
25
HashTable.h
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
Joshiro Lawrence - Unit 3 (Hash Table)
|
||||||
|
Wrote all functions in this file except for _reHash, writeToFile, and the code block of insert that deals with rehashing
|
||||||
|
|
||||||
|
The purpose of the hash table in this project is to store the CPU objects. This allows for quick insertion, search, and removal into the hash table. Specifically, the hash table allows for quick searching in this program, to tell if a CPU object exists in the database already.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef INC_08_TEAM_PROJECT_HASHTABLE_H
|
#ifndef INC_08_TEAM_PROJECT_HASHTABLE_H
|
||||||
#define INC_08_TEAM_PROJECT_HASHTABLE_H
|
#define INC_08_TEAM_PROJECT_HASHTABLE_H
|
||||||
|
|
||||||
@ -173,6 +180,15 @@ int HashTable<T>::search(T &itemOut, const T &key, int h(const T &key, int size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: reHash
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By:
|
||||||
|
* Purpose: Increases the size of the Hash Table's array
|
||||||
|
* Input: Hash function
|
||||||
|
* Output: N/A
|
||||||
|
* Procedure: Creates a larger array, and then traverses the old array, rehashing each item into the new one.
|
||||||
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
void HashTable<T>::_reHash(int h(const T &key, int size)) {
|
void HashTable<T>::_reHash(int h(const T &key, int size)) {
|
||||||
|
|
||||||
@ -207,6 +223,15 @@ void HashTable<T>::_reHash(int h(const T &key, int size)) {
|
|||||||
hashSize = nHashSize;
|
hashSize = nHashSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: writeToFile
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By:
|
||||||
|
* Purpose: Outputs each item in the hash table into a file.
|
||||||
|
* Input: Name of the file, function
|
||||||
|
* Output: N/A
|
||||||
|
* Procedure: Checks if a bucket is in use, and outputs it into the file.
|
||||||
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void writeToFile(const HashTable<T> &hashTable, const string &filename, string visit(const T &)) {
|
void writeToFile(const HashTable<T> &hashTable, const string &filename, string visit(const T &)) {
|
||||||
ofstream outputFile(filename);
|
ofstream outputFile(filename);
|
||||||
|
25
fio.cpp
25
fio.cpp
@ -1,3 +1,10 @@
|
|||||||
|
// Unit 5: File I/O
|
||||||
|
// - Determine hash size based on the number of records in the file
|
||||||
|
// - Read data from the input file and insert them into the hash table and BST
|
||||||
|
//
|
||||||
|
// Written by: Kevin Cremin
|
||||||
|
// Modified by: Iurii Tatishchev
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "fio.h"
|
#include "fio.h"
|
||||||
|
|
||||||
@ -143,6 +150,15 @@ void insertCPU(BinarySearchTree<string> &bst, HashTable<CPU> &hash) {
|
|||||||
hash.insert(aCPU, key_to_index);
|
hash.insert(aCPU, key_to_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: isInteger
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By:
|
||||||
|
* Purpose: Determine if input is an integer
|
||||||
|
* Input: String to test
|
||||||
|
* Output: Bool of whether input was an integer
|
||||||
|
* Procedure: Checks that all characters are digits.
|
||||||
|
*/
|
||||||
bool isInteger(const string &str) {
|
bool isInteger(const string &str) {
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
if (!(isdigit(str[i]))) {
|
if (!(isdigit(str[i]))) {
|
||||||
@ -153,6 +169,15 @@ bool isInteger(const string &str) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: isDouble
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By:
|
||||||
|
* Purpose: Determine if input is a double
|
||||||
|
* Input: String to test
|
||||||
|
* Output: Bool of whether input was an double
|
||||||
|
* Procedure: Checks that all characters are digits and that there is at most one period.
|
||||||
|
*/
|
||||||
bool isDouble(const string &str) {
|
bool isDouble(const string &str) {
|
||||||
int chance = 0;
|
int chance = 0;
|
||||||
|
|
||||||
|
37
fio.h
37
fio.h
@ -1,8 +1,8 @@
|
|||||||
// Unit 5: File I/O
|
// Unit 5: File I/O
|
||||||
// - Determine hash size based on the number of records in the file
|
// - Determine hash size based on the number of records in the file
|
||||||
// - Read data from the input file and insert them into the hash table and BST
|
// - Read data from the input file and insert them into the hash table and BST
|
||||||
// - Save to file (in hash table sequence)
|
// - Save to file (in hash table sequence) (in HashTable.h)
|
||||||
// - Re-hashing
|
// - Re-hashing (in HashTable.h)
|
||||||
//
|
//
|
||||||
// Written by: Kevin Cremin
|
// Written by: Kevin Cremin
|
||||||
|
|
||||||
@ -18,10 +18,39 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
int findHashSize(const string& filename);
|
/*
|
||||||
|
* Name: findHashSize
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By: Iurii Tatishchev
|
||||||
|
* Purpose: Find the the necessary initial size of the hash table
|
||||||
|
* Input: Name of file
|
||||||
|
* Output: Appropriate size of hash array based on how many items are in the fileName
|
||||||
|
* Procedure: Multiplies number of items in file by two, then finds next prime number
|
||||||
|
*/
|
||||||
|
int findHashSize(const string &filename);
|
||||||
|
|
||||||
void insertFile(const string& filename, BinarySearchTree<string> &bst, HashTable<CPU> &hash);
|
/*
|
||||||
|
* Name: insertFile
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By: Iurii Tatishchev
|
||||||
|
* Purpose: Input all items in the file into the program.
|
||||||
|
* Input: Name of file, the Binary Search Tree, and the Hash Table
|
||||||
|
* Output: N/A
|
||||||
|
* Procedure: Goes through each item in the file and inputs them into the table and tree,
|
||||||
|
* verifying that there are no duplicate keys.
|
||||||
|
*/
|
||||||
|
void insertFile(const string &filename, BinarySearchTree<string> &bst, HashTable<CPU> &hash);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: insertCPU
|
||||||
|
* Written By: Kevin Cremin
|
||||||
|
* Modified By:
|
||||||
|
* Purpose: Input an individual CPU from the user
|
||||||
|
* Input: The Binary Search Tree and the Hash Table
|
||||||
|
* Output: N/A
|
||||||
|
* Procedure: Requests information from the user, making sure that it is not a duplicate,
|
||||||
|
* and that all inputs are the correct data type.
|
||||||
|
*/
|
||||||
void insertCPU(BinarySearchTree<string> &bst, HashTable<CPU> &hash);
|
void insertCPU(BinarySearchTree<string> &bst, HashTable<CPU> &hash);
|
||||||
|
|
||||||
#endif //INC_08_TEAM_PROJECT_FIO_H
|
#endif //INC_08_TEAM_PROJECT_FIO_H
|
||||||
|
36
main.cpp
36
main.cpp
@ -24,6 +24,11 @@
|
|||||||
// The output file name does not have to be the same as the input file name,
|
// The output file name does not have to be the same as the input file name,
|
||||||
// but the file format must be the same so that it can be read back into the program.
|
// but the file format must be the same so that it can be read back into the program.
|
||||||
|
|
||||||
|
// Unit 1: Main
|
||||||
|
// - Menu and input processing
|
||||||
|
//
|
||||||
|
// Written by: Iurii Tatishchev
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -40,6 +45,9 @@ using namespace std;
|
|||||||
|
|
||||||
const string DEFAULT_FILE = "out.txt";
|
const string DEFAULT_FILE = "out.txt";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Takes a command character and calls the appropriate function to process the command.
|
||||||
|
*/
|
||||||
void processInput(char command, HashTable<CPU> &table, BinarySearchTree<string> &tree,
|
void processInput(char command, HashTable<CPU> &table, BinarySearchTree<string> &tree,
|
||||||
UndoManager<CPU> &undoManager, DisplayManager<CPU> &displayManager,
|
UndoManager<CPU> &undoManager, DisplayManager<CPU> &displayManager,
|
||||||
SearchManager<CPU> &searchManager);
|
SearchManager<CPU> &searchManager);
|
||||||
@ -68,7 +76,9 @@ int main() {
|
|||||||
cout << "Enter an option (H - for help): ";
|
cout << "Enter an option (H - for help): ";
|
||||||
cin >> command;
|
cin >> command;
|
||||||
command = toupper(command, std::locale());
|
command = toupper(command, std::locale());
|
||||||
// Temporary try catch block to handle unimplemented commands
|
// Temporary try catch block to handle unimplemented commands.
|
||||||
|
// Actually, this catches exceptions like stoi (integer input too large)
|
||||||
|
// so I think leaving it is a good idea.
|
||||||
try {
|
try {
|
||||||
processInput(command, cpuTable, cpuTree, undoManager, displayManager, searchManager);
|
processInput(command, cpuTable, cpuTree, undoManager, displayManager, searchManager);
|
||||||
}
|
}
|
||||||
@ -77,18 +87,31 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Quit command received
|
// Quit command received
|
||||||
writeToFile(cpuTable, DEFAULT_FILE, to_string);
|
|
||||||
cout << "Exiting program...\n";
|
cout << "Exiting program...\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Input a new record into the table and tree.
|
||||||
|
*/
|
||||||
void handleInsert(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree);
|
void handleInsert(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Input data from a file into the table and tree.
|
||||||
|
*/
|
||||||
void handleFileInput(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree);
|
void handleFileInput(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete a record from the table and tree.
|
||||||
|
* Also adds the deleted record to the undo stack.
|
||||||
|
*/
|
||||||
void deleteCPU(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree, UndoManager<CPU> &undoManager);
|
void deleteCPU(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree, UndoManager<CPU> &undoManager);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write data to a file.
|
||||||
|
* Also clears the undo stack.
|
||||||
|
*/
|
||||||
void handleFileOutput(HashTable<CPU> &hashTable, UndoManager<CPU> &undoManager);
|
void handleFileOutput(HashTable<CPU> &hashTable, UndoManager<CPU> &undoManager);
|
||||||
|
|
||||||
void processInput(char command, HashTable<CPU> &cpuTable, BinarySearchTree<string> &cpuTree,
|
void processInput(char command, HashTable<CPU> &cpuTable, BinarySearchTree<string> &cpuTree,
|
||||||
@ -121,9 +144,9 @@ void processInput(char command, HashTable<CPU> &cpuTable, BinarySearchTree<strin
|
|||||||
handleFileOutput(cpuTable, undoManager);
|
handleFileOutput(cpuTable, undoManager);
|
||||||
break;
|
break;
|
||||||
case 'T': // Hashtable statistics
|
case 'T': // Hashtable statistics
|
||||||
cout << "Load factor: " << cpuTable.getLoadFactor() << std::endl;
|
cout << "Load factor: " << cpuTable.getLoadFactor() << '\n';
|
||||||
cout << "Total number of collisions: " << cpuTable.getTotalCollisions() << std::endl;
|
cout << "Total number of collisions: " << cpuTable.getTotalCollisions() << '\n';
|
||||||
cout << "Longest collision path: " << cpuTable.getMaxCollisions() << std::endl;
|
cout << "Longest collision path: " << cpuTable.getMaxCollisions() << '\n';
|
||||||
break;
|
break;
|
||||||
case 'P': // Print indented tree
|
case 'P': // Print indented tree
|
||||||
cpuTree.printTree(iDisplay);
|
cpuTree.printTree(iDisplay);
|
||||||
@ -132,6 +155,7 @@ void processInput(char command, HashTable<CPU> &cpuTable, BinarySearchTree<strin
|
|||||||
printTeam();
|
printTeam();
|
||||||
break;
|
break;
|
||||||
case 'Q': // Quit
|
case 'Q': // Quit
|
||||||
|
writeToFile(cpuTable, DEFAULT_FILE, to_string);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cout << "Invalid command. Press 'H' to view available commands.\n";
|
cout << "Invalid command. Press 'H' to view available commands.\n";
|
||||||
@ -158,7 +182,7 @@ void deleteCPU(HashTable<CPU> &hashTable, BinarySearchTree<string> &tree, UndoMa
|
|||||||
|
|
||||||
CPU cpu(cpuId, 0, 0, "", 0.0);
|
CPU cpu(cpuId, 0, 0, "", 0.0);
|
||||||
CPU cpuFound;
|
CPU cpuFound;
|
||||||
if (hashTable.search(cpuFound, cpu, key_to_index) == -1) {
|
if (hashTable.search(cpuFound, cpu, key_to_index) == -1) {
|
||||||
cout << "CPU ID \"" << cpuId << "\" not found.\n";
|
cout << "CPU ID \"" << cpuId << "\" not found.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
10
utils.cpp
10
utils.cpp
@ -58,16 +58,6 @@ void printTableFooter(const vector<int> &widths) {
|
|||||||
cout << "\b┘\n";
|
cout << "\b┘\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Print ascii/unicode table with given column widths and data. For example:
|
|
||||||
* ┌────────────────────────────────────────┬──────────┬────────────────────────┬────────────────┐
|
|
||||||
* | Col1 | Col2 | Col3 | Numeric Column |
|
|
||||||
* +========================================+==========+========================+================+
|
|
||||||
* | Value 1 | Value 2 | 123 | 10.0 |
|
|
||||||
* | Separate | cols | with a tab or 4 spaces | -2,027.1 |
|
|
||||||
* | This is a row with only one cell | | | |
|
|
||||||
* └────────────────────────────────────────┴──────────┴────────────────────────┴────────────────┘
|
|
||||||
*/
|
|
||||||
void printTable(const vector<int> &widths, const vector<vector<string>> &data) {
|
void printTable(const vector<int> &widths, const vector<vector<string>> &data) {
|
||||||
printTableHeader(widths, data[0]);
|
printTableHeader(widths, data[0]);
|
||||||
for (int i = 1; i < data.size(); i++) {
|
for (int i = 1; i < data.size(); i++) {
|
||||||
|
52
utils.h
52
utils.h
@ -1,3 +1,6 @@
|
|||||||
|
// Contains utility functions mostly for printing tables and formatting.
|
||||||
|
// Written by: Iurii Tatishchev
|
||||||
|
|
||||||
#ifndef INC_08_TEAM_PROJECT_UTILS_H
|
#ifndef INC_08_TEAM_PROJECT_UTILS_H
|
||||||
#define INC_08_TEAM_PROJECT_UTILS_H
|
#define INC_08_TEAM_PROJECT_UTILS_H
|
||||||
|
|
||||||
@ -6,22 +9,71 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print a single row of a table, given the widths of each column and the data for the row.
|
||||||
|
*
|
||||||
|
* Example output:
|
||||||
|
* | Value 1 | Value 2 | 123 | 10.0 |
|
||||||
|
*/
|
||||||
void printRow(const vector<int> &widths, const vector<string> &row);
|
void printRow(const vector<int> &widths, const vector<string> &row);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print the header of a table, given the widths of each column and the headers for each column.
|
||||||
|
* Unicode characters are used to draw the table.
|
||||||
|
*
|
||||||
|
* Example output:
|
||||||
|
* ┌────────────────────────────────────────┬──────────┬────────────────────────┬────────────────┐
|
||||||
|
* | Col1 | Col2 | Col3 | Numeric Column |
|
||||||
|
* +========================================+==========+========================+================+
|
||||||
|
*/
|
||||||
void printTableHeader(const vector<int> &widths, const vector<string> &headers);
|
void printTableHeader(const vector<int> &widths, const vector<string> &headers);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print the footer of a table, given the widths of each column.
|
||||||
|
*
|
||||||
|
* Example output:
|
||||||
|
* └────────────────────────────────────────┴──────────┴────────────────────────┴────────────────┘
|
||||||
|
*/
|
||||||
void printTableFooter(const vector<int> &widths);
|
void printTableFooter(const vector<int> &widths);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print ascii/unicode table with given column widths and data. For example:
|
||||||
|
* ┌────────────────────────────────────────┬──────────┬────────────────────────┬────────────────┐
|
||||||
|
* | Col1 | Col2 | Col3 | Numeric Column |
|
||||||
|
* +========================================+==========+========================+================+
|
||||||
|
* | Value 1 | Value 2 | 123 | 10.0 |
|
||||||
|
* | Separate | cols | with a tab or 4 spaces | -2,027.1 |
|
||||||
|
* | This is a row with only one cell | | | |
|
||||||
|
* └────────────────────────────────────────┴──────────┴────────────────────────┴────────────────┘
|
||||||
|
*/
|
||||||
void printTable(const vector<int> &widths, const vector<vector<string>> &data);
|
void printTable(const vector<int> &widths, const vector<vector<string>> &data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print a help table with all available commands and their descriptions.
|
||||||
|
*/
|
||||||
void printHelp();
|
void printHelp();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print a table with the team members and their roles.
|
||||||
|
*/
|
||||||
void printTeam();
|
void printTeam();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the next prime number after n.
|
||||||
|
*
|
||||||
|
* Written by: Kevin Cremin
|
||||||
|
* Modified by: Iurii Tatishchev
|
||||||
|
*/
|
||||||
int findNextPrime(int n);
|
int findNextPrime(int n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add bold control characters around a string for terminal output.
|
||||||
|
*/
|
||||||
string boldStr(const string &str);
|
string boldStr(const string &str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pad a string with spaces on both sides to center it in a string of a given width.
|
||||||
|
*/
|
||||||
string centeredStr(const string &str, int width);
|
string centeredStr(const string &str, int width);
|
||||||
|
|
||||||
#endif //INC_08_TEAM_PROJECT_UTILS_H
|
#endif //INC_08_TEAM_PROJECT_UTILS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user