mirror of
https://github.com/Garux/netradiant-custom.git
synced 2026-09-28 00:00:03 +02:00
use is_transparent std::set std::map search
This commit is contained in:
+47
-1
@@ -52,6 +52,14 @@ inline int string_compare( const char* string, const char* other ){
|
||||
return std::strcmp( string, other );
|
||||
}
|
||||
|
||||
/// \brief Returns <0 if [\p string, \p string + \p n) is lexicographically less than [\p other, \p other + \p n).
|
||||
/// Returns >0 if [\p string, \p string + \p n) is lexicographically greater than [\p other, \p other + \p n).
|
||||
/// Returns 0 if [\p string, \p string + \p n) is lexicographically equal to [\p other, \p other + \p n).
|
||||
/// O(n)
|
||||
inline int string_compare_n( const char* string, const char* other, std::size_t n ){
|
||||
return std::strncmp( string, other, n );
|
||||
}
|
||||
|
||||
/// \brief Returns true if \p string is lexicographically equal to \p other.
|
||||
/// O(n)
|
||||
inline bool string_equal( const char* string, const char* other ){
|
||||
@@ -61,7 +69,7 @@ inline bool string_equal( const char* string, const char* other ){
|
||||
/// \brief Returns true if [\p string, \p string + \p n) is lexicographically equal to [\p other, \p other + \p n).
|
||||
/// O(n)
|
||||
inline bool string_equal_n( const char* string, const char* other, std::size_t n ){
|
||||
return std::strncmp( string, other, n ) == 0;
|
||||
return string_compare_n( string, other, n ) == 0;
|
||||
}
|
||||
|
||||
/// \brief Returns true if \p string is lexicographically less than \p other.
|
||||
@@ -608,6 +616,30 @@ public:
|
||||
/// \brief A non-mutable string which uses copy-by-reference for assignment of SmartString.
|
||||
typedef String< SmartBuffer< DefaultAllocator<char> > > SmartString;
|
||||
|
||||
|
||||
template<>
|
||||
struct std::less<CopiedString>
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()( const CopiedString& x, const CopiedString& y ) const {
|
||||
return string_less( x.c_str(), y.c_str() );
|
||||
}
|
||||
bool operator()( const CopiedString& x, const char *y ) const {
|
||||
return string_less( x.c_str(), y );
|
||||
}
|
||||
bool operator()( const char *x, const CopiedString& y ) const {
|
||||
return string_less( x, y.c_str() );
|
||||
}
|
||||
bool operator()( const CopiedString& string, const StringRange range ) const {
|
||||
return string_compare_n( string.c_str(), range.data(), range.size() ) < 0;
|
||||
}
|
||||
bool operator()( const StringRange range, const CopiedString& string ) const {
|
||||
return string_compare_n( string.c_str(), range.data(), range.size() ) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class StringEqualNoCase
|
||||
{
|
||||
public:
|
||||
@@ -618,9 +650,23 @@ public:
|
||||
|
||||
struct StringLessNoCase
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()( const CopiedString& x, const CopiedString& y ) const {
|
||||
return string_less_nocase( x.c_str(), y.c_str() );
|
||||
}
|
||||
bool operator()( const CopiedString& x, const char *y ) const {
|
||||
return string_less_nocase( x.c_str(), y );
|
||||
}
|
||||
bool operator()( const char *x, const CopiedString& y ) const {
|
||||
return string_less_nocase( x, y.c_str() );
|
||||
}
|
||||
bool operator()( const CopiedString& string, const StringRange range ) const {
|
||||
return string_compare_nocase_n( string.c_str(), range.data(), range.size() ) < 0;
|
||||
}
|
||||
bool operator()( const StringRange range, const CopiedString& string ) const {
|
||||
return string_compare_nocase_n( string.c_str(), range.data(), range.size() ) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct RawStringEqual
|
||||
|
||||
Reference in New Issue
Block a user