7Utils::COLOR Counter_Duplication_Code_Trie::choose_text_color(){
8 number_printed_lines++;
10 if(number_printed_lines%2 == 0){
16int Counter_Duplication_Code_Trie::create_node_at_the_end(){
20 counter_duplication_lines.push_back(ZERO_INITIAL_COUNTER);
24void Counter_Duplication_Code_Trie::create_edge_if_not_exist(
int node,
string folder){
25 if(trie[node].find(folder) == trie[node].end()){
26 trie[node][folder] = create_node_at_the_end();
30string Counter_Duplication_Code_Trie::create_context_string_on_depth(
int depth){
32 for(
int i = 0; i < depth; i++){
33 ret += BASIC_SHIFT_PER_DEPTH;
40void Counter_Duplication_Code_Trie::print_node_information(
int node,
int depth,
string folder){
41 string line = create_context_string_on_depth(depth) + folder + TWO_POINTER_AFTER_FOLDER;
42 line +=
to_string(counter_duplication_lines[node]) + LINE_TEXT;
47void Counter_Duplication_Code_Trie::dfs_print_duplication_code_trie(
int current_node,
int depth,
string folder){
48 print_node_information(current_node,depth,folder);
49 for(
auto [child_folder,child_node] : trie[current_node]){
50 int child_depth = depth+1;
51 dfs_print_duplication_code_trie(child_node,child_depth,child_folder);
56 int current_node = ROOT_NODE;
57 counter_duplication_lines[current_node] += number_of_duplication_lines;
58 for(
auto folder : folder_path){
59 create_edge_if_not_exist(current_node,folder);
60 current_node = trie[current_node][folder];
61 counter_duplication_lines[current_node] += number_of_duplication_lines;
66 dfs_print_duplication_code_trie(ROOT_NODE,BASE_DEPTH,EMPTY_FOLDER);
70 create_node_at_the_end();
Counter_Duplication_Code_Trie()
Constructs a new trie with root node.
void print_duplication_code_trie()
Prints the trie structure with duplication counts.
void add_folder_duplication_code(vector< string > folder_path, int number_of_duplication_lines)
Adds duplication count for a folder path.
Trie-based code duplication counter.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
COLOR
Enumeration of available colors for formatted messages.
string format_colored_message(string message, COLOR color)
Formats a message with ANSI color codes.