- 冒泡排序
- 快速排序
- 直接插入排序
- 希尔排序
- 简单选择排序
- 桶排序
- 归并排序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
#include <cassert> | |
#include <memory> | |
#include <ctime> | |
using namespace std; | |
bool g_bUseNormal = false; | |
int* next_array = nullptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <functional> | |
class CScopedRelease | |
{ | |
public: | |
explicit CScopedRelease(std::function<void ()> pfnRelease) | |
: m_pfnRelease(pfnRelease) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename CALLBACKTYPE,typename... ARGS> | |
class TimeoutHandler | |
{ | |
public: | |
TimeoutHandler(const int _timeout/*ms*/,CALLBACKTYPE _callback, ARGS... _args) | |
{ | |
std::thread([](TimeoutHandler* this_object,int _timeout, CALLBACKTYPE _callback, ARGS... _args) | |
{ | |
std::this_thread::sleep_for(std::chrono::milliseconds(_timeout)); | |
if (!this_object->exit_flag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,SIMD指令优化的是计算,对于内存复制之类的问题,限制在内存,使用SIMD指令优化很少; | |
2,SIMD指令也需要耗费时间,不要把若干移位和一两次乘法变成SIMD乘法,性能急剧下降; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace cxxdetail | |
{ | |
template <typename FuncType> | |
class InnerScopeExit | |
{ | |
public: | |
InnerScopeExit(const FuncType _func) :func(_func){} | |
~InnerScopeExit(){ if (!dismissed){ func(); } } | |
private: | |
FuncType func; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
static std::string convertUtf16ToLocal(const unsigned short data) | |
{ | |
char dstData[3]; | |
::wcstombs(dstData, (const wchar_t *)&data, 2); | |
dstData[2] = '\0'; | |
return dstData; | |
} | |
static void dumpUtf16Charset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
// FreeType headers | |
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
// OpenCV headers | |
#include <opencv2/core/core.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static std::string strip(const std::string& content) | |
{ | |
if (content.empty()) | |
{ | |
return content; | |
} | |
std::string result = content; | |
while (true) | |
{ | |
const wchar_t last_char = result[result.size() - 1]; |
OlderNewer