Changed every int to int32_t
This commit is contained in:
		
							
								
								
									
										2
									
								
								data.cpp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								data.cpp
									
									
									
									
									
								
							| @@ -60,7 +60,7 @@ static asp::Array<T> create_random_array(const size_t& n) noexcept { | ||||
| 	return std::move(asp::map(original, [& distrib, & gen](const size_t&, const T&) -> const T { return distrib(gen); })); | ||||
| } | ||||
|  | ||||
| int main(int argc, char** argv) { | ||||
| int32_t main(int32_t argc, char** argv) { | ||||
| 	asp::toolbox_unit_test(); | ||||
|  | ||||
| 	using array_type = uint16_t; | ||||
|   | ||||
							
								
								
									
										39
									
								
								data.hpp
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								data.hpp
									
									
									
									
									
								
							| @@ -1,6 +1,9 @@ | ||||
| #pragma once | ||||
| #include <memory> | ||||
| #include <cstring> | ||||
| #ifdef __DEBUG | ||||
| #include <stdexcept> | ||||
| #endif | ||||
|  | ||||
| namespace asp { | ||||
| 	template<typename T> | ||||
| @@ -42,8 +45,8 @@ namespace asp { | ||||
| 	}; | ||||
|  | ||||
| 	template<typename T> | ||||
| 	int print(const Array<T>& a, const char* format) noexcept { | ||||
| 		int num_written = 0; | ||||
| 	int32_t print(const Array<T>& a, const char* format) noexcept { | ||||
| 		int32_t num_written = 0; | ||||
| 		num_written += printf("["); | ||||
| 		char formatter[BUFSIZ] = { 0 }; | ||||
| 		sprintf(formatter, "%s,", format); | ||||
| @@ -54,24 +57,28 @@ namespace asp { | ||||
| 		return num_written; | ||||
| 	} | ||||
|  | ||||
| 	int print(const Array<int>& a) noexcept { | ||||
| 	int32_t print(const Array<uint16_t>& a) noexcept { | ||||
| 		return print(a, "%b"); | ||||
| 	} | ||||
|  | ||||
| 	int32_t print(const Array<int32_t>& a) noexcept { | ||||
| 		return print(a, "%i"); | ||||
| 	} | ||||
|  | ||||
| 	int print(const Array<uint64_t>& a) noexcept { | ||||
| 	int32_t print(const Array<uint64_t>& a) noexcept { | ||||
| 		return print(a, "%lu"); | ||||
| 	} | ||||
|  | ||||
| 	int print(const Array<int16_t>& a) noexcept { | ||||
| 	int32_t print(const Array<int16_t>& a) noexcept { | ||||
| 		//printf("%i\n", a[0]); | ||||
| 		return print(a, "%i"); | ||||
| 	} | ||||
|  | ||||
| 	int print(const std::string& s) noexcept { | ||||
| 	int32_t print(const std::string& s) noexcept { | ||||
| 		return printf("%s\n", s.c_str()); | ||||
| 	} | ||||
|  | ||||
| 	int print(const char* s) noexcept { | ||||
| 	int32_t print(const char* s) noexcept { | ||||
| 		return printf("%s\n", s); | ||||
| 	} | ||||
|  | ||||
| @@ -383,23 +390,23 @@ namespace asp { | ||||
| 		return mergesort_arg(a, 0, a.length - 1); | ||||
| 	} | ||||
|  | ||||
| 	//static void count_sort(const Array<int>& a, const int& exp, const int& d) noexcept { | ||||
| 	//	Array<int> output(a.length), count(d); | ||||
| 	//	memset(&count[0], 0, d * sizeof(int)); | ||||
| 	//static void count_sort(const Array<int32_t>& a, const int32_t& exp, const int32_t& d) noexcept { | ||||
| 	//	Array<int32_t> output(a.length), count(d); | ||||
| 	//	memset(&count[0], 0, d * sizeof(int32_t)); | ||||
|  | ||||
| 	//	foreach(a, [count, exp, d](const int&, const int& val) -> void { | ||||
| 	//	foreach(a, [count, exp, d](const int32_t&, const int32_t& val) -> void { | ||||
| 	//		count[(val / exp) % d]++; | ||||
| 	//	}); | ||||
|  | ||||
| 	//	for (int i = 1; i <= d; ++i) | ||||
| 	//	for (int32_t i = 1; i <= d; ++i) | ||||
| 	//		count[i] += count[i - 1]; | ||||
|  | ||||
| 	//	for (int i = a.length - 1; i >= 0; --i) { | ||||
| 	//	for (int32_t i = a.length - 1; i >= 0; --i) { | ||||
| 	//		output[count[(a[i] / exp) % d] - 1] = a[i]; | ||||
| 	//		count[(a[i] / exp) % d]--; | ||||
| 	//	} | ||||
|  | ||||
| 	//	memcpy(&a[0], &output[0], a.length * sizeof(int)); | ||||
| 	//	memcpy(&a[0], &output[0], a.length * sizeof(int32_t)); | ||||
| 	//} | ||||
|  | ||||
| 	template<typename T> | ||||
| @@ -421,7 +428,7 @@ namespace asp { | ||||
| 	template<typename T> | ||||
| 	inline void radix_sort_256(T* a, const size_t& n) noexcept { | ||||
| 		//template<typename T> | ||||
| 		//void radix_sort(const Array<int>& a) noexcept { | ||||
| 		//void radix_sort(const Array<int32_t>& a) noexcept { | ||||
| 		if (n <= 1) | ||||
| 			//if (a.length <= 1) | ||||
| 			return; | ||||
| @@ -445,7 +452,7 @@ namespace asp { | ||||
| 				count[i] += count[i - 1]; | ||||
|  | ||||
| 			// Build the output array | ||||
| 			for (int i = n - 1; i >= 0; i--) { | ||||
| 			for (int32_t i = n - 1; i >= 0; i--) { | ||||
| 				// precalculate the offset as it's a few instructions | ||||
| 				const size_t idx = (a[i] >> s) & 0xff; | ||||
|  | ||||
|   | ||||
| @@ -124,8 +124,8 @@ namespace asp { | ||||
| 	std::string thousand_sep(const uint64_t& k, const char& sep) noexcept { | ||||
| 		std::string s = "", n = std::to_string(k); | ||||
|  | ||||
| 		int c = 0; | ||||
| 		for (int i = static_cast<int>(n.size()) - 1; i >= 0; --i) { | ||||
| 		int32_t c = 0; | ||||
| 		for (int32_t i = static_cast<int32_t>(n.size()) - 1; i >= 0; --i) { | ||||
| 			c++; | ||||
| 			s.push_back(n[i]); | ||||
| 			if (c == 3) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user