std::collate
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <locale>
|
||
| template< class CharT > class collate; |
||
类std::collate封装区域设置特定的排序规则(比较)和散列字符串。这方面是使用std::basic_regex,std::locale::operator()手段,可应用于所有的标准算法,期望字符串比较谓词.
Original:
Class std::collate encapsulates locale-specific collation (comparison) and hashing of strings. This facet is used by std::basic_regex and can be applied, by means of std::locale::operator(), directly to all standard algorithms that expect a string comparison predicate.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
两个专业所提供的标准库和所有语言环境中创建的对象在C + +程序实现
Original:
Two specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Defined in header
<locale> | |
| std::collate<char> | 实现字节字符串的字典序
Original: implements lexicographical ordering of byte strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| std::collate<wchar_t> | 实现宽字符串的字典序
Original: implements lexicographical ordering of wide strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
目录 |
[编辑] 会员类型
| 会员类型
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
char_type
|
charT
|
string_type
|
std::basic_string<charT>
|
[编辑] 成员函数
| 构造一个新的整理方面 Original: constructs a new collate facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 解构一个整理方面 Original: destructs a collate facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (受保护的成员函数) | |
| 调用 do_compare Original: invokes do_compare The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 调用 do_transform Original: invokes do_transform The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 调用 do_hash Original: invokes do_hash The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
[编辑] 会员对象
| static std::locale::id id |
“ID”的语言环境 Original: id of the locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员对象) |
[编辑] 受保护的成员函数
| [虚拟的] </ SPAN></div></div>
|
使用这方面的排序规则比较两个字符串 Original: compares two strings using this facet's collation rules The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟保护成员函数) |
| [虚拟的] </ SPAN></div></div>
|
转换的字符串排序规则,以便通过比较可以被替换 Original: transforms a string so that collation can be replaced by comparison The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟保护成员函数) |
| [虚拟的] </ SPAN></div></div>
|
生成一个整数的哈希值,使用这方面的排序规则 Original: generates an integer hash value using this facet's collation rules The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟保护成员函数) |
[编辑] 为例
#include <locale> #include <iostream> #include <string> #include <vector> #include <algorithm> int main() { std::wcout.imbue(std::locale("")); std::vector<std::wstring> v = {L"ar", L"zebra", L"\u00f6grupp", L"Zebra", L"\u00e4ngel", L"\u00e5r", L"f\u00f6rnamn"}; std::wcout << "Default locale collation order: "; std::sort(v.begin(), v.end()); for(auto s : v) std::wcout << s << ' '; std::wcout << '\n'; std::wcout << "English locale collation order: "; std::sort(v.begin(), v.end(), std::locale("en_US.UTF-8")); for(auto s : v) std::wcout << s << ' '; std::wcout << '\n'; std::wcout << "Swedish locale collation order: "; std::sort(v.begin(), v.end(), std::locale("sv_SE.UTF-8")); for(auto s : v) std::wcout << s << ' '; std::wcout << '\n'; }
Output:
Default locale collation order: Zebra ar förnamn zebra ängel år ögrupp English locale collation order: ängel ar år förnamn ögrupp zebra Zebra Swedish locale collation order: ar förnamn zebra Zebra år ängel ögrupp
[编辑] 另请参阅
| lexicographically compares two strings using this locale's collate facet (公共成员函数of std::locale)
| |
| 创建一个命名的语言环境的整理方面 Original: creates a collate facet for the named locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (类模板) | |
