コード例 #1
0
static const std::vector<wchar_t> create_alt_sort_table()
{
	std::vector<wchar_t> alt_sort_table(WCHAR_MAX + 1);
	std::vector<wchar_t> chars(WCHAR_MAX + 1);

	std::iota(ALL_RANGE(chars), 0);

	std::sort(chars.begin() + 1, chars.end(), [](wchar_t a, wchar_t b) { return StrCmpNN(&a, 1, &b, 1) < 0; });

	int u_beg = 0, u_end = 0xffff;
	for (int ic=0; ic < 0x10000; ++ic)
	{
		if (chars[ic] == L'a')
		{
			u_beg = ic;
			break;
		}
		alt_sort_table[chars[ic]] = static_cast<wchar_t>(ic);
	}

	for (int ic=0xffff; ic > u_beg; --ic)
	{
		if (IsUpper(chars[ic]))
		{
			u_end = ic;
			break;
		}
		alt_sort_table[chars[ic]] = static_cast<wchar_t>(ic);
	}
	assert(u_beg > 0 && u_beg < u_end && u_end < 0xffff);

	int cc = u_beg;
	for (int ic=u_beg; ic <= u_end; ++ic) // uppercase first
	{
		if (IsUpper(chars[ic]))
			alt_sort_table[chars[ic]] = static_cast<wchar_t>(cc++);
	}
	for (int ic=u_beg; ic <= u_end; ++ic) // than not uppercase
	{
		if (!IsUpper(chars[ic]))
			alt_sort_table[chars[ic]] = static_cast<wchar_t>(cc++);
	}
	assert(cc == u_end+1);
	return alt_sort_table;
}
コード例 #2
0
ファイル: local.hpp プロジェクト: Firebie/FarManager
inline int StrCmpN(const wchar_t *s1, const wchar_t *s2, size_t n) { return StrCmpNN(s1, n, s2, n); }
コード例 #3
0
ファイル: local.hpp プロジェクト: AlexKir/Far-NetBox
inline int __cdecl FarStrCmpN(const wchar_t *s1, const wchar_t *s2, int n) { return StrCmpNN(s1,n,s2,n); }