<commit_before>/*----------COPYRIGHT-------------------------
(c) Copyright <NAME>, 2016
----------------------------------------------*/

/*----------LICENSE---------------------------
This software is licensed under the Apache license. See LICENSE file to learn more.
----------------------------------------------*/

/*----------DESCRIPTION-----------------------
This is a collection of my frequently used classes and methods.
----------------------------------------------*/

#ifndef WRESTD_H
#define WRESTD_H

/* Common imports, or things required for the classes to work. */
#include <stdio.h>
#include <string>
#include <thread>
#include <chrono>

// used to detect things later on, IIRC. Just copied it from the old IOManager.h file, pretty sure it's used somewhere.
#ifdef _WIN32
#define ISWINDOWS 1
#else
#define ISWINDOWS 0
#endif

using namespace std::chrono;

// My namespace, which contains helpful methods and such.
namespace wrestd {
	/* Methods that work with strings. */
	namespace strings {
		int substr_count(std::string, std::string, bool);
		std::string substr_replace(std::string&, std::string, std::string, bool, bool);
		std::string to_lower(std::string);
		std::string to_upper(std::string);
	}
	
	/* Handles IO functions, such as console printing, colors, waiting, etc. and file existance checks. */
	namespace io {
		enum color_t {
			BLACK = 0,
			DARKBLUE = 1,
			DARKGREEN = 2,
			DARKCYAN = 3,
			DARKRED = 4,
			DARKMAGENTA = 5,
			DARKYELLOW = 6,
			DARKWHITE = 7,
			DARKGREY = 8,
			BLUE = 9,
			GREEN = 10,
			CYAN = 11,
			RED = 12,
			MAGENTA = 13,
			YELLOW = 14,
			WHITE = 15,
			DEFAULT = WHITE,
			NOBG = 49,
			NOFG = 39
		};
		enum format_t {
			NORMAL = 22,
			BOLD = 1,
			ITALIC = 3,
			FAINT = 2,
			UNDERLINE = 4,
			BLINK = 5,
			INVERTED = 7,
			RESET = 0
		};
		void printc(std::string, color_t, color_t = NOBG);
		void printlc(std::string, color_t, color_t = NOBG);
		void clear();
		void wait(color_t = DEFAULT, color_t = NOBG);
		void wait(std::string, color_t = DEFAULT, color_t = NOBG);
		void setColor(color_t, color_t = NOBG);
		bool fileExists(char[]);
		int termHeight();
		int termWidth();
		void setFormat(format_t);
	};
	
	/* Handles threading-related functions, including execution times and such. */
	namespace threading {
		template<class RType = double,
			class _Fn,
			class... _Args>
		RType executionTime(_Fn&& fn, _Args&&... args) {
			high_resolution_clock::time_point t1 = high_resolution_clock::now();
			fn(args...);
			high_resolution_clock::time_point t2 = high_resolution_clock::now();
			duration<RType> timespan = duration_cast<duration<RType> >(t2-t1);
			return (RType)timespan.count() * (RType)seconds::period::num/(RType)seconds::period::den;
		}
	};
}

#endif<commit_msg>added v_contains<commit_after>/*----------COPYRIGHT-------------------------
(c) Copyright <NAME>, 2016
----------------------------------------------*/

/*----------LICENSE---------------------------
This software is licensed under the Apache license. See LICENSE file to learn more.
----------------------------------------------*/

/*----------DESCRIPTION-----------------------
This is a collection of my frequently used classes and methods.
----------------------------------------------*/

#ifndef WRESTD_H
#define WRESTD_H

/* Common imports, or things required for the classes to work. */
#include <stdio.h>
#include <string>
#include <thread>
#include <chrono>
#include <algorithm>

// used to detect things later on, IIRC. Just copied it from the old IOManager.h file, pretty sure it's used somewhere.
#ifdef _WIN32
#define ISWINDOWS 1
#else
#define ISWINDOWS 0
#endif

using namespace std::chrono;

// My namespace, which contains helpful methods and such.
namespace wrestd {
	/* Methods that work with strings. */
	namespace strings {
		int substr_count(std::string, std::string, bool);
		std::string substr_replace(std::string&, std::string, std::string, bool, bool);
		std::string to_lower(std::string);
		std::string to_upper(std::string);
	}
	
	/* Handles IO functions, such as console printing, colors, waiting, etc. and file existance checks. */
	namespace io {
		enum color_t {
			BLACK = 0,
			DARKBLUE = 1,
			DARKGREEN = 2,
			DARKCYAN = 3,
			DARKRED = 4,
			DARKMAGENTA = 5,
			DARKYELLOW = 6,
			DARKWHITE = 7,
			DARKGREY = 8,
			BLUE = 9,
			GREEN = 10,
			CYAN = 11,
			RED = 12,
			MAGENTA = 13,
			YELLOW = 14,
			WHITE = 15,
			DEFAULT = WHITE,
			NOBG = 49,
			NOFG = 39
		};
		enum format_t {
			NORMAL = 22,
			BOLD = 1,
			ITALIC = 3,
			FAINT = 2,
			UNDERLINE = 4,
			BLINK = 5,
			INVERTED = 7,
			RESET = 0
		};
		void printc(std::string, color_t, color_t = NOBG);
		void printlc(std::string, color_t, color_t = NOBG);
		void clear();
		void wait(color_t = DEFAULT, color_t = NOBG);
		void wait(std::string, color_t = DEFAULT, color_t = NOBG);
		void setColor(color_t, color_t = NOBG);
		bool fileExists(char[]);
		int termHeight();
		int termWidth();
		void setFormat(format_t);
	};
	
	/* Handles threading-related functions, including execution times and such. */
	namespace threading {
		template<class RType = double,
			class _Fn,
			class... _Args>
		RType executionTime(_Fn&& fn, _Args&&... args) {
			high_resolution_clock::time_point t1 = high_resolution_clock::now();
			fn(args...);
			high_resolution_clock::time_point t2 = high_resolution_clock::now();
			duration<RType> timespan = duration_cast<duration<RType> >(t2-t1);
			return (RType)timespan.count() * (RType)seconds::period::num/(RType)seconds::period::den;
		}
	};

	/* Handles anything related to collections. */
	namespace collections {
		// todo: make this work for any type of collection so long as the algorithms work on it
		template<class T>
		bool v_contains(vector<T>& v, T item) {
			return std::find(v.begin(), v.end(), item) != v.end();
		}
	};
}

#endif
{'fraction_non_alphanumeric': 0.20006851661527922, 'fraction_numerical': 0.016101404590613225, 'mean_word_length': 2.5756276791181874, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2428248', 'n_tokens_mistral': 2176, 'n_tokens_neox': 1876, 'n_words': 566}