mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 22:53:43 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -4,44 +4,43 @@
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class T, class TPtr> class array_impl
|
||||
template <class T, class TPtr>
|
||||
class array_impl
|
||||
{
|
||||
protected:
|
||||
TPtr m_p;
|
||||
size_t m_size;
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T const & const_reference;
|
||||
typedef T & reference;
|
||||
|
||||
array_impl(TPtr p, size_t sz) : m_p(p), m_size(sz) {}
|
||||
|
||||
T const & operator[](size_t i) const
|
||||
{
|
||||
protected:
|
||||
TPtr m_p;
|
||||
size_t m_size;
|
||||
ASSERT_LESS(i, m_size, ());
|
||||
return m_p[i];
|
||||
}
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T const & const_reference;
|
||||
typedef T & reference;
|
||||
T const & back() const
|
||||
{
|
||||
ASSERT_GREATER(m_size, 0, ());
|
||||
return m_p[m_size - 1];
|
||||
}
|
||||
|
||||
array_impl(TPtr p, size_t sz) : m_p(p), m_size(sz) {}
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
T const & operator[](size_t i) const
|
||||
{
|
||||
ASSERT_LESS ( i, m_size, () );
|
||||
return m_p[i];
|
||||
}
|
||||
bool empty() const { return (m_size == 0); }
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
T const & back() const
|
||||
{
|
||||
ASSERT_GREATER ( m_size, 0, () );
|
||||
return m_p[m_size-1];
|
||||
}
|
||||
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
bool empty() const { return (m_size == 0); }
|
||||
};
|
||||
}
|
||||
|
||||
template <class T> class array_read : public detail::array_impl<T, T const *>
|
||||
template <class T>
|
||||
class array_read : public detail::array_impl<T, T const *>
|
||||
{
|
||||
public:
|
||||
array_read(T const * p, size_t sz)
|
||||
: detail::array_impl<T, T const *>(p, sz)
|
||||
{
|
||||
}
|
||||
array_read(T const * p, size_t sz) : detail::array_impl<T, T const *>(p, sz) {}
|
||||
};
|
||||
|
||||
template <class TCont>
|
||||
@@ -50,21 +49,23 @@ array_read<typename TCont::value_type> make_read_adapter(TCont const & cont)
|
||||
return array_read<typename TCont::value_type>(cont.empty() ? 0 : &cont[0], cont.size());
|
||||
}
|
||||
|
||||
template <class T> class array_write : public detail::array_impl<T, T *>
|
||||
template <class T>
|
||||
class array_write : public detail::array_impl<T, T *>
|
||||
{
|
||||
size_t m_capacity;
|
||||
|
||||
typedef detail::array_impl<T, T *> base_t;
|
||||
|
||||
public:
|
||||
template <class TCont> explicit array_write(TCont & cont)
|
||||
: detail::array_impl<T, T *>(cont.empty() ? 0 : &cont[0], 0), m_capacity(cont.size())
|
||||
{
|
||||
}
|
||||
template <class TCont>
|
||||
explicit array_write(TCont & cont)
|
||||
: detail::array_impl<T, T *>(cont.empty() ? 0 : &cont[0], 0)
|
||||
, m_capacity(cont.size())
|
||||
{}
|
||||
|
||||
void push_back(T const & t)
|
||||
{
|
||||
ASSERT_LESS ( base_t::m_size, m_capacity, () );
|
||||
ASSERT_LESS(base_t::m_size, m_capacity, ());
|
||||
base_t::m_p[base_t::m_size++] = t;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,55 +32,117 @@ AssertFailedFn SetAssertFunction(AssertFailedFn fn);
|
||||
ASSERT_CRASH();
|
||||
|
||||
// TODO: Evaluate X only once in CHECK().
|
||||
#define CHECK(X, msg) do { if (X) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X")", ::base::Message msg));} } while(false)
|
||||
#define CHECK(X, msg) \
|
||||
do \
|
||||
{ \
|
||||
if (X) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X ")", ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_EQUAL(X, Y, msg) do { if ((X) == (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" == "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_EQUAL(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) == (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " == " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_NOT_EQUAL(X, Y, msg) do { if ((X) != (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" != "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_NOT_EQUAL(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) != (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " != " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_LESS(X, Y, msg) do { if ((X) < (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" < "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_LESS(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) < (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " < " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_LESS_OR_EQUAL(X, Y, msg) do { if ((X) <= (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" <= "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_LESS_OR_EQUAL(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) <= (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " <= " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_GREATER(X, Y, msg) do { if ((X) > (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" > "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_GREATER(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) > (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " > " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_GREATER_OR_EQUAL(X, Y, msg) do { if ((X) >= (Y)) {} else { \
|
||||
ASSERT_FAIL(::base::Message("CHECK("#X" >= "#Y")", \
|
||||
::base::Message(X, Y), \
|
||||
::base::Message msg));} } while (false)
|
||||
#define CHECK_GREATER_OR_EQUAL(X, Y, msg) \
|
||||
do \
|
||||
{ \
|
||||
if ((X) >= (Y)) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message("CHECK(" #X " >= " #Y ")", ::base::Message(X, Y), ::base::Message msg)); \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#define CHECK_OR_CALL(fail, call, X, msg) do { if (X) {} else { \
|
||||
if (fail) {\
|
||||
ASSERT_FAIL(::base::Message(::base::Message("CHECK("#X")"), \
|
||||
::base::Message msg)); \
|
||||
} else { \
|
||||
call(); \
|
||||
} } } while (false)
|
||||
#define CHECK_OR_CALL(fail, call, X, msg) \
|
||||
do \
|
||||
{ \
|
||||
if (X) \
|
||||
{} \
|
||||
else \
|
||||
{ \
|
||||
if (fail) \
|
||||
{ \
|
||||
ASSERT_FAIL(::base::Message(::base::Message("CHECK(" #X ")"), ::base::Message msg)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
call(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ASSERT(X, msg) CHECK(X, msg)
|
||||
#define VERIFY(X, msg) CHECK(X, msg)
|
||||
#define ASSERT_EQUAL(X, Y, msg) CHECK_EQUAL(X, Y, msg)
|
||||
#define ASSERT_NOT_EQUAL(X, Y, msg) CHECK_NOT_EQUAL(X, Y, msg)
|
||||
#define ASSERT_LESS(X, Y, msg) CHECK_LESS(X, Y, msg)
|
||||
#define ASSERT_LESS_OR_EQUAL(X, Y, msg) CHECK_LESS_OR_EQUAL(X, Y, msg)
|
||||
#define ASSERT_GREATER(X, Y, msg) CHECK_GREATER(X, Y, msg)
|
||||
#define ASSERT(X, msg) CHECK(X, msg)
|
||||
#define VERIFY(X, msg) CHECK(X, msg)
|
||||
#define ASSERT_EQUAL(X, Y, msg) CHECK_EQUAL(X, Y, msg)
|
||||
#define ASSERT_NOT_EQUAL(X, Y, msg) CHECK_NOT_EQUAL(X, Y, msg)
|
||||
#define ASSERT_LESS(X, Y, msg) CHECK_LESS(X, Y, msg)
|
||||
#define ASSERT_LESS_OR_EQUAL(X, Y, msg) CHECK_LESS_OR_EQUAL(X, Y, msg)
|
||||
#define ASSERT_GREATER(X, Y, msg) CHECK_GREATER(X, Y, msg)
|
||||
#define ASSERT_GREATER_OR_EQUAL(X, Y, msg) CHECK_GREATER_OR_EQUAL(X, Y, msg)
|
||||
#else
|
||||
#define ASSERT(X, msg)
|
||||
@@ -100,6 +162,7 @@ AssertFailedFn SetAssertFunction(AssertFailedFn fn);
|
||||
{ \
|
||||
CHECK(false, ("Unreachable statement.")); \
|
||||
std::abort(); \
|
||||
} while (false)
|
||||
} \
|
||||
while (false)
|
||||
|
||||
// NOLINTEND(misc-static-assert)
|
||||
|
||||
@@ -13,8 +13,9 @@ bool OnAssertFailedDefault(SrcPoint const & srcPoint, std::string const & msg)
|
||||
auto & logger = LogHelper::Instance();
|
||||
|
||||
std::cerr << '(' << logger.GetThreadID() << ") ASSERT FAILED" << '\n'
|
||||
<< srcPoint.FileName() << ':' << srcPoint.Line() << '\n' << msg
|
||||
<< std::endl << std::flush;
|
||||
<< srcPoint.FileName() << ':' << srcPoint.Line() << '\n'
|
||||
<< msg << std::endl
|
||||
<< std::flush;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@ static_assert(MY_DEBUG_DEFINED ^ MY_RELEASE_DEFINED, "Either Debug or Release sh
|
||||
|
||||
// #define DEBUG macro, which should be used with #ifdef.
|
||||
#if !MY_RELEASE_DEFINED
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// #include "internal/debug_new.hpp"
|
||||
// TODO: STL debug mode.
|
||||
#define IF_DEBUG_ELSE(a, b) (a)
|
||||
#define IF_DEBUG_ELSE(a, b) (a)
|
||||
#else
|
||||
#define IF_DEBUG_ELSE(a, b) (b)
|
||||
#define IF_DEBUG_ELSE(a, b) (b)
|
||||
#endif
|
||||
|
||||
// platform macroses
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "base/exception.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
|
||||
UNIT_TEST(Assert_Smoke)
|
||||
{
|
||||
int x = 5;
|
||||
@@ -12,17 +11,17 @@ UNIT_TEST(Assert_Smoke)
|
||||
#ifdef RELEASE
|
||||
UNUSED_VALUE(x);
|
||||
#endif
|
||||
ASSERT_EQUAL ( x, 5, () );
|
||||
ASSERT_NOT_EQUAL ( x, 6, () );
|
||||
//ASSERT_EQUAL ( x, 666, ("Skip this to continue test") );
|
||||
ASSERT_EQUAL(x, 5, ());
|
||||
ASSERT_NOT_EQUAL(x, 6, ());
|
||||
// ASSERT_EQUAL ( x, 666, ("Skip this to continue test") );
|
||||
}
|
||||
|
||||
UNIT_TEST(Check_Smoke)
|
||||
{
|
||||
int x = 5;
|
||||
CHECK_EQUAL ( x, 5, () );
|
||||
CHECK_NOT_EQUAL ( x, 6, () );
|
||||
//CHECK_EQUAL ( x, 666, ("Skip this to continue test") );
|
||||
CHECK_EQUAL(x, 5, ());
|
||||
CHECK_NOT_EQUAL(x, 6, ());
|
||||
// CHECK_EQUAL ( x, 666, ("Skip this to continue test") );
|
||||
}
|
||||
|
||||
UNIT_TEST(Exception_Formatting)
|
||||
|
||||
@@ -44,12 +44,10 @@ void Smoke()
|
||||
}
|
||||
|
||||
template <template <typename, typename> class Beam>
|
||||
void Benchmark(string const & beamType, uint64_t const numResets, size_t const capacity,
|
||||
uint64_t const numEvents)
|
||||
void Benchmark(string const & beamType, uint64_t const numResets, size_t const capacity, uint64_t const numEvents)
|
||||
{
|
||||
base::Timer timer;
|
||||
SCOPE_GUARD(timerGuard,
|
||||
[&] { LOG(LINFO, ("type:", beamType, "\ttime passed:", timer.ElapsedSeconds())); });
|
||||
SCOPE_GUARD(timerGuard, [&] { LOG(LINFO, ("type:", beamType, "\ttime passed:", timer.ElapsedSeconds())); });
|
||||
|
||||
CHECK_LESS_OR_EQUAL(capacity, numEvents, ());
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ UNIT_TEST(BitwiseMerge)
|
||||
TEST_EQUAL(bits::BitwiseMerge(1, 3), 11, ());
|
||||
TEST_EQUAL(bits::BitwiseMerge(uint32_t{1} << 31, uint32_t{1} << 31), uint64_t{3} << 62, ());
|
||||
|
||||
auto bitwiseMergeSlow = [](uint32_t x, uint32_t y) -> uint64_t {
|
||||
auto bitwiseMergeSlow = [](uint32_t x, uint32_t y) -> uint64_t
|
||||
{
|
||||
uint64_t result = 0;
|
||||
for (uint32_t i = 0; i < 32; ++i)
|
||||
{
|
||||
@@ -46,34 +47,32 @@ UNIT_TEST(BitwiseMerge)
|
||||
};
|
||||
|
||||
for (uint32_t x = 0; x < 16; ++x)
|
||||
{
|
||||
for (uint32_t y = 0; y < 16; ++y)
|
||||
TEST_EQUAL(bits::BitwiseMerge(x, y), bitwiseMergeSlow(x, y), (x, y));
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(ZigZagEncode)
|
||||
{
|
||||
TEST_EQUAL(bits::ZigZagEncode(0), 0, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(0), 0, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(-1), 1, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(1), 2, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(1), 2, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(-2), 3, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(2), 4, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(127), 254, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(2), 4, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(127), 254, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(-128), 255, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(128), 256, ());
|
||||
TEST_EQUAL(bits::ZigZagEncode(128), 256, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(ZigZagDecode)
|
||||
{
|
||||
TEST_EQUAL(bits::ZigZagDecode(0U), 0, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(1U), -1, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(2U), 1, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(2U), 1, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(3U), -2, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(4U), 2, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(254U), 127, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(4U), 2, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(254U), 127, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(255U), -128, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(256U), 128, ());
|
||||
TEST_EQUAL(bits::ZigZagDecode(256U), 128, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(NumHiZeroBits32)
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
namespace buffer_vector_test
|
||||
{
|
||||
template <class TCont>
|
||||
void CheckVector(TCont & cont, size_t count)
|
||||
{
|
||||
TEST_EQUAL ( cont.size(), count, () );
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
TEST_EQUAL ( cont[i], i, () );
|
||||
}
|
||||
template <class TCont>
|
||||
void CheckVector(TCont & cont, size_t count)
|
||||
{
|
||||
TEST_EQUAL(cont.size(), count, ());
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
TEST_EQUAL(cont[i], i, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(BufferVector_PushBackAndRealloc)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ UNIT_TEST(BufferVector_Bounds)
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
{
|
||||
v.push_back(i);
|
||||
CheckVector(v, i+1);
|
||||
CheckVector(v, i + 1);
|
||||
}
|
||||
|
||||
v.resize(2);
|
||||
@@ -91,8 +91,8 @@ UNIT_TEST(BufferVector_Swap)
|
||||
value_t const * d2 = v2.data();
|
||||
|
||||
swap(v1, v2);
|
||||
TEST_EQUAL ( d1, v2.data(), () );
|
||||
TEST_EQUAL ( d2, v1.data(), () );
|
||||
TEST_EQUAL(d1, v2.data(), ());
|
||||
TEST_EQUAL(d2, v1.data(), ());
|
||||
|
||||
// check swap in resized data
|
||||
{
|
||||
@@ -102,13 +102,13 @@ UNIT_TEST(BufferVector_Swap)
|
||||
|
||||
// resize from 5 to 1 => v[0] will stay at the same place
|
||||
v1.resize(1);
|
||||
TEST_EQUAL ( v1[0].size(), 1, () );
|
||||
TEST_EQUAL ( v1[0][0], 666, () );
|
||||
TEST_EQUAL ( dd1, v1[0].data(), () );
|
||||
TEST_EQUAL(v1[0].size(), 1, ());
|
||||
TEST_EQUAL(v1[0][0], 666, ());
|
||||
TEST_EQUAL(dd1, v1[0].data(), ());
|
||||
|
||||
v1.resize(7);
|
||||
TEST_EQUAL ( v1[0].size(), 1, () );
|
||||
TEST_EQUAL ( v1[0][0], 666, () );
|
||||
TEST_EQUAL(v1[0].size(), 1, ());
|
||||
TEST_EQUAL(v1[0][0], 666, ());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -120,12 +120,12 @@ UNIT_TEST(BufferVector_Swap)
|
||||
auto const * dd2 = v2[0].data();
|
||||
|
||||
v2.resize(1);
|
||||
TEST_EQUAL ( v2[0].size(), 5, () );
|
||||
TEST_EQUAL ( dd2, v2[0].data(), () );
|
||||
TEST_EQUAL(v2[0].size(), 5, ());
|
||||
TEST_EQUAL(dd2, v2[0].data(), ());
|
||||
|
||||
v1.resize(7);
|
||||
TEST_EQUAL ( v2[0].size(), 5, () );
|
||||
TEST_EQUAL ( dd2, v2[0].data(), () );
|
||||
TEST_EQUAL(v2[0].size(), 5, ());
|
||||
TEST_EQUAL(dd2, v2[0].data(), ());
|
||||
}
|
||||
|
||||
// check resize from static to dynamic buffer
|
||||
@@ -140,8 +140,8 @@ UNIT_TEST(BufferVector_Swap)
|
||||
|
||||
// resize from static to dynamic buffer => v3[0] will stay at the same place
|
||||
v1.resize(7);
|
||||
TEST_EQUAL ( v3[0].size(), 5, () );
|
||||
TEST_EQUAL ( dd3, v3[0].data(), () );
|
||||
TEST_EQUAL(v3[0].size(), 5, ());
|
||||
TEST_EQUAL(dd3, v3[0].data(), ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ UNIT_TEST(BufferVector_PopBack)
|
||||
TEST(!v.empty(), (len, i));
|
||||
TEST_EQUAL(v.size(), i, ());
|
||||
TEST_EQUAL(v.front(), 0, ());
|
||||
TEST_EQUAL(v.back(), i-1, ());
|
||||
TEST_EQUAL(v.back(), i - 1, ());
|
||||
v.pop_back();
|
||||
TEST_EQUAL(v.size(), i-1, ());
|
||||
TEST_EQUAL(v.size(), i - 1, ());
|
||||
}
|
||||
TEST(v.empty(), ());
|
||||
}
|
||||
@@ -266,16 +266,12 @@ UNIT_TEST(BufferVector_Assign)
|
||||
int const arr5[] = {1, 2, 3, 4, 5};
|
||||
buffer_vector<int, 5> v(&arr5[0], &arr5[0] + ARRAY_SIZE(arr5));
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr5); ++i)
|
||||
{
|
||||
TEST_EQUAL(arr5[i], v[i], ());
|
||||
}
|
||||
|
||||
int const arr10[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
int const arr10[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
v.assign(&arr10[0], &arr10[0] + ARRAY_SIZE(arr10));
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr10); ++i)
|
||||
{
|
||||
TEST_EQUAL(arr10[i], v[i], ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(BufferVector_Equality)
|
||||
@@ -337,7 +333,7 @@ void TestVector(VectorT const & v, size_t sz)
|
||||
TEST_EQUAL(v[i].m_s, strings::to_string(i), ());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(BufferVector_Move)
|
||||
{
|
||||
@@ -345,7 +341,7 @@ UNIT_TEST(BufferVector_Move)
|
||||
TestVector(v1, 2);
|
||||
|
||||
// Make intermediate array to avoid warning (moving to itself).
|
||||
std::array<VectorT *, 2> arr = { &v1, &v1 };
|
||||
std::array<VectorT *, 2> arr = {&v1, &v1};
|
||||
*arr[0] = std::move(*arr[1]);
|
||||
TestVector(v1, 2);
|
||||
|
||||
@@ -366,18 +362,18 @@ UNIT_TEST(BufferVector_EraseIf)
|
||||
buffer_vector<int, 2> v;
|
||||
v.push_back(1);
|
||||
v.push_back(2);
|
||||
v.erase_if([] (int x) { return x == 1; });
|
||||
v.erase_if([](int x) { return x == 1; });
|
||||
TEST_EQUAL(v.size(), 1, ());
|
||||
TEST_EQUAL(v[0], 2, ());
|
||||
|
||||
v.push_back(3);
|
||||
v.push_back(4);
|
||||
v.erase_if([] (int x) { return x == 3; });
|
||||
v.erase_if([](int x) { return x == 3; });
|
||||
TEST_EQUAL(v.size(), 2, ());
|
||||
TEST_EQUAL(v[0], 2, ());
|
||||
TEST_EQUAL(v[1], 4, ());
|
||||
|
||||
v.erase_if([] (int) { return true; });
|
||||
v.erase_if([](int) { return true; });
|
||||
TEST_EQUAL(v.size(), 0, ());
|
||||
}
|
||||
|
||||
@@ -405,8 +401,8 @@ UNIT_TEST(BufferVector_Erase)
|
||||
|
||||
while (v1.size() > 1)
|
||||
{
|
||||
v1.erase(v1.begin() + v1.size() / 3, v1.begin() + 2 * v1.size () / 3);
|
||||
v2.erase(v2.begin() + v2.size() / 3, v2.begin() + 2 * v2.size () / 3);
|
||||
v1.erase(v1.begin() + v1.size() / 3, v1.begin() + 2 * v1.size() / 3);
|
||||
v2.erase(v2.begin() + v2.size() / 3, v2.begin() + 2 * v2.size() / 3);
|
||||
|
||||
TEST_EQUAL(v1.size(), v2.size(), ());
|
||||
for (size_t i = 0; i < v1.size(); ++i)
|
||||
|
||||
@@ -15,10 +15,7 @@ class SimpleFunctor
|
||||
public:
|
||||
SimpleFunctor() {}
|
||||
|
||||
void operator() (char c)
|
||||
{
|
||||
m_v.push_back(c);
|
||||
}
|
||||
void operator()(char c) { m_v.push_back(c); }
|
||||
|
||||
std::vector<char> m_v;
|
||||
|
||||
@@ -34,8 +31,8 @@ public:
|
||||
|
||||
SimpleMovableFunctor(SimpleMovableFunctor && other)
|
||||
{
|
||||
m_v = other.m_v;
|
||||
other.m_v = nullptr;
|
||||
m_v = other.m_v;
|
||||
other.m_v = nullptr;
|
||||
}
|
||||
|
||||
SimpleMovableFunctor & operator=(SimpleMovableFunctor && other)
|
||||
@@ -45,10 +42,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void operator() (char c)
|
||||
{
|
||||
m_v->push_back(c);
|
||||
}
|
||||
void operator()(char c) { m_v->push_back(c); }
|
||||
|
||||
private:
|
||||
std::vector<char> * m_v;
|
||||
@@ -61,8 +55,8 @@ double constexpr kEpsilon = 1e-6;
|
||||
|
||||
UNIT_TEST(CacheSmoke)
|
||||
{
|
||||
char const s [] = "1123212434445";
|
||||
char const isNew [] = "1011???1??001";
|
||||
char const s[] = "1123212434445";
|
||||
char const isNew[] = "1011???1??001";
|
||||
size_t const n = ARRAY_SIZE(s) - 1;
|
||||
for (int logCacheSize = 2; logCacheSize < 6; ++logCacheSize)
|
||||
{
|
||||
@@ -72,24 +66,18 @@ UNIT_TEST(CacheSmoke)
|
||||
bool found = false;
|
||||
char & c = cache.Find(s[i], found);
|
||||
if (isNew[i] != '?')
|
||||
{
|
||||
TEST_EQUAL(found, isNew[i] == '0', (i, s[i]));
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
TEST_EQUAL(c, s[i], (i));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = s[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(CacheSmoke_0)
|
||||
{
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
bool found = true;
|
||||
cache.Find(0, found);
|
||||
TEST(!found, ());
|
||||
@@ -100,23 +88,23 @@ UNIT_TEST(CacheSmoke_0)
|
||||
|
||||
UNIT_TEST(CacheSmoke_1)
|
||||
{
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
SimpleFunctor f;
|
||||
cache.ForEachValue(f); // f passed by reference
|
||||
cache.ForEachValue(f); // f passed by reference
|
||||
TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(CacheSmoke_2)
|
||||
{
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::Cache<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
SimpleFunctor f;
|
||||
cache.ForEachValue(std::ref(f)); // f passed by reference
|
||||
cache.ForEachValue(std::ref(f)); // f passed by reference
|
||||
TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(CacheSmoke_3)
|
||||
{
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
|
||||
// 0 access, cache miss is 0
|
||||
TEST(AlmostEqualAbs(0.0, cache.GetCacheMiss(), kEpsilon), ());
|
||||
@@ -137,7 +125,7 @@ UNIT_TEST(CacheSmoke_3)
|
||||
cache.Find(2, found);
|
||||
TEST(!found, ());
|
||||
// 3 access, 2 miss, cache miss = 2/3 = 0.6(6)
|
||||
TEST(AlmostEqualAbs(2.0/3.0, cache.GetCacheMiss(), kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(2.0 / 3.0, cache.GetCacheMiss(), kEpsilon), ());
|
||||
|
||||
cache.Reset();
|
||||
|
||||
@@ -147,23 +135,23 @@ UNIT_TEST(CacheSmoke_3)
|
||||
|
||||
UNIT_TEST(CacheSmoke_4)
|
||||
{
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
SimpleFunctor f;
|
||||
cache.ForEachValue(f); // f passed by reference
|
||||
cache.ForEachValue(f); // f passed by reference
|
||||
TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(CacheSmoke_5)
|
||||
{
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
SimpleFunctor f;
|
||||
cache.ForEachValue(std::ref(f)); // f passed by reference
|
||||
cache.ForEachValue(std::ref(f)); // f passed by reference
|
||||
TEST_EQUAL(f.m_v, std::vector<char>(8, 0), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(CacheSmoke_6)
|
||||
{
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
base::CacheWithStat<uint32_t, char> cache(3); // it contains 2^3=8 elements
|
||||
std::vector<char> v;
|
||||
cache.ForEachValue(SimpleMovableFunctor(&v));
|
||||
TEST_EQUAL(v, std::vector<char>(8, 0), ());
|
||||
|
||||
@@ -21,7 +21,8 @@ UNIT_TEST(Cancellable_Smoke)
|
||||
|
||||
double x = 0.123;
|
||||
|
||||
auto const fn = [&] {
|
||||
auto const fn = [&]
|
||||
{
|
||||
for (size_t it = 0;; it++)
|
||||
{
|
||||
if (it > 100 && cancellable.IsCancelled())
|
||||
@@ -54,7 +55,8 @@ UNIT_TEST(Cancellable_Deadline)
|
||||
|
||||
double x = 0.123;
|
||||
|
||||
auto const fn = [&] {
|
||||
auto const fn = [&]
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (cancellable.IsCancelled())
|
||||
|
||||
@@ -27,7 +27,7 @@ class ClusteringMapAdapter
|
||||
public:
|
||||
struct Cluster
|
||||
{
|
||||
Cluster(Key const & key, Value const & value): m_keys({key}), m_values({value}) {}
|
||||
Cluster(Key const & key, Value const & value) : m_keys({key}), m_values({value}) {}
|
||||
|
||||
Cluster(vector<Key> const & keys, vector<Value> const & values) : m_keys(keys), m_values(values)
|
||||
{
|
||||
@@ -42,10 +42,7 @@ public:
|
||||
return m_values < rhs.m_values;
|
||||
}
|
||||
|
||||
bool operator==(Cluster const & rhs) const
|
||||
{
|
||||
return m_keys == rhs.m_keys && m_values == rhs.m_values;
|
||||
}
|
||||
bool operator==(Cluster const & rhs) const { return m_keys == rhs.m_keys && m_values == rhs.m_values; }
|
||||
|
||||
friend string DebugPrint(Cluster const & cluster)
|
||||
{
|
||||
@@ -75,9 +72,8 @@ public:
|
||||
{
|
||||
vector<Cluster> clusters;
|
||||
|
||||
m_m.ForEachCluster([&](vector<Key> const & keys, vector<Value> const & values) {
|
||||
clusters.emplace_back(keys, values);
|
||||
});
|
||||
m_m.ForEachCluster([&](vector<Key> const & keys, vector<Value> const & values)
|
||||
{ clusters.emplace_back(keys, values); });
|
||||
sort(clusters.begin(), clusters.end());
|
||||
return clusters;
|
||||
}
|
||||
@@ -151,16 +147,15 @@ UNIT_TEST(ClusteringMap_ForEach)
|
||||
m.Append(4, "gamma");
|
||||
|
||||
{
|
||||
vector<Cluster> const expected = {{Cluster{0, "Hello"}, Cluster{1, "World!"},
|
||||
Cluster{2, "alpha"}, Cluster{3, "beta"},
|
||||
Cluster{4, "gamma"}}};
|
||||
vector<Cluster> const expected = {
|
||||
{Cluster{0, "Hello"}, Cluster{1, "World!"}, Cluster{2, "alpha"}, Cluster{3, "beta"}, Cluster{4, "gamma"}}};
|
||||
TEST_EQUAL(expected, m.Clusters(), ());
|
||||
}
|
||||
|
||||
m.Union(0, 1);
|
||||
{
|
||||
vector<Cluster> const expected = {{Cluster{{0, 1}, {"Hello", "World!"}}, Cluster{2, "alpha"},
|
||||
Cluster{3, "beta"}, Cluster{4, "gamma"}}};
|
||||
vector<Cluster> const expected = {
|
||||
{Cluster{{0, 1}, {"Hello", "World!"}}, Cluster{2, "alpha"}, Cluster{3, "beta"}, Cluster{4, "gamma"}}};
|
||||
TEST_EQUAL(expected, m.Clusters(), ());
|
||||
}
|
||||
|
||||
@@ -174,8 +169,7 @@ UNIT_TEST(ClusteringMap_ForEach)
|
||||
|
||||
m.Union(0, 3);
|
||||
{
|
||||
vector<Cluster> const expected = {
|
||||
{Cluster{{0, 1, 2, 3, 4}, {"Hello", "World!", "alpha", "beta", "gamma"}}}};
|
||||
vector<Cluster> const expected = {{Cluster{{0, 1, 2, 3, 4}, {"Hello", "World!", "alpha", "beta", "gamma"}}}};
|
||||
TEST_EQUAL(expected, m.Clusters(), ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,11 @@
|
||||
|
||||
UNIT_TEST(collection_cast)
|
||||
{
|
||||
TEST_EQUAL((std::list<int>{1, 2, 3, 4, }), base::collection_cast<std::list>(std::vector<int> {1, 2, 3, 4}), ());
|
||||
TEST_EQUAL((std::list<int>{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
}),
|
||||
base::collection_cast<std::list>(std::vector<int>{1, 2, 3, 4}), ());
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ UNIT_TEST(ControlFlow_Smoke)
|
||||
{
|
||||
Repeater repeater(10);
|
||||
uint32_t c = 0;
|
||||
repeater.ForEach([&c] {
|
||||
repeater.ForEach([&c]
|
||||
{
|
||||
++c;
|
||||
if (c == 5)
|
||||
return ControlFlow::Break;
|
||||
|
||||
@@ -7,28 +7,66 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
int FuncDoesNotThrow() noexcept { return 1; }
|
||||
int FuncThrowsRootException() { throw RootException("RootException", "RootException"); }
|
||||
int FuncThrowsException() { throw std::exception(); }
|
||||
int FuncThrowsRuntimeError() { throw std::runtime_error("runtime_error"); }
|
||||
int FuncThrowsNumber() { throw 1; };
|
||||
int FuncDoesNotThrow() noexcept
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int FuncThrowsRootException()
|
||||
{
|
||||
throw RootException("RootException", "RootException");
|
||||
}
|
||||
int FuncThrowsException()
|
||||
{
|
||||
throw std::exception();
|
||||
}
|
||||
int FuncThrowsRuntimeError()
|
||||
{
|
||||
throw std::runtime_error("runtime_error");
|
||||
}
|
||||
int FuncThrowsNumber()
|
||||
{
|
||||
throw 1;
|
||||
}
|
||||
|
||||
int FuncDoesNotThrowArg(int) noexcept { return 1; }
|
||||
int FuncThrowsRootExceptionArg(int) { throw RootException("RootException", "RootException"); }
|
||||
int FuncThrowsExceptionArg(int) { throw std::exception(); }
|
||||
int FuncThrowsNumberArg(int) { throw 1; };
|
||||
int FuncDoesNotThrowArg(int) noexcept
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int FuncThrowsRootExceptionArg(int)
|
||||
{
|
||||
throw RootException("RootException", "RootException");
|
||||
}
|
||||
int FuncThrowsExceptionArg(int)
|
||||
{
|
||||
throw std::exception();
|
||||
}
|
||||
int FuncThrowsNumberArg(int)
|
||||
{
|
||||
throw 1;
|
||||
}
|
||||
|
||||
void FuncDoesNotThrowVoid(int) noexcept { return; }
|
||||
void FuncThrowsRootExceptionVoid(int) { throw RootException("RootException", "RootException"); }
|
||||
void FuncThrowsExceptionVoid() { throw std::exception(); }
|
||||
void FuncThrowsNumberVoid() { throw 1; };
|
||||
void FuncDoesNotThrowVoid(int) noexcept
|
||||
{
|
||||
return;
|
||||
}
|
||||
void FuncThrowsRootExceptionVoid(int)
|
||||
{
|
||||
throw RootException("RootException", "RootException");
|
||||
}
|
||||
void FuncThrowsExceptionVoid()
|
||||
{
|
||||
throw std::exception();
|
||||
}
|
||||
void FuncThrowsNumberVoid()
|
||||
{
|
||||
throw 1;
|
||||
}
|
||||
|
||||
std::string const & ReturnsByRef(std::string const & str)
|
||||
{
|
||||
bool exception = true;
|
||||
return ExceptionCatcher(
|
||||
"ReturnsByRef().", exception,
|
||||
[](std::string const & str) -> std::string const & { return str; }, str);
|
||||
return ExceptionCatcher("ReturnsByRef().", exception,
|
||||
[](std::string const & str) -> std::string const & { return str; }, str);
|
||||
}
|
||||
|
||||
UNIT_TEST(ExceptionCatcher_FunctionsWithoutArgs)
|
||||
@@ -63,43 +101,35 @@ UNIT_TEST(ExceptionCatcher_LambdasReturnInt)
|
||||
{
|
||||
bool exception = false;
|
||||
size_t callCount = 0;
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) {
|
||||
++callCount;
|
||||
return 1;
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int)
|
||||
{
|
||||
++callCount;
|
||||
return 1;
|
||||
}, 7);
|
||||
TEST(!exception, ());
|
||||
TEST_EQUAL(callCount, 1, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) -> int {
|
||||
++callCount;
|
||||
throw RootException("RootException", "RootException");
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int) -> int
|
||||
{
|
||||
++callCount;
|
||||
throw RootException("RootException", "RootException");
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 2, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) -> int {
|
||||
++callCount;
|
||||
throw std::exception();
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int) -> int
|
||||
{
|
||||
++callCount;
|
||||
throw std::exception();
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 3, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) -> int {
|
||||
++callCount;
|
||||
throw 1;
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int) -> int
|
||||
{
|
||||
++callCount;
|
||||
throw 1;
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 4, ());
|
||||
}
|
||||
@@ -108,42 +138,31 @@ UNIT_TEST(ExceptionCatcher_LambdasReturnVoid)
|
||||
{
|
||||
bool exception = false;
|
||||
size_t callCount = 0;
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) {
|
||||
++callCount;
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int) { ++callCount; }, 7);
|
||||
TEST(!exception, ());
|
||||
TEST_EQUAL(callCount, 1, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) {
|
||||
++callCount;
|
||||
throw RootException("RootException", "RootException");
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int)
|
||||
{
|
||||
++callCount;
|
||||
throw RootException("RootException", "RootException");
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 2, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) {
|
||||
++callCount;
|
||||
throw std::exception();
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int)
|
||||
{
|
||||
++callCount;
|
||||
throw std::exception();
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 3, ());
|
||||
|
||||
ExceptionCatcher(
|
||||
"Lambda", exception,
|
||||
[&callCount](int) {
|
||||
++callCount;
|
||||
throw 1;
|
||||
},
|
||||
7);
|
||||
ExceptionCatcher("Lambda", exception, [&callCount](int)
|
||||
{
|
||||
++callCount;
|
||||
throw 1;
|
||||
}, 7);
|
||||
TEST(exception, ());
|
||||
TEST_EQUAL(callCount, 4, ());
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ template <typename Key, typename Value>
|
||||
class FifoCacheTest
|
||||
{
|
||||
public:
|
||||
FifoCacheTest(size_t capacity, typename FifoCache<Key, Value>::Loader const & loader)
|
||||
: m_cache(capacity, loader)
|
||||
{
|
||||
}
|
||||
FifoCacheTest(size_t capacity, typename FifoCache<Key, Value>::Loader const & loader) : m_cache(capacity, loader) {}
|
||||
|
||||
Value const & GetValue(Key const & key) { return m_cache.GetValue(key); }
|
||||
unordered_map<Key, Value> const & GetMap() const { return m_cache.m_map; }
|
||||
@@ -93,7 +90,8 @@ UNIT_TEST(FifoCache_LoaderCalls)
|
||||
using Key = int;
|
||||
using Value = int;
|
||||
bool shouldLoadBeCalled = true;
|
||||
auto loader = [&shouldLoadBeCalled](Key k, Value & v) {
|
||||
auto loader = [&shouldLoadBeCalled](Key k, Value & v)
|
||||
{
|
||||
TEST(shouldLoadBeCalled, ());
|
||||
v = k;
|
||||
};
|
||||
|
||||
@@ -83,4 +83,4 @@ UNIT_TEST(FilePath_Join)
|
||||
TEST_EQUAL("../../omim/strings.txt", base::JoinPath("../", "..", "omim/", "strings.txt"), ());
|
||||
}
|
||||
|
||||
#endif // OMIM_OS_WINDOWS
|
||||
#endif // OMIM_OS_WINDOWS
|
||||
|
||||
@@ -50,18 +50,18 @@ UNIT_TEST(GeoObjectId_Print)
|
||||
// https://www.openstreetmap.org/#map=19/54.54438/25.69932
|
||||
|
||||
// Belarus -> Lithuania B L
|
||||
LOG(LINFO, (MakeOsmWay(533044131).GetEncodedId())); // 1 3 0
|
||||
LOG(LINFO, (MakeOsmWay(489294139).GetEncodedId())); // 1 0 1
|
||||
LOG(LINFO, (MakeOsmWay(533044131).GetEncodedId())); // 1 3 0
|
||||
LOG(LINFO, (MakeOsmWay(489294139).GetEncodedId())); // 1 0 1
|
||||
|
||||
// Lithuania -> Belarus
|
||||
LOG(LINFO, (MakeOsmWay(614091318).GetEncodedId())); // 1 5 1 1 5 0
|
||||
LOG(LINFO, (MakeOsmWay(614091318).GetEncodedId())); // 1 5 1 1 5 0
|
||||
LOG(LINFO, (MakeOsmWay(148247387).GetEncodedId()));
|
||||
|
||||
// https://www.openstreetmap.org/#map=19/55.30215/10.86668
|
||||
|
||||
// Denmark_Zealand -> Denmark_Southern Z S
|
||||
LOG(LINFO, (MakeOsmWay(2032610).GetEncodedId())); // 1 6 0 1 6 1
|
||||
LOG(LINFO, (MakeOsmWay(2032610).GetEncodedId())); // 1 6 0 1 6 1
|
||||
|
||||
// Denmark_Southern -> Denmark_Zealand
|
||||
LOG(LINFO, (MakeOsmWay(4360600).GetEncodedId())); // 1 18 1 1 18 0
|
||||
LOG(LINFO, (MakeOsmWay(4360600).GetEncodedId())); // 1 18 1 1 18 0
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ struct Result
|
||||
{
|
||||
Result() = default;
|
||||
Result(Status status, size_t errorsMade = 0, size_t prefixErrorsMade = 0)
|
||||
: m_status(status), m_errorsMade(errorsMade), m_prefixErrorsMade(prefixErrorsMade)
|
||||
{
|
||||
}
|
||||
: m_status(status)
|
||||
, m_errorsMade(errorsMade)
|
||||
, m_prefixErrorsMade(prefixErrorsMade)
|
||||
{}
|
||||
|
||||
bool operator==(Result const & rhs) const
|
||||
{
|
||||
return m_status == rhs.m_status &&
|
||||
(m_errorsMade == rhs.m_errorsMade || m_status == Status::Rejects) &&
|
||||
return m_status == rhs.m_status && (m_errorsMade == rhs.m_errorsMade || m_status == Status::Rejects) &&
|
||||
(m_prefixErrorsMade == rhs.m_prefixErrorsMade || m_status == Status::Rejects);
|
||||
}
|
||||
|
||||
@@ -160,30 +160,24 @@ UNIT_TEST(LevenshteinDFA_ErrorsMade)
|
||||
{
|
||||
LevenshteinDFA dfa("москва", 1 /* prefixSize */, 2 /* maxErrors */);
|
||||
|
||||
TEST_EQUAL(GetResult(dfa, "москва"),
|
||||
Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "москв"),
|
||||
Result(Status::Accepts, 1 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "моск"),
|
||||
Result(Status::Accepts, 2 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "москва"), Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "москв"), Result(Status::Accepts, 1 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "моск"), Result(Status::Accepts, 2 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "мос").m_status, Status::Intermediate, ());
|
||||
TEST_EQUAL(GetResult(dfa, "мос").m_prefixErrorsMade, 0, ());
|
||||
|
||||
TEST_EQUAL(GetResult(dfa, "моксав"),
|
||||
Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "моксав"), Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "максав").m_status, Status::Rejects, ());
|
||||
|
||||
TEST_EQUAL(GetResult(dfa, "мсовк").m_status, Status::Intermediate, ());
|
||||
TEST_EQUAL(GetResult(dfa, "мсовк").m_prefixErrorsMade, 2, ());
|
||||
TEST_EQUAL(GetResult(dfa, "мсовка"),
|
||||
Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "мсовка"), Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "мсовкб").m_status, Status::Rejects, ());
|
||||
}
|
||||
|
||||
{
|
||||
LevenshteinDFA dfa("aa", 0 /* prefixSize */, 2 /* maxErrors */);
|
||||
TEST_EQUAL(GetResult(dfa, "abab"),
|
||||
Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "abab"), Result(Status::Accepts, 2 /* errorsMade */, 2 /* prefixErrorsMade */), ());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -191,8 +185,8 @@ UNIT_TEST(LevenshteinDFA_ErrorsMade)
|
||||
TEST_EQUAL(GetResult(dfa, "misisipi").m_status, Status::Rejects, ());
|
||||
TEST_EQUAL(GetResult(dfa, "mississipp").m_status, Status::Intermediate, ());
|
||||
TEST_EQUAL(GetResult(dfa, "mississipp").m_prefixErrorsMade, 0, ());
|
||||
TEST_EQUAL(GetResult(dfa, "mississippi"),
|
||||
Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "mississippi"), Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */),
|
||||
());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -215,10 +209,8 @@ UNIT_TEST(LevenshteinDFA_ErrorsMade)
|
||||
|
||||
{
|
||||
LevenshteinDFA dfa("кафе", 1 /* prefixSize */, 1 /* maxErrors */);
|
||||
TEST_EQUAL(GetResult(dfa, "кафе"),
|
||||
Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "кафер"),
|
||||
Result(Status::Accepts, 1 /* errorsMade */, 1 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "кафе"), Result(Status::Accepts, 0 /* errorsMade */, 0 /* prefixErrorsMade */), ());
|
||||
TEST_EQUAL(GetResult(dfa, "кафер"), Result(Status::Accepts, 1 /* errorsMade */, 1 /* prefixErrorsMade */), ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +263,7 @@ UNIT_TEST(LevenshteinDFA_PrefixDFASmoke)
|
||||
{
|
||||
result.clear();
|
||||
result.resize(math::PowUint(alphabet.size(), size));
|
||||
for (size_t letterNumber = 0; letterNumber < size; ++letterNumber)
|
||||
for (size_t letterNumber = 0; letterNumber < size; ++letterNumber)
|
||||
{
|
||||
for (size_t i = 0; i < result.size(); ++i)
|
||||
{
|
||||
|
||||
@@ -5,27 +5,24 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void TestLogMessage(base::LogLevel, base::SrcPoint const &, std::string const &)
|
||||
{
|
||||
}
|
||||
void TestLogMessage(base::LogLevel, base::SrcPoint const &, std::string const &) {}
|
||||
|
||||
bool g_SomeFunctionCalled;
|
||||
int SomeFunction()
|
||||
{
|
||||
g_SomeFunctionCalled = true;
|
||||
return 3;
|
||||
}
|
||||
|
||||
bool BoolFunction(bool result, bool & called)
|
||||
{
|
||||
called = true;
|
||||
return result;
|
||||
}
|
||||
bool g_SomeFunctionCalled;
|
||||
int SomeFunction()
|
||||
{
|
||||
g_SomeFunctionCalled = true;
|
||||
return 3;
|
||||
}
|
||||
|
||||
bool BoolFunction(bool result, bool & called)
|
||||
{
|
||||
called = true;
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Logging_Level)
|
||||
{
|
||||
base::LogLevel const logLevelSaved = base::g_LogLevel;
|
||||
|
||||
@@ -11,9 +11,7 @@ class LruCacheTest
|
||||
public:
|
||||
using Loader = std::function<void(Key const & key, Value & value)>;
|
||||
|
||||
LruCacheTest(size_t maxCacheSize, Loader const & loader) : m_cache(maxCacheSize), m_loader(loader)
|
||||
{
|
||||
}
|
||||
LruCacheTest(size_t maxCacheSize, Loader const & loader) : m_cache(maxCacheSize), m_loader(loader) {}
|
||||
|
||||
Value const & GetValue(Key const & key)
|
||||
{
|
||||
@@ -42,17 +40,16 @@ public:
|
||||
bool IsValid() const { return m_keyAge.IsValidForTesting(); }
|
||||
|
||||
size_t GetAge() const { return m_keyAge.m_age; }
|
||||
std::map<size_t, Key> const & GetAgeToKey() const { return m_keyAge.m_ageToKey; };
|
||||
std::unordered_map<Key, size_t> const & GetKeyToAge() const { return m_keyAge.m_keyToAge; };
|
||||
std::map<size_t, Key> const & GetAgeToKey() const { return m_keyAge.m_ageToKey; }
|
||||
std::unordered_map<Key, size_t> const & GetKeyToAge() const { return m_keyAge.m_keyToAge; }
|
||||
|
||||
private:
|
||||
typename LruCache<Key, Value>::KeyAge m_keyAge;
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
void TestAge(LruCacheKeyAgeTest<Key, Value> const & keyAge,
|
||||
size_t expectedAge, std::map<size_t, Key> const & expectedAgeToKey,
|
||||
std::unordered_map<Key, size_t> const & expectedKeyToAge)
|
||||
void TestAge(LruCacheKeyAgeTest<Key, Value> const & keyAge, size_t expectedAge,
|
||||
std::map<size_t, Key> const & expectedAgeToKey, std::unordered_map<Key, size_t> const & expectedKeyToAge)
|
||||
{
|
||||
TEST(keyAge.IsValid(), ());
|
||||
TEST_EQUAL(keyAge.GetAge(), expectedAge, ());
|
||||
@@ -151,7 +148,8 @@ UNIT_TEST(LruCacheLoaderCallsTest)
|
||||
using Key = int;
|
||||
using Value = int;
|
||||
bool shouldLoadBeCalled = true;
|
||||
auto loader = [&shouldLoadBeCalled](Key k, Value & v) {
|
||||
auto loader = [&shouldLoadBeCalled](Key k, Value & v)
|
||||
{
|
||||
TEST(shouldLoadBeCalled, ());
|
||||
v = k;
|
||||
};
|
||||
|
||||
@@ -77,9 +77,9 @@ UNIT_TEST(AlmostEqualULPs_double)
|
||||
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax, dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-dmax, -dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax/2.0, dmax/2.0, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(1.0/dmax, 1.0/dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-1.0/dmax, -1.0/dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax / 2.0, dmax / 2.0, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(1.0 / dmax, 1.0 / dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-1.0 / dmax, -1.0 / dmax, ());
|
||||
|
||||
TEST(!AlmostEqualULPs(1.0, -1.0), ());
|
||||
TEST(!AlmostEqualULPs(2.0, -2.0), ());
|
||||
@@ -88,7 +88,7 @@ UNIT_TEST(AlmostEqualULPs_double)
|
||||
// That's why AlmostEqualULPs is a strange function, IMHO.
|
||||
TEST(!AlmostEqualULPs(0.0, eps), ());
|
||||
TEST(!AlmostEqualULPs(-eps, 0.0), ());
|
||||
TEST(!AlmostEqualULPs(eps, 2.0*eps), ());
|
||||
TEST(!AlmostEqualULPs(eps, 2.0 * eps), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(AlmostEqualULPs_float)
|
||||
@@ -105,9 +105,9 @@ UNIT_TEST(AlmostEqualULPs_float)
|
||||
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax, dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-dmax, -dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax/2.0f, dmax/2.0f, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(1.0f/dmax, 1.0f/dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-1.0f/dmax, -1.0f/dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(dmax / 2.0f, dmax / 2.0f, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(1.0f / dmax, 1.0f / dmax, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(-1.0f / dmax, -1.0f / dmax, ());
|
||||
|
||||
TEST(!AlmostEqualULPs(1.0f, -1.0f), ());
|
||||
TEST(!AlmostEqualULPs(2.0f, -2.0f), ());
|
||||
@@ -116,7 +116,7 @@ UNIT_TEST(AlmostEqualULPs_float)
|
||||
// That's why AlmostEqualULPs is a strange function, IMHO.
|
||||
TEST(!AlmostEqualULPs(0.0f, eps), ());
|
||||
TEST(!AlmostEqualULPs(-eps, 0.0f), ());
|
||||
TEST(!AlmostEqualULPs(eps, 2.0f*eps), ());
|
||||
TEST(!AlmostEqualULPs(eps, 2.0f * eps), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(AlmostEqual_Smoke)
|
||||
@@ -199,14 +199,14 @@ UNIT_TEST(is_finite)
|
||||
|
||||
TEST(!is_finite(Nan()), ());
|
||||
TEST(!is_finite(Infinity()), ());
|
||||
TEST(!is_finite(DBL_MAX*2.0), ());
|
||||
TEST(!is_finite(DBL_MAX * 2.0), ());
|
||||
|
||||
TEST(is_finite(0.0), ());
|
||||
TEST(is_finite(1.0), ());
|
||||
TEST(is_finite(-2.0), ());
|
||||
TEST(is_finite(DBL_MIN), ());
|
||||
TEST(is_finite(DBL_MAX), ());
|
||||
TEST(is_finite(DBL_MIN/2.0), ("As in cppreference example"));
|
||||
TEST(is_finite(DBL_MIN / 2.0), ("As in cppreference example"));
|
||||
}
|
||||
|
||||
} // namespace math_test
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "base/matrix.hpp"
|
||||
|
||||
|
||||
UNIT_TEST(Matrix_Inverse_Simple)
|
||||
{
|
||||
math::Matrix<double, 3, 3> m;
|
||||
@@ -19,9 +18,15 @@ UNIT_TEST(Matrix_Inverse_Simple)
|
||||
UNIT_TEST(Matrix_Inverse_AllElementsNonZero)
|
||||
{
|
||||
math::Matrix<double, 3, 3> m;
|
||||
m(0, 0) = 5; m(0, 1) = 3; m(0, 2) = 6;
|
||||
m(1, 0) = 1; m(1, 1) = 7; m(1, 2) = 9;
|
||||
m(2, 0) = 2; m(2, 1) = 13; m(2, 2) = 4;
|
||||
m(0, 0) = 5;
|
||||
m(0, 1) = 3;
|
||||
m(0, 2) = 6;
|
||||
m(1, 0) = 1;
|
||||
m(1, 1) = 7;
|
||||
m(1, 2) = 9;
|
||||
m(2, 0) = 2;
|
||||
m(2, 1) = 13;
|
||||
m(2, 2) = 4;
|
||||
|
||||
math::Matrix<double, 3, 3> m1 = math::Inverse(m);
|
||||
|
||||
|
||||
@@ -50,8 +50,7 @@ public:
|
||||
Data GetContentsByPrefix(Key const & prefix) const
|
||||
{
|
||||
Data data;
|
||||
m_trie.ForEachInSubtree(prefix,
|
||||
[&data](Key const & k, Value const & v) { data.emplace_back(k, v); });
|
||||
m_trie.ForEachInSubtree(prefix, [&data](Key const & k, Value const & v) { data.emplace_back(k, v); });
|
||||
sort(data.begin(), data.end());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ UNIT_TEST(RangeIterator)
|
||||
}
|
||||
|
||||
{
|
||||
TEST_EQUAL(std::vector<int>(MakeRangeIterator(0), MakeRangeIterator(5)),
|
||||
(std::vector<int>{0, 1, 2, 3, 4}), ());
|
||||
TEST_EQUAL(std::vector<int>(MakeRangeIterator(0), MakeRangeIterator(5)), (std::vector<int>{0, 1, 2, 3, 4}), ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <regex>
|
||||
|
||||
|
||||
namespace regexp_test
|
||||
{
|
||||
template <typename Fn>
|
||||
@@ -84,4 +83,4 @@ UNIT_TEST(RegExp_ForEachMatched)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace regexp_test
|
||||
} // namespace regexp_test
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "base/rolling_hash.hpp"
|
||||
#include "testing/benchmark.hpp"
|
||||
#include "testing/testing.hpp"
|
||||
#include "base/rolling_hash.hpp"
|
||||
|
||||
#include "base/base.hpp"
|
||||
#include "base/logging.hpp"
|
||||
#include "base/macros.hpp"
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
template <class RollingHasherT> void SmokeTest1RollingHasher()
|
||||
template <class RollingHasherT>
|
||||
void SmokeTest1RollingHasher()
|
||||
{
|
||||
typedef typename RollingHasherT::hash_type hash_type;
|
||||
RollingHasherT hash;
|
||||
@@ -18,7 +18,8 @@ template <class RollingHasherT> void SmokeTest1RollingHasher()
|
||||
TEST_EQUAL(h0, hash.Scroll('a', 'a'), (sizeof(hash_type)));
|
||||
}
|
||||
|
||||
template <class RollingHasherT> void SmokeTest2RollingHasher()
|
||||
template <class RollingHasherT>
|
||||
void SmokeTest2RollingHasher()
|
||||
{
|
||||
typedef typename RollingHasherT::hash_type hash_type;
|
||||
RollingHasherT hash;
|
||||
@@ -30,12 +31,13 @@ template <class RollingHasherT> void SmokeTest2RollingHasher()
|
||||
TEST_EQUAL(hBA, hBA1, (sizeof(hash_type)));
|
||||
}
|
||||
|
||||
template <class RollingHasherT> void TestRollingHasher()
|
||||
template <class RollingHasherT>
|
||||
void TestRollingHasher()
|
||||
{
|
||||
SmokeTest1RollingHasher<RollingHasherT>();
|
||||
SmokeTest2RollingHasher<RollingHasherT>();
|
||||
// 01234567890123
|
||||
char const s [] = "abcdefghaabcde";
|
||||
char const s[] = "abcdefghaabcde";
|
||||
size_t const len = ARRAY_SIZE(s) - 1;
|
||||
for (uint32_t size = 1; size <= 6; ++size)
|
||||
{
|
||||
@@ -49,34 +51,34 @@ template <class RollingHasherT> void TestRollingHasher()
|
||||
switch (size)
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
// Test that there are no collisions.
|
||||
sort(hashes.begin(), hashes.end());
|
||||
TEST(hashes.end() == unique(hashes.begin(), hashes.end()), (size, hashes));
|
||||
}
|
||||
break;
|
||||
{
|
||||
// Test that there are no collisions.
|
||||
sort(hashes.begin(), hashes.end());
|
||||
TEST(hashes.end() == unique(hashes.begin(), hashes.end()), (size, hashes));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
TEST_EQUAL(hashes[0], hashes[8], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[0], hashes[9], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[1], hashes[10], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[2], hashes[11], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[3], hashes[12], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[4], hashes[13], (size, len, sizeof(hash_type)));
|
||||
}
|
||||
break;
|
||||
{
|
||||
TEST_EQUAL(hashes[0], hashes[8], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[0], hashes[9], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[1], hashes[10], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[2], hashes[11], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[3], hashes[12], (size, len, sizeof(hash_type)));
|
||||
TEST_EQUAL(hashes[4], hashes[13], (size, len, sizeof(hash_type)));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
for (unsigned int i = 0; i < 6 - size; ++i)
|
||||
TEST_EQUAL(hashes[i], hashes[i + 9], (i, size, len, sizeof(hash_type)));
|
||||
sort(hashes.begin(), hashes.end());
|
||||
TEST((hashes.end() - (6 - size)) == unique(hashes.begin(), hashes.end()), (size, hashes));
|
||||
}
|
||||
{
|
||||
for (unsigned int i = 0; i < 6 - size; ++i)
|
||||
TEST_EQUAL(hashes[i], hashes[i + 9], (i, size, len, sizeof(hash_type)));
|
||||
sort(hashes.begin(), hashes.end());
|
||||
TEST((hashes.end() - (6 - size)) == unique(hashes.begin(), hashes.end()), (size, hashes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(RabinKarpRollingHasher32)
|
||||
{
|
||||
|
||||
@@ -6,26 +6,26 @@ static bool b = false;
|
||||
|
||||
void SetB()
|
||||
{
|
||||
b = true;
|
||||
b = true;
|
||||
}
|
||||
|
||||
UNIT_TEST(ScopeGuard)
|
||||
{
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
}
|
||||
TEST_EQUAL(b, true, ("scope_guard works in destructor"));
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
}
|
||||
TEST_EQUAL(b, true, ("scope_guard works in destructor"));
|
||||
}
|
||||
|
||||
UNIT_TEST(ScopeGuardRelease)
|
||||
{
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
guard.release();
|
||||
}
|
||||
TEST_EQUAL(b, false, ("If relese() was called then scope_guard shouldn't work"));
|
||||
{
|
||||
b = false;
|
||||
SCOPE_GUARD(guard, &SetB);
|
||||
TEST_EQUAL(b, false, ("Start test condition"));
|
||||
guard.release();
|
||||
}
|
||||
TEST_EQUAL(b, false, ("If relese() was called then scope_guard shouldn't work"));
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace small_set_test
|
||||
{
|
||||
@@ -97,13 +97,10 @@ UNIT_TEST(SmallMap_Benchmark1)
|
||||
// 1. Init maps.
|
||||
// Dataset is similar to routing::VehicleModel.
|
||||
std::unordered_map<uint32_t, bool> uMap = {
|
||||
{1, true}, {2, false}, {4, false}, {6, true}, {7, true},
|
||||
{8, true}, {12, false}, {15, false}, {26, true}, {30, false},
|
||||
{36, false}, {43, false}, {54, false}, {57, true}, {58, true},
|
||||
{65, true}, {69, true}, {90, true}, {95, false}, {119, false},
|
||||
{167, true}, {176, false}, {259, true}, {272, false}, {994, true},
|
||||
{1054, false}
|
||||
};
|
||||
{1, true}, {2, false}, {4, false}, {6, true}, {7, true}, {8, true}, {12, false},
|
||||
{15, false}, {26, true}, {30, false}, {36, false}, {43, false}, {54, false}, {57, true},
|
||||
{58, true}, {65, true}, {69, true}, {90, true}, {95, false}, {119, false}, {167, true},
|
||||
{176, false}, {259, true}, {272, false}, {994, true}, {1054, false}};
|
||||
|
||||
base::SmallMap<uint32_t, bool> sMap(uMap.begin(), uMap.end());
|
||||
|
||||
@@ -142,31 +139,31 @@ UNIT_TEST(SmallMap_Benchmark2)
|
||||
uint32_t i = 0;
|
||||
// Dataset is similar to routing::VehicleModelFactory.
|
||||
unordered_map<string, shared_ptr<int>> uMap = {
|
||||
{"", make_shared<int>(i++)},
|
||||
{"Australia", make_shared<int>(i++)},
|
||||
{"Austria", make_shared<int>(i++)},
|
||||
{"Belarus", make_shared<int>(i++)},
|
||||
{"Belgium", make_shared<int>(i++)},
|
||||
{"Brazil", make_shared<int>(i++)},
|
||||
{"Denmark", make_shared<int>(i++)},
|
||||
{"France", make_shared<int>(i++)},
|
||||
{"Finland", make_shared<int>(i++)},
|
||||
{"Germany", make_shared<int>(i++)},
|
||||
{"Hungary", make_shared<int>(i++)},
|
||||
{"Iceland", make_shared<int>(i++)},
|
||||
{"Netherlands", make_shared<int>(i++)},
|
||||
{"Norway", make_shared<int>(i++)},
|
||||
{"Oman", make_shared<int>(i++)},
|
||||
{"Poland", make_shared<int>(i++)},
|
||||
{"Romania", make_shared<int>(i++)},
|
||||
{"Russian Federation", make_shared<int>(i++)},
|
||||
{"Slovakia", make_shared<int>(i++)},
|
||||
{"Spain", make_shared<int>(i++)},
|
||||
{"Switzerland", make_shared<int>(i++)},
|
||||
{"Turkey", make_shared<int>(i++)},
|
||||
{"Ukraine", make_shared<int>(i++)},
|
||||
{"United Kingdom", make_shared<int>(i++)},
|
||||
{"United States of America", make_shared<int>(i++)},
|
||||
{"", make_shared<int>(i++)},
|
||||
{"Australia", make_shared<int>(i++)},
|
||||
{"Austria", make_shared<int>(i++)},
|
||||
{"Belarus", make_shared<int>(i++)},
|
||||
{"Belgium", make_shared<int>(i++)},
|
||||
{"Brazil", make_shared<int>(i++)},
|
||||
{"Denmark", make_shared<int>(i++)},
|
||||
{"France", make_shared<int>(i++)},
|
||||
{"Finland", make_shared<int>(i++)},
|
||||
{"Germany", make_shared<int>(i++)},
|
||||
{"Hungary", make_shared<int>(i++)},
|
||||
{"Iceland", make_shared<int>(i++)},
|
||||
{"Netherlands", make_shared<int>(i++)},
|
||||
{"Norway", make_shared<int>(i++)},
|
||||
{"Oman", make_shared<int>(i++)},
|
||||
{"Poland", make_shared<int>(i++)},
|
||||
{"Romania", make_shared<int>(i++)},
|
||||
{"Russian Federation", make_shared<int>(i++)},
|
||||
{"Slovakia", make_shared<int>(i++)},
|
||||
{"Spain", make_shared<int>(i++)},
|
||||
{"Switzerland", make_shared<int>(i++)},
|
||||
{"Turkey", make_shared<int>(i++)},
|
||||
{"Ukraine", make_shared<int>(i++)},
|
||||
{"United Kingdom", make_shared<int>(i++)},
|
||||
{"United States of America", make_shared<int>(i++)},
|
||||
};
|
||||
|
||||
base::SmallMap<std::string, std::shared_ptr<int>> sMap(uMap.begin(), uMap.end());
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace stl_helpers_tests
|
||||
{
|
||||
using namespace base;
|
||||
@@ -35,8 +34,7 @@ void TestSortUnique()
|
||||
{
|
||||
using Value = int;
|
||||
using Pair = std::pair<Value, int>;
|
||||
Cont<Pair> d =
|
||||
{{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
|
||||
Cont<Pair> d = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
|
||||
|
||||
SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first));
|
||||
|
||||
@@ -48,8 +46,7 @@ void TestSortUnique()
|
||||
{
|
||||
using Value = double;
|
||||
using Pair = std::pair<Value, int>;
|
||||
Cont<Pair> d =
|
||||
{{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
|
||||
Cont<Pair> d = {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
|
||||
|
||||
SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first));
|
||||
|
||||
@@ -155,17 +152,18 @@ UNIT_TEST(IgnoreFirstArgument)
|
||||
|
||||
namespace
|
||||
{
|
||||
struct EqualZero
|
||||
{
|
||||
bool operator() (int x) { return (x == 0); }
|
||||
};
|
||||
struct EqualZero
|
||||
{
|
||||
bool operator()(int x) { return (x == 0); }
|
||||
};
|
||||
|
||||
template <class ContT> void CheckNoZero(ContT & c, typename ContT::iterator i)
|
||||
{
|
||||
c.erase(i, c.end());
|
||||
TEST(find_if(c.begin(), c.end(), EqualZero()) == c.end(), ());
|
||||
}
|
||||
template <class ContT>
|
||||
void CheckNoZero(ContT & c, typename ContT::iterator i)
|
||||
{
|
||||
c.erase(i, c.end());
|
||||
TEST(find_if(c.begin(), c.end(), EqualZero()) == c.end(), ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(RemoveIfKeepValid)
|
||||
{
|
||||
@@ -222,20 +220,18 @@ UNIT_TEST(RemoveIfKeepValid)
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T, size_t N1, size_t N2, size_t N3>
|
||||
void CheckAccumulateIntervals(size_t & idTest,
|
||||
std::pair<T, T> (&arr1)[N1],
|
||||
std::pair<T, T> (&arr2)[N2],
|
||||
std::pair<T, T> (&arr3)[N3])
|
||||
{
|
||||
std::vector<std::pair<T, T> > res;
|
||||
AccumulateIntervals1With2(arr1, arr1 + N1, arr2, arr2 + N2, back_inserter(res));
|
||||
template <class T, size_t N1, size_t N2, size_t N3>
|
||||
void CheckAccumulateIntervals(size_t & idTest, std::pair<T, T> (&arr1)[N1], std::pair<T, T> (&arr2)[N2],
|
||||
std::pair<T, T> (&arr3)[N3])
|
||||
{
|
||||
std::vector<std::pair<T, T>> res;
|
||||
AccumulateIntervals1With2(arr1, arr1 + N1, arr2, arr2 + N2, back_inserter(res));
|
||||
|
||||
++idTest;
|
||||
TEST_EQUAL(N3, res.size(), ("Test", idTest, res));
|
||||
TEST(equal(res.begin(), res.end(), arr3), ("Test", idTest, res));
|
||||
}
|
||||
++idTest;
|
||||
TEST_EQUAL(N3, res.size(), ("Test", idTest, res));
|
||||
TEST(equal(res.begin(), res.end(), arr3), ("Test", idTest, res));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(AccumulateIntervals)
|
||||
{
|
||||
@@ -245,7 +241,7 @@ UNIT_TEST(AccumulateIntervals)
|
||||
// bound cases
|
||||
{
|
||||
std::vector<T> res;
|
||||
T arr[] = { T(10, 20) };
|
||||
T arr[] = {T(10, 20)};
|
||||
|
||||
res.clear();
|
||||
AccumulateIntervals1With2(arr, arr + 1, arr, arr, back_inserter(res));
|
||||
@@ -258,71 +254,65 @@ UNIT_TEST(AccumulateIntervals)
|
||||
|
||||
// check splice overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(19, 31) };
|
||||
T res[] = { T(10, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(19, 31)};
|
||||
T res[] = {T(10, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check skip not overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(0, 9), T(21, 29), T(41, 50) };
|
||||
T res[2] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(0, 9), T(21, 29), T(41, 50)};
|
||||
T res[2] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(1, 2), T(3, 4), T(5, 6),
|
||||
T(21, 22), T(23, 24), T(25, 26),
|
||||
T(41, 42), T(43, 44), T(45, 46)
|
||||
};
|
||||
T res[] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(1, 2), T(3, 4), T(5, 6), T(21, 22), T(23, 24), T(25, 26), T(41, 42), T(43, 44), T(45, 46)};
|
||||
T res[] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check equal bounds
|
||||
{
|
||||
T arr1[] = { T(20, 30) };
|
||||
T arr2[] = { T(10, 20), T(30, 40) };
|
||||
T res[] = { T(20, 30) };
|
||||
T arr1[] = {T(20, 30)};
|
||||
T arr2[] = {T(10, 20), T(30, 40)};
|
||||
T res[] = {T(20, 30)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(20, 30) };
|
||||
T res[] = { T(10, 20), T(30, 40) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(20, 30)};
|
||||
T res[] = {T(10, 20), T(30, 40)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check large overlap interval
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40), T(50, 60) };
|
||||
T arr2[] = { T(0, 100) };
|
||||
T res[] = { T(0, 100) };
|
||||
T arr1[] = {T(10, 20), T(30, 40), T(50, 60)};
|
||||
T arr2[] = {T(0, 100)};
|
||||
T res[] = {T(0, 100)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(0, 100) };
|
||||
T arr2[] = { T(10, 20), T(30, 40), T(50, 60) };
|
||||
T res[] = { T(0, 100) };
|
||||
T arr1[] = {T(0, 100)};
|
||||
T arr2[] = {T(10, 20), T(30, 40), T(50, 60)};
|
||||
T res[] = {T(0, 100)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
|
||||
// check splice overlapped
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(5, 15), T(35, 45) };
|
||||
T res[] = { T(5, 20), T(30, 45) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(5, 15), T(35, 45)};
|
||||
T res[] = {T(5, 20), T(30, 45)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
{
|
||||
T arr1[] = { T(10, 20), T(30, 40) };
|
||||
T arr2[] = { T(1, 2), T(3, 4), T(5, 15),
|
||||
T(17, 25), T(26, 27), T(28, 32),
|
||||
T(38, 45), T(46, 50)
|
||||
};
|
||||
T res[] = { T(5, 25), T(28, 45) };
|
||||
T arr1[] = {T(10, 20), T(30, 40)};
|
||||
T arr2[] = {T(1, 2), T(3, 4), T(5, 15), T(17, 25), T(26, 27), T(28, 32), T(38, 45), T(46, 50)};
|
||||
T res[] = {T(5, 25), T(28, 45)};
|
||||
CheckAccumulateIntervals(idTest, arr1, arr2, res);
|
||||
}
|
||||
}
|
||||
@@ -353,6 +343,7 @@ UNIT_TEST(Map_EmplaceOrAssign)
|
||||
|
||||
Obj(Obj const &) = delete;
|
||||
Obj & operator=(Obj const &) = delete;
|
||||
|
||||
public:
|
||||
Obj(int v) : m_v(v) {}
|
||||
Obj(Obj &&) = default;
|
||||
@@ -370,4 +361,4 @@ UNIT_TEST(Map_EmplaceOrAssign)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace stl_helpers_test
|
||||
} // namespace stl_helpers_tests
|
||||
|
||||
@@ -114,7 +114,7 @@ UNIT_TEST(MakeLowerCase)
|
||||
TEST_EQUAL(MakeLowerCase("this_is_lower"), "this_is_lower", ());
|
||||
|
||||
TEST_EQUAL(MakeLowerCase("Hola! 99-\xD0\xA3\xD0\x9F\xD0\xAF\xD0\xA7\xD0\x9A\xD0\x90"),
|
||||
"hola! 99-\xD1\x83\xD0\xBF\xD1\x8F\xD1\x87\xD0\xBA\xD0\xB0", ());
|
||||
"hola! 99-\xD1\x83\xD0\xBF\xD1\x8F\xD1\x87\xD0\xBA\xD0\xB0", ());
|
||||
|
||||
// es-cet
|
||||
TEST_EQUAL(MakeLowerCase("\xc3\x9f"), "ss", ());
|
||||
@@ -249,7 +249,7 @@ void ToUIntTest(char const * p, bool good = false, uint32_t expected = 0)
|
||||
if (good)
|
||||
TEST(expected == i1 && expected == i2 && expected == i3, (s, i1, i2, i3));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(to_uint)
|
||||
{
|
||||
@@ -661,16 +661,12 @@ UNIT_TEST(to_string_width)
|
||||
TEST_EQUAL(strings::to_string_width(1073741824, 0), "1073741824", ());
|
||||
}
|
||||
|
||||
|
||||
struct FunctorTester
|
||||
{
|
||||
size_t & m_index;
|
||||
std::vector<std::string> const & m_tokens;
|
||||
|
||||
FunctorTester(size_t & counter, std::vector<std::string> const & tokens)
|
||||
: m_index(counter), m_tokens(tokens)
|
||||
{
|
||||
}
|
||||
FunctorTester(size_t & counter, std::vector<std::string> const & tokens) : m_index(counter), m_tokens(tokens) {}
|
||||
|
||||
void operator()(std::string_view s) { TEST_EQUAL(s, m_tokens[m_index++], ()); }
|
||||
};
|
||||
@@ -692,12 +688,11 @@ void TestIter(std::string const & s, char const * delims, std::vector<std::strin
|
||||
TEST_EQUAL(counter, tokens.size(), ());
|
||||
}
|
||||
|
||||
void TestIterWithEmptyTokens(std::string const & s, char const * delims,
|
||||
std::vector<std::string> const & tokens)
|
||||
void TestIterWithEmptyTokens(std::string const & s, char const * delims, std::vector<std::string> const & tokens)
|
||||
{
|
||||
using namespace strings;
|
||||
TokenizeIterator<SimpleDelimiter, std::string::const_iterator, true /* KeepEmptyTokens */>
|
||||
it(s.begin(), s.end(), delims);
|
||||
TokenizeIterator<SimpleDelimiter, std::string::const_iterator, true /* KeepEmptyTokens */> it(s.begin(), s.end(),
|
||||
delims);
|
||||
|
||||
for (size_t i = 0; i < tokens.size(); ++i)
|
||||
{
|
||||
@@ -728,8 +723,7 @@ UNIT_TEST(SimpleTokenizer)
|
||||
}
|
||||
|
||||
{
|
||||
char const * s[] = {"\xD9\x80", "\xD8\xA7\xD9\x84\xD9\x85\xD9\x88\xD8\xA7\xD9\x81\xD9\x82",
|
||||
"\xD8\xAC"};
|
||||
char const * s[] = {"\xD9\x80", "\xD8\xA7\xD9\x84\xD9\x85\xD9\x88\xD8\xA7\xD9\x81\xD9\x82", "\xD8\xAC"};
|
||||
tokens.assign(&s[0], &s[0] + ARRAY_SIZE(s));
|
||||
TestIter(
|
||||
"\xD9\x87\xD9\x80 - \xD8\xA7\xD9\x84\xD9\x85\xD9\x88\xD8\xA7\xD9\x81\xD9\x82 "
|
||||
@@ -826,8 +820,7 @@ UNIT_TEST(Normalize)
|
||||
{
|
||||
strings::UniChar const s[] = {0x1f101, 'H', 0xfef0, 0xfdfc, 0x2150};
|
||||
strings::UniString us(&s[0], &s[0] + ARRAY_SIZE(s));
|
||||
strings::UniChar const r[] = {0x30, 0x2c, 'H', 0x649, 0x631, 0x6cc,
|
||||
0x627, 0x644, 0x31, 0x2044, 0x37};
|
||||
strings::UniChar const r[] = {0x30, 0x2c, 'H', 0x649, 0x631, 0x6cc, 0x627, 0x644, 0x31, 0x2044, 0x37};
|
||||
strings::UniString result(&r[0], &r[0] + ARRAY_SIZE(r));
|
||||
strings::NormalizeInplace(us);
|
||||
TEST_EQUAL(us, result, ());
|
||||
@@ -837,8 +830,7 @@ UNIT_TEST(Normalize_Special)
|
||||
{
|
||||
{
|
||||
std::string const utf8 = "ąĄćłŁÓŻźŃĘęĆ";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), "aAclLOZzNEeC",
|
||||
());
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), "aAclLOZzNEeC", ());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -847,69 +839,69 @@ UNIT_TEST(Normalize_Special)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UNIT_TEST(Normalize_Arabic)
|
||||
{
|
||||
{
|
||||
// Test Arabic-Indic digits normalization
|
||||
std::string const utf8 = "٠١٢٣٤٥٦٧٨٩";
|
||||
std::string const utf8 = "٠١٢٣٤٥٦٧٨٩";
|
||||
std::string const normalized = "0123456789";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Test Extended Arabic-Indic digits normalization
|
||||
std::string const utf8 = "۰۱۲۳۴۵۶۷۸۹";
|
||||
std::string const utf8 = "۰۱۲۳۴۵۶۷۸۹";
|
||||
std::string const normalized = "0123456789";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// All Arabic Letters (all of these are standalone unicode characters)
|
||||
std::string const utf8 = "ء أ إ ا آ ٱ ٲ ٳ ٵ ب ت ة ۃ ث ج ح خ د ذ ر ز س ش ص ط ظ ع غ ف ق ك ل م ن ه ۀ ۂ ؤ ٶ ٷ و ي ى ئ ٸ ے ۓ";
|
||||
std::string const normalized = "ء ا ا ا ا ا ا ا ا ب ت ه ه ث ج ح خ د ذ ر ز س ش ص ط ظ ع غ ف ق ك ل م ن ه ه ه و و و و ي ي ي ي ے ے";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
std::string const utf8 =
|
||||
"ء أ إ ا آ ٱ ٲ ٳ ٵ ب ت ة ۃ ث ج ح خ د ذ ر ز س ش ص ط ظ ع غ ف ق ك ل م ن ه ۀ ۂ ؤ ٶ ٷ و ي ى ئ ٸ ے ۓ";
|
||||
std::string const normalized =
|
||||
"ء ا ا ا ا ا ا ا ا ب ت ه ه ث ج ح خ د ذ ر ز س ش ص ط ظ ع غ ف ق ك ل م ن ه ه ه و و و و ي ي ي ي ے ے";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Test Removing Arabic Diacritics (Tashkeel), we can add multiple diacritics to the same letter
|
||||
// Each diacritic is a standalone unicode character
|
||||
std::string const utf8 = "هَذِهْٜ تَّجُّرًّبهٌ عَلَىٰ إِزَالْهٍ ألتَشٗكُيٓلُ وَّ ليٙسٝت دقٞيٛقٚه لُغَويًّاً";
|
||||
std::string const utf8 = "هَذِهْٜ تَّجُّرًّبهٌ عَلَىٰ إِزَالْهٍ ألتَشٗكُيٓلُ وَّ ليٙسٝت دقٞيٛقٚه لُغَويًّاً";
|
||||
std::string const normalized = "هذه تجربه علي ازاله التشكيل و ليست دقيقه لغويا";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Test Removing Arabic Islamic Honorifics
|
||||
// These are standalone unicode characters that can be applied to a letter
|
||||
std::string const utf8 = "صؐلي عنؑه رحؒمه رضؓي سؔ طؕ الىؖ زؗ اؘ اؙ ؚا";
|
||||
std::string const utf8 = "صؐلي عنؑه رحؒمه رضؓي سؔ طؕ الىؖ زؗ اؘ اؙ ؚا";
|
||||
std::string const normalized = "صلي عنه رحمه رضي س ط الي ز ا ا ا";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Test Removing Arabic Quranic Annotations
|
||||
// These are standalone unicode characters that can be applied to a letter
|
||||
std::string const utf8 = "نۖ بۗ مۘ لۙا جۛ جۚ سۜ ا۟ ا۠ اۡ مۢ ۣس نۤ ك۪ ك۫ ك۬ مۭ";
|
||||
std::string const utf8 = "نۖ بۗ مۘ لۙا جۛ جۚ سۜ ا۟ ا۠ اۡ مۢ ۣس نۤ ك۪ ك۫ ك۬ مۭ";
|
||||
std::string const normalized = "ن ب م لا ج ج س ا ا ا م س ن ك ك ك م";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Tests Arabic Tatweel (Kashida) normalization
|
||||
// This character is used to elongate text in Arabic script, (used in justifing/aligning text)
|
||||
std::string const utf8 = "اميـــــن";
|
||||
std::string const normalized = "امين";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
std::string const utf8 = "اميـــــن";
|
||||
std::string const normalized = "امين";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
{
|
||||
// Tests Arabic Comma normalization
|
||||
std::string const utf8 = "،";
|
||||
std::string const utf8 = "،";
|
||||
std::string const normalized = ",";
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized , ());
|
||||
TEST_EQUAL(strings::ToUtf8(strings::Normalize(strings::MakeUniString(utf8))), normalized, ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UNIT_TEST(UniStringToUtf8)
|
||||
@@ -957,27 +949,15 @@ UNIT_TEST(EatPrefix_EatSuffix)
|
||||
{
|
||||
// <original string, prefix/suffix to cut, success, string after cutting>
|
||||
std::vector<std::tuple<std::string, std::string, bool, std::string>> kPrefixTestcases = {
|
||||
{"abc", "a", true, "bc"},
|
||||
{"abc", "b", false, "abc"},
|
||||
{"abc", "", true, "abc"},
|
||||
{"abc", "abc", true, ""},
|
||||
{"abc", "abc00", false, "abc"},
|
||||
{"", "", true, ""},
|
||||
{"абв", "а", true, "бв"},
|
||||
{"абв", "б", false, "абв"},
|
||||
{"字符串", "字", true, "符串"},
|
||||
{"abc", "a", true, "bc"}, {"abc", "b", false, "abc"}, {"abc", "", true, "abc"},
|
||||
{"abc", "abc", true, ""}, {"abc", "abc00", false, "abc"}, {"", "", true, ""},
|
||||
{"абв", "а", true, "бв"}, {"абв", "б", false, "абв"}, {"字符串", "字", true, "符串"},
|
||||
};
|
||||
|
||||
std::vector<std::tuple<std::string, std::string, bool, std::string>> kSuffixTestcases = {
|
||||
{"abc", "c", true, "ab"},
|
||||
{"abc", "b", false, "abc"},
|
||||
{"abc", "", true, "abc"},
|
||||
{"abc", "abc", true, ""},
|
||||
{"abc", "00abc", false, "abc"},
|
||||
{"", "", true, ""},
|
||||
{"абв", "в", true, "аб"},
|
||||
{"абв", "б", false, "абв"},
|
||||
{"字符串", "串", true, "字符"},
|
||||
{"abc", "c", true, "ab"}, {"abc", "b", false, "abc"}, {"abc", "", true, "abc"},
|
||||
{"abc", "abc", true, ""}, {"abc", "00abc", false, "abc"}, {"", "", true, ""},
|
||||
{"абв", "в", true, "аб"}, {"абв", "б", false, "абв"}, {"字符串", "串", true, "字符"},
|
||||
};
|
||||
|
||||
for (auto const & [original, toCut, success, afterCutting] : kPrefixTestcases)
|
||||
@@ -1121,9 +1101,8 @@ UNIT_TEST(AlmostEqual)
|
||||
|
||||
UNIT_TEST(EditDistance)
|
||||
{
|
||||
auto testEditDistance = [](std::string const & s1, std::string const & s2, uint32_t expected) {
|
||||
TEST_EQUAL(strings::EditDistance(s1.begin(), s1.end(), s2.begin(), s2.end()), expected, ());
|
||||
};
|
||||
auto testEditDistance = [](std::string const & s1, std::string const & s2, uint32_t expected)
|
||||
{ TEST_EQUAL(strings::EditDistance(s1.begin(), s1.end(), s2.begin(), s2.end()), expected, ()); };
|
||||
|
||||
testEditDistance("", "wwwww", 5);
|
||||
testEditDistance("", "", 0);
|
||||
@@ -1135,8 +1114,8 @@ UNIT_TEST(EditDistance)
|
||||
testEditDistance("aaaab", "aaaac", 1);
|
||||
testEditDistance("a spaces test", "aspacestest", 2);
|
||||
|
||||
auto testUniStringEditDistance = [](std::string const & utf1, std::string const & utf2,
|
||||
uint32_t expected) {
|
||||
auto testUniStringEditDistance = [](std::string const & utf1, std::string const & utf2, uint32_t expected)
|
||||
{
|
||||
auto s1 = strings::MakeUniString(utf1);
|
||||
auto s2 = strings::MakeUniString(utf2);
|
||||
TEST_EQUAL(strings::EditDistance(s1.begin(), s1.end(), s2.begin(), s2.end()), expected, ());
|
||||
@@ -1148,7 +1127,8 @@ UNIT_TEST(EditDistance)
|
||||
|
||||
UNIT_TEST(NormalizeDigits)
|
||||
{
|
||||
auto const nd = [](std::string str) -> std::string {
|
||||
auto const nd = [](std::string str) -> std::string
|
||||
{
|
||||
strings::NormalizeDigits(str);
|
||||
return str;
|
||||
};
|
||||
@@ -1160,7 +1140,8 @@ UNIT_TEST(NormalizeDigits)
|
||||
|
||||
UNIT_TEST(NormalizeDigits_UniString)
|
||||
{
|
||||
auto const nd = [](std::string const & utf8) -> std::string {
|
||||
auto const nd = [](std::string const & utf8) -> std::string
|
||||
{
|
||||
strings::UniString us = strings::MakeUniString(utf8);
|
||||
strings::NormalizeDigits(us);
|
||||
return strings::ToUtf8(us);
|
||||
@@ -1187,34 +1168,32 @@ UNIT_TEST(CSV)
|
||||
|
||||
UNIT_TEST(UniString_Replace)
|
||||
{
|
||||
std::vector<std::string> const testStrings = {
|
||||
"longlong",
|
||||
"ss",
|
||||
"samesize",
|
||||
"sometext longlong",
|
||||
"sometext ss",
|
||||
"sometext samesize",
|
||||
"longlong sometext",
|
||||
"ss sometext",
|
||||
"samesize sometext",
|
||||
"longlong ss samesize",
|
||||
"sometext longlong sometext ss samesize sometext",
|
||||
"длинная строка",
|
||||
"к с",
|
||||
"такая же строка",
|
||||
"sometext длинная строка",
|
||||
"sometext к с",
|
||||
"sometext такая же строка",
|
||||
"длинная строка sometext",
|
||||
"к с sometext",
|
||||
"samesize sometext",
|
||||
"длинная строка к с samesize",
|
||||
"sometext длинная строка sometext к с такая же строка sometext"};
|
||||
std::vector<std::string> const testStrings = {"longlong",
|
||||
"ss",
|
||||
"samesize",
|
||||
"sometext longlong",
|
||||
"sometext ss",
|
||||
"sometext samesize",
|
||||
"longlong sometext",
|
||||
"ss sometext",
|
||||
"samesize sometext",
|
||||
"longlong ss samesize",
|
||||
"sometext longlong sometext ss samesize sometext",
|
||||
"длинная строка",
|
||||
"к с",
|
||||
"такая же строка",
|
||||
"sometext длинная строка",
|
||||
"sometext к с",
|
||||
"sometext такая же строка",
|
||||
"длинная строка sometext",
|
||||
"к с sometext",
|
||||
"samesize sometext",
|
||||
"длинная строка к с samesize",
|
||||
"sometext длинная строка sometext к с такая же строка sometext"};
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> const replacements = {
|
||||
{"longlong", "ll"}, {"ss", "shortshort"},
|
||||
{"samesize", "sizesame"}, {"длинная строка", "д с"},
|
||||
{"к с", "короткая строка"}, {"такая же строка", "строка такая же"}};
|
||||
{"longlong", "ll"}, {"ss", "shortshort"}, {"samesize", "sizesame"},
|
||||
{"длинная строка", "д с"}, {"к с", "короткая строка"}, {"такая же строка", "строка такая же"}};
|
||||
|
||||
for (auto testString : testStrings)
|
||||
{
|
||||
@@ -1260,7 +1239,7 @@ void TestTrim(std::string const & str, std::string const & expected)
|
||||
|
||||
TEST(expected == copy && expected == sv, (str));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Trim)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,10 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
UNIT_TEST(Skew_Smoke) { Skew(0, nullptr /* s */, nullptr /* sa */); }
|
||||
UNIT_TEST(Skew_Smoke)
|
||||
{
|
||||
Skew(0, nullptr /* s */, nullptr /* sa */);
|
||||
}
|
||||
|
||||
UNIT_TEST(Skew_Simple)
|
||||
{
|
||||
@@ -71,7 +74,7 @@ UNIT_TEST(Skew_Classic)
|
||||
TEST_EQUAL(n, 11, ());
|
||||
|
||||
vector<size_t> pos(n);
|
||||
Skew(n, reinterpret_cast<const uint8_t *>(s), pos.data());
|
||||
Skew(n, reinterpret_cast<uint8_t const *>(s), pos.data());
|
||||
|
||||
TEST_STR_EQUAL("i", s + pos[0], ());
|
||||
TEST_STR_EQUAL("ippi", s + pos[1], ());
|
||||
|
||||
@@ -23,7 +23,8 @@ UNIT_TEST(ThreadPoolComputational_SomeThreads)
|
||||
base::ComputationalThreadPool threadPool(threadCount);
|
||||
for (size_t i = 0; i < threadCount; ++i)
|
||||
{
|
||||
threadPool.Submit([&]() {
|
||||
threadPool.Submit([&]()
|
||||
{
|
||||
threads::Sleep(1);
|
||||
++counter;
|
||||
});
|
||||
@@ -44,7 +45,8 @@ UNIT_TEST(ThreadPoolComputational_OneThread)
|
||||
base::ComputationalThreadPool threadPool(threadCount);
|
||||
for (size_t i = 0; i < threadCount; ++i)
|
||||
{
|
||||
threadPool.Submit([&]() {
|
||||
threadPool.Submit([&]()
|
||||
{
|
||||
threads::Sleep(1);
|
||||
++counter;
|
||||
});
|
||||
@@ -67,7 +69,8 @@ UNIT_TEST(ThreadPoolComputational_ManyThread)
|
||||
base::ComputationalThreadPool threadPool(threadCount);
|
||||
for (size_t i = 0; i < threadCount; ++i)
|
||||
{
|
||||
threadPool.Submit([&]() {
|
||||
threadPool.Submit([&]()
|
||||
{
|
||||
threads::Sleep(1);
|
||||
++counter;
|
||||
});
|
||||
@@ -87,7 +90,8 @@ UNIT_TEST(ThreadPoolComputational_ReturnValue)
|
||||
std::vector<std::future<size_t>> futures;
|
||||
for (size_t i = 0; i < threadCount; ++i)
|
||||
{
|
||||
auto f = threadPool.Submit([=]() {
|
||||
auto f = threadPool.Submit([=]()
|
||||
{
|
||||
threads::Sleep(1);
|
||||
return i;
|
||||
});
|
||||
@@ -110,7 +114,8 @@ UNIT_TEST(ThreadPoolComputational_ManyTasks)
|
||||
base::ComputationalThreadPool threadPool(4);
|
||||
for (size_t i = 0; i < taskCount; ++i)
|
||||
{
|
||||
threadPool.Submit([&]() {
|
||||
threadPool.Submit([&]()
|
||||
{
|
||||
threads::Sleep(1);
|
||||
++counter;
|
||||
});
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
#include "base/thread_pool_delayed.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace thread_pool_delayed_tests
|
||||
{
|
||||
using namespace base;
|
||||
@@ -52,7 +51,8 @@ UNIT_TEST(ThreadPoolDelayed_SimpleSync)
|
||||
TEST(pushResult.m_isSuccess, ());
|
||||
TEST_NOT_EQUAL(pushResult.m_id, DelayedThreadPool::kNoId, ());
|
||||
|
||||
pushResult = thread.Push([&]() {
|
||||
pushResult = thread.Push([&]()
|
||||
{
|
||||
lock_guard<mutex> lk(mu);
|
||||
done = true;
|
||||
cv.notify_one();
|
||||
@@ -77,7 +77,8 @@ UNIT_TEST(ThreadPoolDelayed_SimpleFlush)
|
||||
TEST(pushResult.m_isSuccess, ());
|
||||
TEST_NOT_EQUAL(pushResult.m_id, DelayedThreadPool::kNoId, ());
|
||||
|
||||
pushResult = thread.Push([&value]() {
|
||||
pushResult = thread.Push([&value]()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
value *= 2;
|
||||
});
|
||||
@@ -97,7 +98,8 @@ UNIT_TEST(ThreadPoolDelayed_PushFromPendingTask)
|
||||
auto f = p.get_future();
|
||||
|
||||
DelayedThreadPool thread;
|
||||
auto const pushResult = thread.Push([&f, &thread]() {
|
||||
auto const pushResult = thread.Push([&f, &thread]()
|
||||
{
|
||||
f.get();
|
||||
auto const innerPushResult = thread.Push([]() { TEST(false, ("This task should not be executed")); });
|
||||
TEST(!innerPushResult.m_isSuccess, ());
|
||||
@@ -157,10 +159,7 @@ UNIT_TEST(ThreadPoolDelayed_DelayedAndImmediateTasks)
|
||||
}
|
||||
|
||||
for (int i = 1; i < kNumTasks; ++i)
|
||||
{
|
||||
TEST(immediateEntries[i] >= immediateEntries[i - 1],
|
||||
("Failed delay for the immediate task", i));
|
||||
}
|
||||
TEST(immediateEntries[i] >= immediateEntries[i - 1], ("Failed delay for the immediate task", i));
|
||||
}
|
||||
|
||||
UNIT_TEST(ThreadPoolDelayed_CancelImmediate)
|
||||
@@ -171,7 +170,8 @@ UNIT_TEST(ThreadPoolDelayed_CancelImmediate)
|
||||
TaskLoop::TaskId cancelTaskId;
|
||||
DelayedThreadPool thread;
|
||||
{
|
||||
auto const pushResult = thread.Push([&value]() {
|
||||
auto const pushResult = thread.Push([&value]()
|
||||
{
|
||||
++value;
|
||||
testing::Wait();
|
||||
});
|
||||
@@ -246,4 +246,4 @@ UNIT_TEST(ThreadPoolDelayed_CancelDelayed)
|
||||
TEST_EQUAL(value, 2, ());
|
||||
}
|
||||
|
||||
} // namespace thread_pool_delayed_tests
|
||||
} // namespace thread_pool_delayed_tests
|
||||
|
||||
@@ -6,48 +6,39 @@
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
const int TASK_COUNT = 10;
|
||||
class CanceledTask : public threads::IRoutine
|
||||
{
|
||||
public:
|
||||
CanceledTask()
|
||||
{
|
||||
Cancel();
|
||||
}
|
||||
int const TASK_COUNT = 10;
|
||||
class CanceledTask : public threads::IRoutine
|
||||
{
|
||||
public:
|
||||
CanceledTask() { Cancel(); }
|
||||
|
||||
virtual void Do()
|
||||
{
|
||||
TEST_EQUAL(true, false, ());
|
||||
}
|
||||
};
|
||||
struct Condition
|
||||
{
|
||||
std::mutex m;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
virtual void Do() { TEST_EQUAL(true, false, ()); }
|
||||
};
|
||||
struct Condition
|
||||
{
|
||||
std::mutex m;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
|
||||
void JoinFinishFunction(threads::IRoutine * routine,
|
||||
int & finishCounter,
|
||||
Condition & cond)
|
||||
{
|
||||
cond.m.lock();
|
||||
finishCounter++;
|
||||
cond.m.unlock();
|
||||
void JoinFinishFunction(threads::IRoutine * routine, int & finishCounter, Condition & cond)
|
||||
{
|
||||
cond.m.lock();
|
||||
finishCounter++;
|
||||
cond.m.unlock();
|
||||
|
||||
delete routine;
|
||||
cond.cv.notify_one();
|
||||
}
|
||||
delete routine;
|
||||
cond.cv.notify_one();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(ThreadPool_CanceledTaskTest)
|
||||
{
|
||||
int finishCounter = 0;
|
||||
Condition cond;
|
||||
base::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1,
|
||||
std::ref(finishCounter), std::ref(cond)));
|
||||
base::ThreadPool pool(4,
|
||||
std::bind(&JoinFinishFunction, std::placeholders::_1, std::ref(finishCounter), std::ref(cond)));
|
||||
|
||||
for (int i = 0; i < TASK_COUNT; ++i)
|
||||
pool.PushBack(new CanceledTask());
|
||||
@@ -57,42 +48,34 @@ UNIT_TEST(ThreadPool_CanceledTaskTest)
|
||||
TEST_EQUAL(finishCounter, TASK_COUNT, ());
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class CancelTestTask : public threads::IRoutine
|
||||
class CancelTestTask : public threads::IRoutine
|
||||
{
|
||||
public:
|
||||
explicit CancelTestTask(bool isWaitDoCall) : m_waitDoCall(isWaitDoCall), m_doCalled(false) {}
|
||||
|
||||
~CancelTestTask() { TEST_EQUAL(m_waitDoCall, m_doCalled, ()); }
|
||||
|
||||
virtual void Do()
|
||||
{
|
||||
public:
|
||||
explicit CancelTestTask(bool isWaitDoCall)
|
||||
: m_waitDoCall(isWaitDoCall)
|
||||
, m_doCalled(false)
|
||||
{
|
||||
}
|
||||
TEST_EQUAL(m_waitDoCall, true, ());
|
||||
m_doCalled = true;
|
||||
threads::Sleep(100);
|
||||
}
|
||||
|
||||
~CancelTestTask()
|
||||
{
|
||||
TEST_EQUAL(m_waitDoCall, m_doCalled, ());
|
||||
}
|
||||
|
||||
virtual void Do()
|
||||
{
|
||||
TEST_EQUAL(m_waitDoCall, true, ());
|
||||
m_doCalled = true;
|
||||
threads::Sleep(100);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_waitDoCall;
|
||||
bool m_doCalled;
|
||||
};
|
||||
}
|
||||
private:
|
||||
bool m_waitDoCall;
|
||||
bool m_doCalled;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(ThreadPool_ExecutionTaskTest)
|
||||
{
|
||||
int finishCounter = 0;
|
||||
Condition cond;
|
||||
base::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1,
|
||||
std::ref(finishCounter), std::ref(cond)));
|
||||
base::ThreadPool pool(4,
|
||||
std::bind(&JoinFinishFunction, std::placeholders::_1, std::ref(finishCounter), std::ref(cond)));
|
||||
|
||||
for (int i = 0; i < TASK_COUNT - 1; ++i)
|
||||
pool.PushBack(new CancelTestTask(true));
|
||||
@@ -102,7 +85,7 @@ UNIT_TEST(ThreadPool_ExecutionTaskTest)
|
||||
pool.PushBack(p);
|
||||
p->Cancel();
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
std::unique_lock lock(cond.m);
|
||||
if (finishCounter == TASK_COUNT)
|
||||
@@ -115,8 +98,8 @@ UNIT_TEST(ThreadPool_EmptyTest)
|
||||
{
|
||||
int finishCouter = 0;
|
||||
Condition cond;
|
||||
base::ThreadPool pool(4, std::bind(&JoinFinishFunction, std::placeholders::_1,
|
||||
std::ref(finishCouter), std::ref(cond)));
|
||||
base::ThreadPool pool(4,
|
||||
std::bind(&JoinFinishFunction, std::placeholders::_1, std::ref(finishCouter), std::ref(cond)));
|
||||
|
||||
threads::Sleep(100);
|
||||
pool.Stop();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
|
||||
|
||||
UNIT_TEST(ThreadSafeQueue_ThreadSafeQueue)
|
||||
{
|
||||
threads::ThreadSafeQueue<size_t> queue;
|
||||
@@ -21,11 +20,7 @@ UNIT_TEST(ThreadSafeQueue_Push)
|
||||
threads::ThreadSafeQueue<size_t> queue;
|
||||
base::DelayedThreadPool pool(2, base::DelayedThreadPool::Exit::ExecPending);
|
||||
for (size_t i = 0; i < kSize; ++i)
|
||||
{
|
||||
pool.Push([&, i](){
|
||||
queue.Push(i);
|
||||
});
|
||||
}
|
||||
pool.Push([&, i]() { queue.Push(i); });
|
||||
|
||||
pool.ShutdownAndJoin();
|
||||
|
||||
@@ -38,7 +33,8 @@ UNIT_TEST(ThreadSafeQueue_WaitAndPop)
|
||||
threads::ThreadSafeQueue<size_t> queue;
|
||||
size_t const value = 101;
|
||||
size_t result;
|
||||
auto thread = std::thread([&]() {
|
||||
auto thread = std::thread([&]()
|
||||
{
|
||||
std::this_thread::sleep_for(10ms);
|
||||
queue.Push(value);
|
||||
});
|
||||
@@ -56,7 +52,8 @@ UNIT_TEST(ThreadSafeQueue_TryPop)
|
||||
threads::ThreadSafeQueue<size_t> queue;
|
||||
size_t const value = 101;
|
||||
size_t result;
|
||||
auto thread = std::thread([&]() {
|
||||
auto thread = std::thread([&]()
|
||||
{
|
||||
std::this_thread::sleep_for(10ms);
|
||||
queue.Push(value);
|
||||
});
|
||||
@@ -73,7 +70,8 @@ UNIT_TEST(ThreadSafeQueue_ExampleWithDataWrapper)
|
||||
size_t const kSize = 100000;
|
||||
threads::ThreadSafeQueue<std::optional<size_t>> queue;
|
||||
|
||||
auto thread = std::thread([&]() {
|
||||
auto thread = std::thread([&]()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
std::optional<size_t> dw;
|
||||
@@ -87,14 +85,8 @@ UNIT_TEST(ThreadSafeQueue_ExampleWithDataWrapper)
|
||||
|
||||
base::DelayedThreadPool pool(4, base::DelayedThreadPool::Exit::ExecPending);
|
||||
for (size_t i = 0; i < kSize; ++i)
|
||||
{
|
||||
pool.Push([&, i](){
|
||||
queue.Push(i);
|
||||
});
|
||||
}
|
||||
pool.Push([&](){
|
||||
queue.Push({});
|
||||
});
|
||||
pool.Push([&, i]() { queue.Push(i); });
|
||||
pool.Push([&]() { queue.Push({}); });
|
||||
|
||||
thread.join();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "base/threaded_list.hpp"
|
||||
#include "base/thread.hpp"
|
||||
#include "base/logging.hpp"
|
||||
#include "base/thread.hpp"
|
||||
#include "base/threaded_list.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -15,9 +15,11 @@ struct ThreadedListProcessor : public threads::IRoutine
|
||||
int m_id;
|
||||
|
||||
ThreadedListProcessor(ThreadedList<int> & p, std::mutex & resMutex, std::list<int> & res, int id)
|
||||
: m_p(p), m_resMutex(resMutex), m_res(res), m_id(id)
|
||||
{
|
||||
}
|
||||
: m_p(p)
|
||||
, m_resMutex(resMutex)
|
||||
, m_res(res)
|
||||
, m_id(id)
|
||||
{}
|
||||
|
||||
virtual void Do()
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "base/thread.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
using Vector = std::vector<int>;
|
||||
|
||||
@@ -38,20 +38,19 @@ struct ReaderThread : public threads::IRoutine
|
||||
Vector & m_vec;
|
||||
};
|
||||
|
||||
|
||||
UNIT_TEST(Simple_Threads)
|
||||
{
|
||||
Vector vec;
|
||||
|
||||
threads::Thread reader;
|
||||
bool ok = reader.Create(std::make_unique<GeneratorThread>(vec));
|
||||
TEST( ok, ("Create Generator thread") );
|
||||
TEST(ok, ("Create Generator thread"));
|
||||
|
||||
reader.Join();
|
||||
|
||||
threads::Thread writer;
|
||||
ok = writer.Create(std::make_unique<ReaderThread>(vec));
|
||||
TEST( ok, ("Create Reader thread") );
|
||||
TEST(ok, ("Create Reader thread"));
|
||||
|
||||
writer.Join();
|
||||
|
||||
@@ -65,10 +64,7 @@ class SomeClass
|
||||
|
||||
public:
|
||||
SomeClass() {}
|
||||
void Increment(int * a, int b)
|
||||
{
|
||||
*a = *a + b;
|
||||
}
|
||||
void Increment(int * a, int b) { *a = *a + b; }
|
||||
};
|
||||
|
||||
static void Increment(int * a, int b)
|
||||
@@ -80,7 +76,7 @@ UNIT_TEST(SimpleThreadTest1)
|
||||
{
|
||||
int a = 0;
|
||||
|
||||
auto fn = [&a](){ a = 1; };
|
||||
auto fn = [&a]() { a = 1; };
|
||||
|
||||
threads::SimpleThread t(fn);
|
||||
t.join();
|
||||
@@ -92,7 +88,7 @@ UNIT_TEST(SimpleThreadTest2)
|
||||
{
|
||||
int a = 0;
|
||||
|
||||
threads::SimpleThread t([&a](){ a = 1; });
|
||||
threads::SimpleThread t([&a]() { a = 1; });
|
||||
t.join();
|
||||
|
||||
TEST_EQUAL(a, 1, ("test a"));
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "base/timer.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "base/timer.hpp"
|
||||
|
||||
UNIT_TEST(Timer_Seconds)
|
||||
{
|
||||
@@ -11,7 +10,7 @@ UNIT_TEST(Timer_Seconds)
|
||||
double t1 = timer.ElapsedSeconds();
|
||||
double s = 0.0;
|
||||
for (int i = 0; i < 10000000; ++i)
|
||||
s += i*0.01;
|
||||
s += i * 0.01;
|
||||
double t2 = timer.ElapsedSeconds();
|
||||
|
||||
TEST_NOT_EQUAL(s, 0.0, ("Fictive, to prevent loop optimization"));
|
||||
|
||||
@@ -103,10 +103,7 @@ public:
|
||||
bool operator<(Entry const & rhs) const { return m_value > rhs.m_value; }
|
||||
};
|
||||
|
||||
explicit HeapBeam(size_t capacity) : m_capacity(capacity), m_size(0)
|
||||
{
|
||||
m_entries.reserve(m_capacity);
|
||||
}
|
||||
explicit HeapBeam(size_t capacity) : m_capacity(capacity), m_size(0) { m_entries.reserve(m_capacity); }
|
||||
|
||||
// Tries to add a key-value pair to the beam. Evicts the entry with the lowest
|
||||
// value if the insertion would result in an overspill.
|
||||
|
||||
@@ -7,10 +7,8 @@ namespace base
|
||||
{
|
||||
// A bidirectional map to store a one-to-one correspondence between
|
||||
// keys and values.
|
||||
template <typename K, typename V,
|
||||
template <typename ...> typename KToVMap = std::unordered_map,
|
||||
typename KToVHashOrComparator = std::hash<K>,
|
||||
template <typename ...> typename VToKMap = std::unordered_map,
|
||||
template <typename K, typename V, template <typename...> typename KToVMap = std::unordered_map,
|
||||
typename KToVHashOrComparator = std::hash<K>, template <typename...> typename VToKMap = std::unordered_map,
|
||||
typename VToKHashOrComparator = std::hash<V>>
|
||||
class BidirectionalMap
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace bits
|
||||
{
|
||||
static constexpr int SELECT1_ERROR = -1;
|
||||
|
||||
template <typename T> unsigned int select1(T x, unsigned int i)
|
||||
template <typename T>
|
||||
unsigned int select1(T x, unsigned int i)
|
||||
{
|
||||
// TODO: Fast implementation of select1.
|
||||
ASSERT(i > 0 && i <= sizeof(T) * 8, (i));
|
||||
@@ -104,17 +105,27 @@ inline void SetBitTo1(void * p, uint32_t offset)
|
||||
// Compute number of zero bits from the most significant bits side.
|
||||
constexpr uint32_t NumHiZeroBits32(uint32_t n)
|
||||
{
|
||||
if (n == 0) return 32;
|
||||
if (n == 0)
|
||||
return 32;
|
||||
uint32_t result = 0;
|
||||
while ((n & (uint32_t{1} << 31)) == 0) { ++result; n <<= 1; }
|
||||
while ((n & (uint32_t{1} << 31)) == 0)
|
||||
{
|
||||
++result;
|
||||
n <<= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr uint32_t NumHiZeroBits64(uint64_t n)
|
||||
{
|
||||
if (n == 0) return 64;
|
||||
if (n == 0)
|
||||
return 64;
|
||||
uint32_t result = 0;
|
||||
while ((n & (uint64_t{1} << 63)) == 0) { ++result; n <<= 1; }
|
||||
while ((n & (uint64_t{1} << 63)) == 0)
|
||||
{
|
||||
++result;
|
||||
n <<= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -123,16 +134,22 @@ constexpr uint32_t NumHiZeroBits64(uint64_t n)
|
||||
constexpr uint32_t NumUsedBits(uint64_t n)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
while (n != 0) { ++result; n >>= 1; }
|
||||
while (n != 0)
|
||||
{
|
||||
++result;
|
||||
n >>= 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr uint64_t GetFullMask(uint8_t numBits)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(numBits, 64, ());
|
||||
return numBits == 64 ? std::numeric_limits<uint64_t>::max()
|
||||
: (static_cast<uint64_t>(1) << numBits) - 1;
|
||||
return numBits == 64 ? std::numeric_limits<uint64_t>::max() : (static_cast<uint64_t>(1) << numBits) - 1;
|
||||
}
|
||||
|
||||
constexpr bool IsPow2Minus1(uint64_t n) { return (n & (n + 1)) == 0; }
|
||||
constexpr bool IsPow2Minus1(uint64_t n)
|
||||
{
|
||||
return (n & (n + 1)) == 0;
|
||||
}
|
||||
} // namespace bits
|
||||
|
||||
@@ -16,12 +16,14 @@ void Swap(T & a, T & b)
|
||||
swap(a, b);
|
||||
}
|
||||
|
||||
|
||||
template <class T, size_t N>
|
||||
class buffer_vector
|
||||
{
|
||||
private:
|
||||
enum { USE_DYNAMIC = N + 1 };
|
||||
enum
|
||||
{
|
||||
USE_DYNAMIC = N + 1
|
||||
};
|
||||
// TODO (@gmoryes) consider std::aligned_storage
|
||||
T m_static[N];
|
||||
size_t m_size;
|
||||
@@ -47,7 +49,7 @@ private:
|
||||
m_size = newSize;
|
||||
}
|
||||
|
||||
static constexpr size_t SwitchCapacity() { return 3*N/2 + 1; }
|
||||
static constexpr size_t SwitchCapacity() { return 3 * N / 2 + 1; }
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
@@ -58,10 +60,7 @@ public:
|
||||
typedef T * iterator;
|
||||
|
||||
buffer_vector() : m_size(0) {}
|
||||
explicit buffer_vector(size_t n) : m_size(0)
|
||||
{
|
||||
resize(n);
|
||||
}
|
||||
explicit buffer_vector(size_t n) : m_size(0) { resize(n); }
|
||||
|
||||
buffer_vector(std::initializer_list<T> init) : m_size(0)
|
||||
{
|
||||
@@ -243,10 +242,10 @@ public:
|
||||
|
||||
T const * begin() const { return data(); }
|
||||
T const * cbegin() const { return data(); }
|
||||
T * begin() { return data(); }
|
||||
T * begin() { return data(); }
|
||||
T const * end() const { return data() + size(); }
|
||||
T const * cend() const { return data() + size(); }
|
||||
T * end() { return data() + size(); }
|
||||
T * end() { return data() + size(); }
|
||||
//@}
|
||||
|
||||
bool empty() const { return (IsDynamic() ? m_dynamic.empty() : m_size == 0); }
|
||||
@@ -304,7 +303,7 @@ public:
|
||||
if (m_size < N)
|
||||
{
|
||||
m_static[m_size] = std::move(t);
|
||||
++m_size; // keep basic exception safety here
|
||||
++m_size; // keep basic exception safety here
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -333,24 +332,22 @@ public:
|
||||
{
|
||||
m_dynamic.emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
else if (m_size < N)
|
||||
{
|
||||
m_static[m_size] = value_type(std::forward<Args>(args)...);
|
||||
++m_size; // keep basic exception safety here
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_size < N)
|
||||
{
|
||||
m_static[m_size] = value_type(std::forward<Args>(args)...);
|
||||
++m_size; // keep basic exception safety here
|
||||
}
|
||||
else
|
||||
{
|
||||
// Construct value first in case of reallocation and m_vec.emplace_back(m_vec[0]).
|
||||
value_type value(std::forward<Args>(args)...);
|
||||
SwitchToDynamic(SwitchCapacity());
|
||||
m_dynamic.push_back(std::move(value));
|
||||
}
|
||||
// Construct value first in case of reallocation and m_vec.emplace_back(m_vec[0]).
|
||||
value_type value(std::forward<Args>(args)...);
|
||||
SwitchToDynamic(SwitchCapacity());
|
||||
m_dynamic.push_back(std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TIt> void insert(const_iterator where, TIt beg, TIt end)
|
||||
template <typename TIt>
|
||||
void insert(const_iterator where, TIt beg, TIt end)
|
||||
{
|
||||
size_t const pos = base::asserted_cast<size_t>(where - data());
|
||||
ASSERT_LESS_OR_EQUAL(pos, size(), ());
|
||||
@@ -365,10 +362,8 @@ public:
|
||||
if (m_size + n <= N)
|
||||
{
|
||||
if (pos != m_size)
|
||||
{
|
||||
for (size_t i = m_size - 1; i >= pos && i < m_size; --i)
|
||||
Swap(m_static[i], m_static[i + n]);
|
||||
}
|
||||
|
||||
m_size += n;
|
||||
T * writableWhere = &m_static[0] + pos;
|
||||
@@ -383,10 +378,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void insert(const_iterator where, value_type const & value)
|
||||
{
|
||||
insert(where, &value, &value + 1);
|
||||
}
|
||||
void insert(const_iterator where, value_type const & value) { insert(where, &value, &value + 1); }
|
||||
|
||||
template <class Fn>
|
||||
void erase_if(Fn && fn)
|
||||
@@ -405,9 +397,7 @@ public:
|
||||
|
||||
auto const numToErase = std::distance(first, last);
|
||||
for (; first != end() - numToErase; ++first)
|
||||
{
|
||||
Swap(*first, *(first + numToErase));
|
||||
}
|
||||
resize(std::distance(begin(), first));
|
||||
}
|
||||
void erase(iterator it) { erase(it, it + 1); }
|
||||
@@ -483,7 +473,8 @@ typename buffer_vector<T, N>::const_iterator end(buffer_vector<T, N> const & v)
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
template <class Dest, class Src> void assign_range(Dest & dest, Src const & src)
|
||||
template <class Dest, class Src>
|
||||
void assign_range(Dest & dest, Src const & src)
|
||||
{
|
||||
dest.assign(std::begin(src), std::end(src));
|
||||
}
|
||||
|
||||
@@ -10,161 +10,148 @@
|
||||
|
||||
namespace base
|
||||
{
|
||||
// Simple cache that stores list of values.
|
||||
template <typename KeyT, typename ValueT> class Cache
|
||||
// Simple cache that stores list of values.
|
||||
template <typename KeyT, typename ValueT>
|
||||
class Cache
|
||||
{
|
||||
DISALLOW_COPY(Cache);
|
||||
|
||||
public:
|
||||
Cache() = default;
|
||||
Cache(Cache && r) = default;
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
explicit Cache(uint32_t logCacheSize) { Init(logCacheSize); }
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
void Init(uint32_t logCacheSize)
|
||||
{
|
||||
DISALLOW_COPY(Cache);
|
||||
ASSERT(logCacheSize > 0 && logCacheSize < 32, (logCacheSize));
|
||||
static_assert((std::is_same<KeyT, uint32_t>::value || std::is_same<KeyT, uint64_t>::value), "");
|
||||
|
||||
public:
|
||||
Cache() = default;
|
||||
Cache(Cache && r) = default;
|
||||
m_cache.reset(new Data[1 << logCacheSize]);
|
||||
m_hashMask = (1 << logCacheSize) - 1;
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
explicit Cache(uint32_t logCacheSize)
|
||||
Reset();
|
||||
}
|
||||
|
||||
uint32_t GetCacheSize() const { return m_hashMask + 1; }
|
||||
|
||||
// Find value by @key. If @key is found, returns reference to its value.
|
||||
// If @key is not found, some other key is removed and it's value is reused without
|
||||
// re-initialization. It's up to caller to re-initialize the new value if @found == false.
|
||||
// TODO: Return pair<ValueT *, bool> instead?
|
||||
ValueT & Find(KeyT const & key, bool & found)
|
||||
{
|
||||
Data & data = m_cache[Index(key)];
|
||||
if (data.m_Key == key)
|
||||
{
|
||||
Init(logCacheSize);
|
||||
found = true;
|
||||
}
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
void Init(uint32_t logCacheSize)
|
||||
else
|
||||
{
|
||||
ASSERT(logCacheSize > 0 && logCacheSize < 32, (logCacheSize));
|
||||
static_assert((std::is_same<KeyT, uint32_t>::value || std::is_same<KeyT, uint64_t>::value), "");
|
||||
|
||||
m_cache.reset(new Data[1 << logCacheSize]);
|
||||
m_hashMask = (1 << logCacheSize) - 1;
|
||||
|
||||
Reset();
|
||||
found = false;
|
||||
data.m_Key = key;
|
||||
}
|
||||
return data.m_Value;
|
||||
}
|
||||
|
||||
uint32_t GetCacheSize() const
|
||||
template <typename F>
|
||||
void ForEachValue(F && f)
|
||||
{
|
||||
for (uint32_t i = 0; i <= m_hashMask; ++i)
|
||||
f(m_cache[i].m_Value);
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
// Initialize m_Cache such, that Index(m_Cache[i].m_Key) != i.
|
||||
for (uint32_t i = 0; i <= m_hashMask; ++i)
|
||||
{
|
||||
return m_hashMask + 1;
|
||||
KeyT & key = m_cache[i].m_Key;
|
||||
for (key = 0; Index(key) == i; ++key)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
// Find value by @key. If @key is found, returns reference to its value.
|
||||
// If @key is not found, some other key is removed and it's value is reused without
|
||||
// re-initialization. It's up to caller to re-initialize the new value if @found == false.
|
||||
// TODO: Return pair<ValueT *, bool> instead?
|
||||
ValueT & Find(KeyT const & key, bool & found)
|
||||
{
|
||||
Data & data = m_cache[Index(key)];
|
||||
if (data.m_Key == key)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
found = false;
|
||||
data.m_Key = key;
|
||||
}
|
||||
return data.m_Value;
|
||||
}
|
||||
private:
|
||||
size_t Index(KeyT const & key) const { return static_cast<size_t>(Hash(key) & m_hashMask); }
|
||||
|
||||
template <typename F>
|
||||
void ForEachValue(F && f)
|
||||
{
|
||||
for (uint32_t i = 0; i <= m_hashMask; ++i)
|
||||
f(m_cache[i].m_Value);
|
||||
}
|
||||
static uint32_t Hash(uint32_t x)
|
||||
{
|
||||
x = (x ^ 61) ^ (x >> 16);
|
||||
x = x + (x << 3);
|
||||
x = x ^ (x >> 4);
|
||||
x = x * 0x27d4eb2d;
|
||||
x = x ^ (x >> 15);
|
||||
return x;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
// Initialize m_Cache such, that Index(m_Cache[i].m_Key) != i.
|
||||
for (uint32_t i = 0; i <= m_hashMask; ++i)
|
||||
{
|
||||
KeyT & key = m_cache[i].m_Key;
|
||||
for (key = 0; Index(key) == i; ++key) ;
|
||||
}
|
||||
}
|
||||
static uint32_t Hash(uint64_t x) { return Hash(uint32_t(x) ^ uint32_t(x >> 32)); }
|
||||
|
||||
private:
|
||||
size_t Index(KeyT const & key) const
|
||||
{
|
||||
return static_cast<size_t>(Hash(key) & m_hashMask);
|
||||
}
|
||||
|
||||
static uint32_t Hash(uint32_t x)
|
||||
{
|
||||
x = (x ^ 61) ^ (x >> 16);
|
||||
x = x + (x << 3);
|
||||
x = x ^ (x >> 4);
|
||||
x = x * 0x27d4eb2d;
|
||||
x = x ^ (x >> 15);
|
||||
return x;
|
||||
}
|
||||
|
||||
static uint32_t Hash(uint64_t x)
|
||||
{
|
||||
return Hash(uint32_t(x) ^ uint32_t(x >> 32));
|
||||
}
|
||||
|
||||
// TODO: Consider using separate arrays for keys and values, to save on padding.
|
||||
struct Data
|
||||
{
|
||||
Data() : m_Key(), m_Value() {}
|
||||
KeyT m_Key;
|
||||
ValueT m_Value;
|
||||
};
|
||||
|
||||
std::unique_ptr<Data[]> m_cache;
|
||||
uint32_t m_hashMask;
|
||||
// TODO: Consider using separate arrays for keys and values, to save on padding.
|
||||
struct Data
|
||||
{
|
||||
Data() : m_Key(), m_Value() {}
|
||||
KeyT m_Key;
|
||||
ValueT m_Value;
|
||||
};
|
||||
|
||||
// Simple cache that stores list of values and provides cache missing statistics.
|
||||
// CacheWithStat class has the same interface as Cache class
|
||||
template <typename TKey, typename TValue>
|
||||
class CacheWithStat
|
||||
std::unique_ptr<Data[]> m_cache;
|
||||
uint32_t m_hashMask;
|
||||
};
|
||||
|
||||
// Simple cache that stores list of values and provides cache missing statistics.
|
||||
// CacheWithStat class has the same interface as Cache class
|
||||
template <typename TKey, typename TValue>
|
||||
class CacheWithStat
|
||||
{
|
||||
public:
|
||||
CacheWithStat() = default;
|
||||
|
||||
explicit CacheWithStat(uint32_t logCacheSize) : m_cache(logCacheSize), m_miss(0), m_access(0) {}
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
void Init(uint32_t logCacheSize)
|
||||
{
|
||||
public:
|
||||
CacheWithStat() = default;
|
||||
m_cache.Init(logCacheSize);
|
||||
m_miss = m_access = 0;
|
||||
}
|
||||
|
||||
explicit CacheWithStat(uint32_t logCacheSize)
|
||||
: m_cache(logCacheSize), m_miss(0), m_access(0)
|
||||
{
|
||||
}
|
||||
double GetCacheMiss() const
|
||||
{
|
||||
if (m_access == 0)
|
||||
return 0.0;
|
||||
return static_cast<double>(m_miss) / static_cast<double>(m_access);
|
||||
}
|
||||
|
||||
/// @param[in] logCacheSize is pow of two for number of elements in cache.
|
||||
void Init(uint32_t logCacheSize)
|
||||
{
|
||||
m_cache.Init(logCacheSize);
|
||||
m_miss = m_access = 0;
|
||||
}
|
||||
uint32_t GetCacheSize() const { return m_cache.GetCacheSize(); }
|
||||
|
||||
double GetCacheMiss() const
|
||||
{
|
||||
if (m_access == 0)
|
||||
return 0.0;
|
||||
return static_cast<double>(m_miss) / static_cast<double>(m_access);
|
||||
}
|
||||
TValue & Find(TKey const & key, bool & found)
|
||||
{
|
||||
++m_access;
|
||||
TValue & res = m_cache.Find(key, found);
|
||||
if (!found)
|
||||
++m_miss;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t GetCacheSize() const { return m_cache.GetCacheSize(); }
|
||||
template <typename F>
|
||||
void ForEachValue(F && f)
|
||||
{
|
||||
m_cache.ForEachValue(std::forward<F>(f));
|
||||
}
|
||||
|
||||
TValue & Find(TKey const & key, bool & found)
|
||||
{
|
||||
++m_access;
|
||||
TValue & res = m_cache.Find(key, found);
|
||||
if (!found)
|
||||
++m_miss;
|
||||
return res;
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
m_cache.Reset();
|
||||
m_access = 0;
|
||||
m_miss = 0;
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void ForEachValue(F && f)
|
||||
{
|
||||
m_cache.ForEachValue(std::forward<F>(f));
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_cache.Reset();
|
||||
m_access = 0;
|
||||
m_miss = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Cache<TKey, TValue> m_cache;
|
||||
uint64_t m_miss;
|
||||
uint64_t m_access;
|
||||
};
|
||||
private:
|
||||
Cache<TKey, TValue> m_cache;
|
||||
uint64_t m_miss;
|
||||
uint64_t m_access;
|
||||
};
|
||||
} // namespace base
|
||||
|
||||
@@ -42,11 +42,8 @@ Cancellable::Status Cancellable::CancellationStatus() const
|
||||
|
||||
void Cancellable::CheckDeadline() const
|
||||
{
|
||||
if (m_status == Status::Active &&
|
||||
m_deadline && *m_deadline < std::chrono::steady_clock::now())
|
||||
{
|
||||
if (m_status == Status::Active && m_deadline && *m_deadline < std::chrono::steady_clock::now())
|
||||
m_status = Status::DeadlineExceeded;
|
||||
}
|
||||
}
|
||||
|
||||
std::string DebugPrint(Cancellable::Status status)
|
||||
|
||||
@@ -37,10 +37,7 @@ public:
|
||||
entry.m_values.push_back(std::forward<V>(value));
|
||||
}
|
||||
|
||||
void Delete(Key const & key)
|
||||
{
|
||||
m_table.erase(key);
|
||||
}
|
||||
void Delete(Key const & key) { m_table.erase(key); }
|
||||
|
||||
// Unions clusters corresponding to |u| and |v|.
|
||||
//
|
||||
@@ -75,10 +72,7 @@ public:
|
||||
{
|
||||
EntryWithKey(Entry const * entry, Key const & key) : m_entry(entry), m_key(key) {}
|
||||
|
||||
bool operator<(EntryWithKey const & rhs) const
|
||||
{
|
||||
return m_entry->m_root < rhs.m_entry->m_root;
|
||||
}
|
||||
bool operator<(EntryWithKey const & rhs) const { return m_entry->m_root < rhs.m_entry->m_root; }
|
||||
|
||||
Entry const * m_entry;
|
||||
Key m_key;
|
||||
|
||||
@@ -21,7 +21,7 @@ using TValueType = typename ValueType<T>::TType;
|
||||
// More examples:
|
||||
// auto const mySet = collection_cast<set>("aaabcccd");
|
||||
// auto const myMap = collection_cast<map>(vector<pair<int, int>>{{1, 2}, {3, 4}});
|
||||
template <template<typename ... TArgs> class TTo, typename TFrom>
|
||||
template <template <typename... TArgs> class TTo, typename TFrom>
|
||||
auto collection_cast(TFrom && from) -> TTo<details::TValueType<TFrom>>
|
||||
{
|
||||
return TTo<details::TValueType<TFrom>>(begin(from), end(from));
|
||||
|
||||
@@ -20,19 +20,17 @@ class ControlFlowWrapper
|
||||
public:
|
||||
template <typename Gn>
|
||||
explicit ControlFlowWrapper(Gn && gn) : m_fn(std::forward<Gn>(gn))
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
template <typename... Args>
|
||||
std::enable_if_t<std::is_same_v<std::invoke_result_t<Fn, Args...>, ControlFlow>, ControlFlow>
|
||||
operator()(Args &&... args)
|
||||
std::enable_if_t<std::is_same_v<std::invoke_result_t<Fn, Args...>, ControlFlow>, ControlFlow> operator()(
|
||||
Args &&... args)
|
||||
{
|
||||
return m_fn(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
std::enable_if_t<std::is_same_v<std::invoke_result_t<Fn, Args...>, void>, ControlFlow>
|
||||
operator()(Args &&... args)
|
||||
std::enable_if_t<std::is_same_v<std::invoke_result_t<Fn, Args...>, void>, ControlFlow> operator()(Args &&... args)
|
||||
{
|
||||
m_fn(std::forward<Args>(args)...);
|
||||
return ControlFlow::Continue;
|
||||
|
||||
@@ -5,10 +5,8 @@ RootException::RootException(char const * what, std::string const & msg) : m_msg
|
||||
std::string asciiMsg(m_msg.size(), '?');
|
||||
|
||||
for (size_t i = 0; i < m_msg.size(); ++i)
|
||||
{
|
||||
if (static_cast<unsigned char>(m_msg[i]) < 128)
|
||||
asciiMsg[i] = static_cast<char>(m_msg[i]);
|
||||
}
|
||||
|
||||
m_whatWithAscii = std::string(what) + ", \"" + asciiMsg + "\"";
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
std::invoke_result_t<Fn&&, Args&&...> ExceptionCatcher(std::string const & comment,
|
||||
bool & exceptionWasThrown, Fn && fn,
|
||||
Args &&... args) noexcept
|
||||
std::invoke_result_t<Fn &&, Args &&...> ExceptionCatcher(std::string const & comment, bool & exceptionWasThrown,
|
||||
Fn && fn, Args &&... args) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -48,24 +47,24 @@ std::invoke_result_t<Fn&&, Args&&...> ExceptionCatcher(std::string const & comme
|
||||
}
|
||||
|
||||
exceptionWasThrown = true;
|
||||
using ReturnType = std::decay_t<std::invoke_result_t<Fn&&, Args&&...>>;
|
||||
using ReturnType = std::decay_t<std::invoke_result_t<Fn &&, Args &&...>>;
|
||||
if constexpr (!std::is_same_v<void, ReturnType>)
|
||||
{
|
||||
static const ReturnType defaultResult = {};
|
||||
static ReturnType const defaultResult = {};
|
||||
return defaultResult;
|
||||
}
|
||||
}
|
||||
|
||||
#define DECLARE_EXCEPTION(exception_name, base_exception) \
|
||||
class exception_name : public base_exception \
|
||||
{ \
|
||||
public: \
|
||||
#define DECLARE_EXCEPTION(exception_name, base_exception) \
|
||||
class exception_name : public base_exception \
|
||||
{ \
|
||||
public: \
|
||||
exception_name(char const * what, std::string const & msg) : base_exception(what, msg) {} \
|
||||
}
|
||||
|
||||
// TODO: Use SRC_LOGGING macro.
|
||||
#define MYTHROW(exception_name, msg) throw exception_name( \
|
||||
#exception_name " " __FILE__ ":" TO_STRING(__LINE__), ::base::Message msg)
|
||||
#define MYTHROW(exception_name, msg) \
|
||||
throw exception_name(#exception_name " " __FILE__ ":" TO_STRING(__LINE__), ::base::Message msg)
|
||||
|
||||
#define MYTHROW1(exception_name, param1, msg) throw exception_name(param1, \
|
||||
#exception_name " " __FILE__ ":" TO_STRING(__LINE__), ::base::Message msg)
|
||||
#define MYTHROW1(exception_name, param1, msg) \
|
||||
throw exception_name(param1, #exception_name " " __FILE__ ":" TO_STRING(__LINE__), ::base::Message msg)
|
||||
|
||||
@@ -16,4 +16,4 @@ bool is_finite(double t)
|
||||
{
|
||||
return std::isfinite(t);
|
||||
}
|
||||
} // namespace base
|
||||
} // namespace math
|
||||
|
||||
@@ -15,20 +15,18 @@
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
template<class Key, class Value, class HashContainer = std::unordered_map<Key, Value>>
|
||||
template <class Key, class Value, class HashContainer = std::unordered_map<Key, Value>>
|
||||
class FifoCache
|
||||
{
|
||||
template <typename K, typename V> friend class FifoCacheTest;
|
||||
template <typename K, typename V>
|
||||
friend class FifoCacheTest;
|
||||
|
||||
public:
|
||||
using Loader = std::function<void(Key const & key, Value & value)>;
|
||||
|
||||
/// \param capacity maximum size of the cache in number of items.
|
||||
/// \param loader Function which is called if it's necessary to load a new item for the cache.
|
||||
FifoCache(size_t capacity, Loader const & loader)
|
||||
: m_fifo(capacity), m_capacity(capacity), m_loader(loader)
|
||||
{
|
||||
}
|
||||
FifoCache(size_t capacity, Loader const & loader) : m_fifo(capacity), m_capacity(capacity), m_loader(loader) {}
|
||||
|
||||
/// \brief Loads value, if it's necessary, by |key| with |m_loader|, puts it to cache and
|
||||
/// returns the reference to the value to |m_map|.
|
||||
|
||||
@@ -27,7 +27,7 @@ void GetNameFromFullPath(string & name)
|
||||
{
|
||||
string::size_type const i = name.find_last_of("/\\");
|
||||
if (i != string::npos)
|
||||
name = name.substr(i+1);
|
||||
name = name.substr(i + 1);
|
||||
}
|
||||
|
||||
std::string FileNameFromFullPath(std::string path)
|
||||
@@ -59,9 +59,9 @@ string GetDirectory(string const & name)
|
||||
string::value_type GetNativeSeparator()
|
||||
{
|
||||
#ifdef OMIM_OS_WINDOWS
|
||||
return '\\';
|
||||
return '\\';
|
||||
#else
|
||||
return '/';
|
||||
return '/';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,10 @@ std::string AddSlashIfNeeded(std::string const & path);
|
||||
|
||||
namespace impl
|
||||
{
|
||||
inline std::string JoinPath(std::string const & file) { return file; }
|
||||
inline std::string JoinPath(std::string const & file)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
std::string JoinPath(std::string const & folder, Args &&... args)
|
||||
|
||||
@@ -10,17 +10,16 @@ namespace
|
||||
// and add assertions about the highest bit.
|
||||
// The old scheme used the highest bit and the new one does not.
|
||||
// uint64_t const kTypeMask = 0x7F00000000000000;
|
||||
uint64_t const kTypeMask = 0xFF00000000000000;
|
||||
uint64_t const kReservedMask = 0x00FF000000000000;
|
||||
uint64_t const kSerialMask = 0x0000FFFFFFFFFFFF;
|
||||
uint64_t const kTypeMask = 0xFF00000000000000;
|
||||
uint64_t const kReservedMask = 0x00FF000000000000;
|
||||
uint64_t const kSerialMask = 0x0000FFFFFFFFFFFF;
|
||||
} // namespace
|
||||
|
||||
namespace base
|
||||
{
|
||||
GeoObjectId::GeoObjectId(uint64_t encodedId) : m_encodedId(encodedId) {}
|
||||
|
||||
GeoObjectId::GeoObjectId(Type type, uint64_t id)
|
||||
: m_encodedId((static_cast<uint64_t>(type) << 56) | id) {}
|
||||
GeoObjectId::GeoObjectId(Type type, uint64_t id) : m_encodedId((static_cast<uint64_t>(type) << 56) | id) {}
|
||||
|
||||
uint64_t GeoObjectId::GetSerialId() const
|
||||
{
|
||||
@@ -29,7 +28,10 @@ uint64_t GeoObjectId::GetSerialId() const
|
||||
return m_encodedId & kSerialMask;
|
||||
}
|
||||
|
||||
uint64_t GeoObjectId::GetEncodedId() const { return m_encodedId; }
|
||||
uint64_t GeoObjectId::GetEncodedId() const
|
||||
{
|
||||
return m_encodedId;
|
||||
}
|
||||
|
||||
GeoObjectId::Type GeoObjectId::GetType() const
|
||||
{
|
||||
|
||||
@@ -22,11 +22,18 @@
|
||||
|
||||
/// @name Declarations.
|
||||
//@{
|
||||
template <typename T> inline std::string DebugPrint(T const & t);
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(T const & t);
|
||||
|
||||
inline std::string DebugPrint(std::string s) { return s; }
|
||||
inline std::string DebugPrint(std::string s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
inline std::string DebugPrint(char const * t);
|
||||
inline std::string DebugPrint(char * t) { return DebugPrint(static_cast<char const *>(t)); }
|
||||
inline std::string DebugPrint(char * t)
|
||||
{
|
||||
return DebugPrint(static_cast<char const *>(t));
|
||||
}
|
||||
inline std::string DebugPrint(char t);
|
||||
inline std::string DebugPrint(char32_t t);
|
||||
|
||||
@@ -38,14 +45,22 @@ std::string DebugPrint(char32_t const * t) = delete;
|
||||
std::string DebugPrint(char32_t * t) = delete;
|
||||
/// @}
|
||||
|
||||
template <typename U, typename V> inline std::string DebugPrint(std::pair<U, V> const & p);
|
||||
template <typename T> inline std::string DebugPrint(std::list<T> const & v);
|
||||
template <typename T> inline std::string DebugPrint(std::vector<T> const & v);
|
||||
template <typename T, typename C = std::less<T>> inline std::string DebugPrint(std::set<T, C> const & v);
|
||||
template <typename T, typename C = std::less<T>> inline std::string DebugPrint(std::multiset<T, C> const & v);
|
||||
template <typename U, typename V, typename C = std::less<U>> inline std::string DebugPrint(std::map<U, V, C> const & v);
|
||||
template <typename T> inline std::string DebugPrint(std::initializer_list<T> const & v);
|
||||
template <typename T> inline std::string DebugPrint(std::unique_ptr<T> const & v);
|
||||
template <typename U, typename V>
|
||||
inline std::string DebugPrint(std::pair<U, V> const & p);
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::list<T> const & v);
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::vector<T> const & v);
|
||||
template <typename T, typename C = std::less<T>>
|
||||
inline std::string DebugPrint(std::set<T, C> const & v);
|
||||
template <typename T, typename C = std::less<T>>
|
||||
inline std::string DebugPrint(std::multiset<T, C> const & v);
|
||||
template <typename U, typename V, typename C = std::less<U>>
|
||||
inline std::string DebugPrint(std::map<U, V, C> const & v);
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::initializer_list<T> const & v);
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::unique_ptr<T> const & v);
|
||||
|
||||
template <class Key, class Hash = std::hash<Key>, class Pred = std::equal_to<Key>>
|
||||
inline std::string DebugPrint(std::unordered_set<Key, Hash, Pred> const & v);
|
||||
@@ -53,7 +68,8 @@ template <class Key, class T, class Hash = std::hash<Key>, class Pred = std::equ
|
||||
inline std::string DebugPrint(std::unordered_map<Key, T, Hash, Pred> const & v);
|
||||
//@}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(T const & t)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(T const & t)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << t;
|
||||
@@ -151,50 +167,58 @@ std::string inline DebugPrint(std::nullopt_t const & p)
|
||||
|
||||
// Avoid calling it for string literals.
|
||||
template <typename T, size_t N,
|
||||
typename = std::enable_if_t<!std::is_same<typename std::remove_cv<T>::type, char>::value &&
|
||||
!std::is_same<typename std::remove_cv<T>::type, char16_t>::value &&
|
||||
!std::is_same<typename std::remove_cv<T>::type, char32_t>::value>>
|
||||
inline std::string DebugPrint(T (&arr) [N])
|
||||
typename = std::enable_if_t<!std::is_same<typename std::remove_cv<T>::type, char>::value &&
|
||||
!std::is_same<typename std::remove_cv<T>::type, char16_t>::value &&
|
||||
!std::is_same<typename std::remove_cv<T>::type, char32_t>::value>>
|
||||
inline std::string DebugPrint(T (&arr)[N])
|
||||
{
|
||||
return DebugPrintSequence(arr, arr + N);
|
||||
}
|
||||
|
||||
template <typename T, size_t N> inline std::string DebugPrint(std::array<T, N> const & v)
|
||||
template <typename T, size_t N>
|
||||
inline std::string DebugPrint(std::array<T, N> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(std::vector<T> const & v)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::vector<T> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(std::deque<T> const & d)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::deque<T> const & d)
|
||||
{
|
||||
return DebugPrintSequence(d.begin(), d.end());
|
||||
}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(std::list<T> const & v)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::list<T> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T, typename C> inline std::string DebugPrint(std::set<T, C> const & v)
|
||||
template <typename T, typename C>
|
||||
inline std::string DebugPrint(std::set<T, C> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T, typename C> inline std::string DebugPrint(std::multiset<T, C> const & v)
|
||||
template <typename T, typename C>
|
||||
inline std::string DebugPrint(std::multiset<T, C> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename U, typename V, typename C> inline std::string DebugPrint(std::map<U, V, C> const & v)
|
||||
template <typename U, typename V, typename C>
|
||||
inline std::string DebugPrint(std::map<U, V, C> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(std::initializer_list<T> const & v)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::initializer_list<T> const & v)
|
||||
{
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
@@ -211,7 +235,8 @@ inline std::string DebugPrint(std::unordered_map<Key, T, Hash, Pred> const & v)
|
||||
return DebugPrintSequence(v.begin(), v.end());
|
||||
}
|
||||
|
||||
template <typename T> inline std::string DebugPrint(std::unique_ptr<T> const & v)
|
||||
template <typename T>
|
||||
inline std::string DebugPrint(std::unique_ptr<T> const & v)
|
||||
{
|
||||
std::ostringstream out;
|
||||
if (v.get() != nullptr)
|
||||
@@ -223,7 +248,10 @@ template <typename T> inline std::string DebugPrint(std::unique_ptr<T> const & v
|
||||
|
||||
namespace base
|
||||
{
|
||||
inline std::string Message() { return {}; }
|
||||
inline std::string Message()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Message(T const & t)
|
||||
|
||||
@@ -13,16 +13,20 @@ namespace strings
|
||||
{
|
||||
namespace
|
||||
{
|
||||
size_t AbsDiff(size_t a, size_t b) { return a > b ? a - b : b - a; }
|
||||
size_t AbsDiff(size_t a, size_t b)
|
||||
{
|
||||
return a > b ? a - b : b - a;
|
||||
}
|
||||
|
||||
class TransitionTable
|
||||
{
|
||||
public:
|
||||
TransitionTable(UniString const & s, std::vector<UniString> const & prefixMisprints,
|
||||
size_t prefixSize)
|
||||
: m_s(s), m_size(s.size()), m_prefixMisprints(prefixMisprints), m_prefixSize(prefixSize)
|
||||
{
|
||||
}
|
||||
TransitionTable(UniString const & s, std::vector<UniString> const & prefixMisprints, size_t prefixSize)
|
||||
: m_s(s)
|
||||
, m_size(s.size())
|
||||
, m_prefixMisprints(prefixMisprints)
|
||||
, m_prefixSize(prefixSize)
|
||||
{}
|
||||
|
||||
void Move(LevenshteinDFA::State const & s, UniChar c, LevenshteinDFA::State & t)
|
||||
{
|
||||
@@ -87,10 +91,8 @@ private:
|
||||
size_t const limit = std::min(m_size - p.m_offset, p.m_errorsLeft + 1);
|
||||
|
||||
for (i = 0; i < limit; ++i)
|
||||
{
|
||||
if (m_s[p.m_offset + i] == c)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,10 +101,8 @@ private:
|
||||
CHECK_LESS(position, m_prefixSize, ());
|
||||
|
||||
for (auto const & misprints : m_prefixMisprints)
|
||||
{
|
||||
if (base::IsExist(misprints, c) && base::IsExist(misprints, m_s[position]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -120,9 +120,10 @@ size_t const LevenshteinDFA::kRejectingState = 1;
|
||||
|
||||
// LevenshteinDFA::Position ------------------------------------------------------------------------
|
||||
LevenshteinDFA::Position::Position(size_t offset, size_t errorsLeft, bool transposed)
|
||||
: m_offset(offset), m_errorsLeft(errorsLeft), m_transposed(transposed)
|
||||
{
|
||||
}
|
||||
: m_offset(offset)
|
||||
, m_errorsLeft(errorsLeft)
|
||||
, m_transposed(transposed)
|
||||
{}
|
||||
|
||||
bool LevenshteinDFA::Position::SubsumedBy(Position const & rhs) const
|
||||
{
|
||||
@@ -156,8 +157,7 @@ bool LevenshteinDFA::Position::operator<(Position const & rhs) const
|
||||
|
||||
bool LevenshteinDFA::Position::operator==(Position const & rhs) const
|
||||
{
|
||||
return m_offset == rhs.m_offset && m_errorsLeft == rhs.m_errorsLeft &&
|
||||
m_transposed == rhs.m_transposed;
|
||||
return m_offset == rhs.m_offset && m_errorsLeft == rhs.m_errorsLeft && m_transposed == rhs.m_transposed;
|
||||
}
|
||||
|
||||
// LevenshteinDFA::State ---------------------------------------------------------------------------
|
||||
@@ -190,31 +190,27 @@ void LevenshteinDFA::State::Normalize()
|
||||
|
||||
// LevenshteinDFA ----------------------------------------------------------------------------------
|
||||
// static
|
||||
LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize,
|
||||
std::vector<UniString> const & prefixMisprints, size_t maxErrors)
|
||||
: m_size(s.size()), m_maxErrors(maxErrors)
|
||||
LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize, std::vector<UniString> const & prefixMisprints,
|
||||
size_t maxErrors)
|
||||
: m_size(s.size())
|
||||
, m_maxErrors(maxErrors)
|
||||
{
|
||||
m_alphabet.assign(s.begin(), s.end());
|
||||
CHECK_LESS_OR_EQUAL(prefixSize, s.size(), ());
|
||||
|
||||
auto const pSize = static_cast<std::iterator_traits<
|
||||
UniString::iterator>::difference_type>(prefixSize);
|
||||
auto const pSize = static_cast<std::iterator_traits<UniString::iterator>::difference_type>(prefixSize);
|
||||
for (auto it = s.begin(); std::distance(s.begin(), it) < pSize; ++it)
|
||||
{
|
||||
for (auto const & misprints : prefixMisprints)
|
||||
{
|
||||
if (base::IsExist(misprints, *it))
|
||||
m_alphabet.insert(m_alphabet.end(), misprints.begin(), misprints.end());
|
||||
}
|
||||
}
|
||||
base::SortUnique(m_alphabet);
|
||||
|
||||
UniChar missed = 0;
|
||||
for (size_t i = 0; i < m_alphabet.size() && missed >= m_alphabet[i]; ++i)
|
||||
{
|
||||
if (missed == m_alphabet[i])
|
||||
++missed;
|
||||
}
|
||||
m_alphabet.push_back(missed);
|
||||
|
||||
std::queue<State> states;
|
||||
@@ -279,24 +275,20 @@ LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize,
|
||||
|
||||
LevenshteinDFA::LevenshteinDFA(std::string const & s, size_t prefixSize, size_t maxErrors)
|
||||
: LevenshteinDFA(MakeUniString(s), prefixSize, {} /* prefixMisprints */, maxErrors)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t maxErrors)
|
||||
: LevenshteinDFA(s, 0 /* prefixSize */, {} /* prefixMisprints */, maxErrors)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
LevenshteinDFA::LevenshteinDFA(std::string const & s, size_t maxErrors)
|
||||
: LevenshteinDFA(MakeUniString(s), 0 /* prefixSize */, {} /* prefixMisprints */, maxErrors)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
LevenshteinDFA::State LevenshteinDFA::MakeStart()
|
||||
{
|
||||
State state;
|
||||
state.m_positions.emplace_back(0 /* offset */, m_maxErrors /* errorsLeft */,
|
||||
false /* transposed */);
|
||||
state.m_positions.emplace_back(0 /* offset */, m_maxErrors /* errorsLeft */, false /* transposed */);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -313,10 +305,8 @@ bool LevenshteinDFA::IsValid(Position const & p) const
|
||||
bool LevenshteinDFA::IsValid(State const & s) const
|
||||
{
|
||||
for (auto const & p : s.m_positions)
|
||||
{
|
||||
if (!IsValid(p))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -328,10 +318,8 @@ bool LevenshteinDFA::IsAccepting(Position const & p) const
|
||||
bool LevenshteinDFA::IsAccepting(State const & s) const
|
||||
{
|
||||
for (auto const & p : s.m_positions)
|
||||
{
|
||||
if (IsAccepting(p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ public:
|
||||
LevenshteinDFA(LevenshteinDFA &&) = default;
|
||||
LevenshteinDFA & operator=(LevenshteinDFA &&) = default;
|
||||
|
||||
LevenshteinDFA(UniString const & s, size_t prefixSize,
|
||||
std::vector<UniString> const & prefixMisprints, size_t maxErrors);
|
||||
LevenshteinDFA(UniString const & s, size_t prefixSize, std::vector<UniString> const & prefixMisprints,
|
||||
size_t maxErrors);
|
||||
LevenshteinDFA(std::string const & s, size_t prefixSize, size_t maxErrors);
|
||||
LevenshteinDFA(UniString const & s, size_t maxErrors);
|
||||
LevenshteinDFA(std::string const & s, size_t maxErrors);
|
||||
|
||||
@@ -17,9 +17,9 @@ public:
|
||||
typedef typename std::vector<T>::const_iterator const_iterator;
|
||||
|
||||
explicit limited_priority_queue(size_t maxSize = 1, CompareT compare = CompareT())
|
||||
: m_maxSize(maxSize == 0 ? 1 : maxSize), m_compare(compare)
|
||||
{
|
||||
}
|
||||
: m_maxSize(maxSize == 0 ? 1 : maxSize)
|
||||
, m_compare(compare)
|
||||
{}
|
||||
|
||||
void push(T t)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
void pop()
|
||||
{
|
||||
ASSERT ( !empty(), () );
|
||||
ASSERT(!empty(), ());
|
||||
pop_heap(m_queue.begin(), m_queue.end(), m_compare);
|
||||
m_queue.pop_back();
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
size_t size() const { return m_queue.size(); }
|
||||
T const & top() const
|
||||
{
|
||||
ASSERT ( !empty(), () );
|
||||
ASSERT(!empty(), ());
|
||||
return m_queue.front();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Contains(KeyType const & key) const
|
||||
{
|
||||
return m_map.find(key) != m_map.cend();
|
||||
}
|
||||
bool Contains(KeyType const & key) const { return m_map.find(key) != m_map.cend(); }
|
||||
|
||||
ValueType const & Get(KeyType const & key) const
|
||||
{
|
||||
@@ -58,15 +55,9 @@ public:
|
||||
return it->second->second;
|
||||
}
|
||||
|
||||
ValueType & Front()
|
||||
{
|
||||
return m_list.front().second;
|
||||
}
|
||||
ValueType & Front() { return m_list.front().second; }
|
||||
|
||||
ValueType const & Front() const
|
||||
{
|
||||
return m_list.front().second;
|
||||
}
|
||||
ValueType const & Front() const { return m_list.front().second; }
|
||||
|
||||
void Swap(LinkedMap & linkedMap)
|
||||
{
|
||||
@@ -74,15 +65,9 @@ public:
|
||||
m_list.swap(linkedMap.m_list);
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
{
|
||||
return m_list.size();
|
||||
}
|
||||
size_t Size() const { return m_list.size(); }
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return m_list.empty();
|
||||
}
|
||||
bool IsEmpty() const { return m_list.empty(); }
|
||||
|
||||
private:
|
||||
ListType m_list;
|
||||
|
||||
@@ -31,7 +31,7 @@ std::optional<LogLevel> FromString(std::string const & s)
|
||||
ASSERT(!s.empty(), ("Log level should not be empty"));
|
||||
|
||||
auto const & names = GetLogLevelNames();
|
||||
const auto it = std::find(names.begin(), names.end(), std::toupper(s[0]));
|
||||
auto const it = std::find(names.begin(), names.end(), std::toupper(s[0]));
|
||||
if (it == names.end())
|
||||
return {};
|
||||
return static_cast<LogLevel>(std::distance(names.begin(), it));
|
||||
@@ -39,7 +39,7 @@ std::optional<LogLevel> FromString(std::string const & s)
|
||||
|
||||
std::array<char, NUM_LOG_LEVELS> const & GetLogLevelNames()
|
||||
{
|
||||
static std::array<char, NUM_LOG_LEVELS> constexpr kLogLevelNames {'D', 'I', 'W', 'E', 'C'};
|
||||
static std::array<char, NUM_LOG_LEVELS> constexpr kLogLevelNames{'D', 'I', 'W', 'E', 'C'};
|
||||
return kLogLevelNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ struct ScopedLogAbortLevelChanger
|
||||
};
|
||||
} // namespace base
|
||||
|
||||
using base::LCRITICAL;
|
||||
using base::LDEBUG;
|
||||
using base::LERROR;
|
||||
using base::LINFO;
|
||||
using base::LWARNING;
|
||||
using base::LERROR;
|
||||
using base::LCRITICAL;
|
||||
using base::NUM_LOG_LEVELS;
|
||||
|
||||
// Logging macro.
|
||||
@@ -105,7 +105,8 @@ using base::NUM_LOG_LEVELS;
|
||||
{ \
|
||||
if ((level) >= ::base::g_LogLevel) \
|
||||
::base::LogMessage(level, SRC(), ::base::Message msg); \
|
||||
} while (false)
|
||||
} \
|
||||
while (false)
|
||||
|
||||
// Logging macro with short info (without entry point)
|
||||
#define LOG_SHORT(level, msg) \
|
||||
@@ -113,14 +114,16 @@ using base::NUM_LOG_LEVELS;
|
||||
{ \
|
||||
if ((level) >= ::base::g_LogLevel) \
|
||||
::base::LogMessage(level, base::SrcPoint(), ::base::Message msg); \
|
||||
} while (false)
|
||||
} \
|
||||
while (false)
|
||||
|
||||
// Provides logging despite of |g_LogLevel|.
|
||||
#define LOG_FORCE(level, msg) \
|
||||
do \
|
||||
{ \
|
||||
::base::LogMessage(level, SRC(), ::base::Message msg); \
|
||||
} while (false) \
|
||||
#define LOG_FORCE(level, msg) \
|
||||
do \
|
||||
{ \
|
||||
::base::LogMessage(level, SRC(), ::base::Message msg); \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
// Conditional log. Logs @msg with level @level in case when @X returns false.
|
||||
#define CLOG(level, X, msg) \
|
||||
@@ -128,4 +131,5 @@ using base::NUM_LOG_LEVELS;
|
||||
{ \
|
||||
if (!(X)) \
|
||||
LOG(level, (SRC(), "CLOG(" #X ")", ::base::Message msg)); \
|
||||
} while (false)
|
||||
} \
|
||||
while (false)
|
||||
|
||||
@@ -7,57 +7,322 @@
|
||||
namespace strings
|
||||
{
|
||||
|
||||
static uint16_t const small00[] = {0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,0x3bc,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xd7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0x0,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};
|
||||
static uint16_t const small01[] = {0x101,0x101,0x103,0x103,0x105,0x105,0x107,0x107,0x109,0x109,0x10b,0x10b,0x10d,0x10d,0x10f,0x10f,0x111,0x111,0x113,0x113,0x115,0x115,0x117,0x117,0x119,0x119,0x11b,0x11b,0x11d,0x11d,0x11f,0x11f,0x121,0x121,0x123,0x123,0x125,0x125,0x127,0x127,0x129,0x129,0x12b,0x12b,0x12d,0x12d,0x12f,0x12f,0x0,0x131,0x133,0x133,0x135,0x135,0x137,0x137,0x138,0x13a,0x13a,0x13c,0x13c,0x13e,0x13e,0x140,0x140,0x142,0x142,0x144,0x144,0x146,0x146,0x148,0x148,0x0,0x14b,0x14b,0x14d,0x14d,0x14f,0x14f,0x151,0x151,0x153,0x153,0x155,0x155,0x157,0x157,0x159,0x159,0x15b,0x15b,0x15d,0x15d,0x15f,0x15f,0x161,0x161,0x163,0x163,0x165,0x165,0x167,0x167,0x169,0x169,0x16b,0x16b,0x16d,0x16d,0x16f,0x16f,0x171,0x171,0x173,0x173,0x175,0x175,0x177,0x177,0xff,0x17a,0x17a,0x17c,0x17c,0x17e,0x17e,0x73,0x180,0x253,0x183,0x183,0x185,0x185,0x254,0x188,0x188,0x256,0x257,0x18c,0x18c,0x18d,0x1dd,0x259,0x25b,0x192,0x192,0x260,0x263,0x195,0x269,0x268,0x199,0x199,0x19a,0x19b,0x26f,0x272,0x19e,0x275,0x1a1,0x1a1,0x1a3,0x1a3,0x1a5,0x1a5,0x280,0x1a8,0x1a8,0x283,0x1aa,0x1ab,0x1ad,0x1ad,0x288,0x1b0,0x1b0,0x28a,0x28b,0x1b4,0x1b4,0x1b6,0x1b6,0x292,0x1b9,0x1b9,0x1ba,0x1bb,0x1bd,0x1bd,0x1be,0x1bf,0x1c0,0x1c1,0x1c2,0x1c3,0x1c6,0x1c6,0x1c6,0x1c9,0x1c9,0x1c9,0x1cc,0x1cc,0x1cc,0x1ce,0x1ce,0x1d0,0x1d0,0x1d2,0x1d2,0x1d4,0x1d4,0x1d6,0x1d6,0x1d8,0x1d8,0x1da,0x1da,0x1dc,0x1dc,0x1dd,0x1df,0x1df,0x1e1,0x1e1,0x1e3,0x1e3,0x1e5,0x1e5,0x1e7,0x1e7,0x1e9,0x1e9,0x1eb,0x1eb,0x1ed,0x1ed,0x1ef,0x1ef,0x0,0x1f3,0x1f3,0x1f3,0x1f5,0x1f5,0x195,0x1bf,0x1f9,0x1f9,0x1fb,0x1fb,0x1fd,0x1fd,0x1ff,0x1ff};
|
||||
static uint16_t const small02[] = {0x201,0x201,0x203,0x203,0x205,0x205,0x207,0x207,0x209,0x209,0x20b,0x20b,0x20d,0x20d,0x20f,0x20f,0x211,0x211,0x213,0x213,0x215,0x215,0x217,0x217,0x219,0x219,0x21b,0x21b,0x21d,0x21d,0x21f,0x21f,0x19e,0x221,0x223,0x223,0x225,0x225,0x227,0x227,0x229,0x229,0x22b,0x22b,0x22d,0x22d,0x22f,0x22f,0x231,0x231,0x233,0x233,0x234,0x235,0x236,0x237,0x238,0x239,0x2c65,0x23c,0x23c,0x19a,0x2c66,0x23f,0x240,0x242,0x242,0x180,0x289,0x28c,0x247,0x247,0x249,0x249,0x24b,0x24b,0x24d,0x24d,0x24f,0x24f,0x250,0x251,0x252,0x253,0x254,0x255,0x256,0x257,0x258,0x259,0x25a,0x25b,0x25c,0x25d,0x25e,0x25f,0x260,0x261,0x262,0x263,0x264,0x265,0x266,0x267,0x268,0x269,0x26a,0x26b,0x26c,0x26d,0x26e,0x26f,0x270,0x271,0x272,0x273,0x274,0x275,0x276,0x277,0x278,0x279,0x27a,0x27b,0x27c,0x27d,0x27e,0x27f,0x280,0x281,0x282,0x283,0x284,0x285,0x286,0x287,0x288,0x289,0x28a,0x28b,0x28c,0x28d,0x28e,0x28f,0x290,0x291,0x292,0x293,0x294,0x295,0x296,0x297,0x298,0x299,0x29a,0x29b,0x29c,0x29d,0x29e,0x29f,0x2a0,0x2a1,0x2a2,0x2a3,0x2a4,0x2a5,0x2a6,0x2a7,0x2a8,0x2a9,0x2aa,0x2ab,0x2ac,0x2ad,0x2ae,0x2af,0x2b0,0x2b1,0x2b2,0x2b3,0x2b4,0x2b5,0x2b6,0x2b7,0x2b8,0x2b9,0x2ba,0x2bb,0x2bc,0x2bd,0x2be,0x2bf,0x2c0,0x2c1,0x2c2,0x2c3,0x2c4,0x2c5,0x2c6,0x2c7,0x2c8,0x2c9,0x2ca,0x2cb,0x2cc,0x2cd,0x2ce,0x2cf,0x2d0,0x2d1,0x2d2,0x2d3,0x2d4,0x2d5,0x2d6,0x2d7,0x2d8,0x2d9,0x2da,0x2db,0x2dc,0x2dd,0x2de,0x2df,0x2e0,0x2e1,0x2e2,0x2e3,0x2e4,0x2e5,0x2e6,0x2e7,0x2e8,0x2e9,0x2ea,0x2eb,0x2ec,0x2ed,0x2ee,0x2ef,0x2f0,0x2f1,0x2f2,0x2f3,0x2f4,0x2f5,0x2f6,0x2f7,0x2f8,0x2f9,0x2fa,0x2fb,0x2fc,0x2fd,0x2fe,0x2ff};
|
||||
static uint16_t const small03[] = {0x300,0x301,0x302,0x303,0x304,0x305,0x306,0x307,0x308,0x309,0x30a,0x30b,0x30c,0x30d,0x30e,0x30f,0x310,0x311,0x312,0x313,0x314,0x315,0x316,0x317,0x318,0x319,0x31a,0x31b,0x31c,0x31d,0x31e,0x31f,0x320,0x321,0x322,0x323,0x324,0x325,0x326,0x327,0x328,0x329,0x32a,0x32b,0x32c,0x32d,0x32e,0x32f,0x330,0x331,0x332,0x333,0x334,0x335,0x336,0x337,0x338,0x339,0x33a,0x33b,0x33c,0x33d,0x33e,0x33f,0x340,0x341,0x342,0x343,0x344,0x3b9,0x346,0x347,0x348,0x349,0x34a,0x34b,0x34c,0x34d,0x34e,0x34f,0x350,0x351,0x352,0x353,0x354,0x355,0x356,0x357,0x358,0x359,0x35a,0x35b,0x35c,0x35d,0x35e,0x35f,0x360,0x361,0x362,0x363,0x364,0x365,0x366,0x367,0x368,0x369,0x36a,0x36b,0x36c,0x36d,0x36e,0x36f,0x371,0x371,0x373,0x373,0x374,0x375,0x377,0x377,0x378,0x379,0x37a,0x37b,0x37c,0x37d,0x37e,0x37f,0x380,0x381,0x382,0x383,0x384,0x385,0x3ac,0x387,0x3ad,0x3ae,0x3af,0x38b,0x3cc,0x38d,0x3cd,0x3ce,0x0,0x3b1,0x3b2,0x3b3,0x3b4,0x3b5,0x3b6,0x3b7,0x3b8,0x3b9,0x3ba,0x3bb,0x3bc,0x3bd,0x3be,0x3bf,0x3c0,0x3c1,0x3a2,0x3c3,0x3c4,0x3c5,0x3c6,0x3c7,0x3c8,0x3c9,0x3ca,0x3cb,0x3ac,0x3ad,0x3ae,0x3af,0x0,0x3b1,0x3b2,0x3b3,0x3b4,0x3b5,0x3b6,0x3b7,0x3b8,0x3b9,0x3ba,0x3bb,0x3bc,0x3bd,0x3be,0x3bf,0x3c0,0x3c1,0x3c3,0x3c3,0x3c4,0x3c5,0x3c6,0x3c7,0x3c8,0x3c9,0x3ca,0x3cb,0x3cc,0x3cd,0x3ce,0x3d7,0x3b2,0x3b8,0x3d2,0x3d3,0x3d4,0x3c6,0x3c0,0x3d7,0x3d9,0x3d9,0x3db,0x3db,0x3dd,0x3dd,0x3df,0x3df,0x3e1,0x3e1,0x3e3,0x3e3,0x3e5,0x3e5,0x3e7,0x3e7,0x3e9,0x3e9,0x3eb,0x3eb,0x3ed,0x3ed,0x3ef,0x3ef,0x3ba,0x3c1,0x3f2,0x3f3,0x3b8,0x3b5,0x3f6,0x3f8,0x3f8,0x3f2,0x3fb,0x3fb,0x3fc,0x37b,0x37c,0x37d};
|
||||
static uint16_t const small04[] = {0x450,0x451,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45a,0x45b,0x45c,0x45d,0x45e,0x45f,0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43a,0x43b,0x43c,0x43d,0x43e,0x43f,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44a,0x44b,0x44c,0x44d,0x44e,0x44f,0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43a,0x43b,0x43c,0x43d,0x43e,0x43f,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44a,0x44b,0x44c,0x44d,0x44e,0x44f,0x450,0x451,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45a,0x45b,0x45c,0x45d,0x45e,0x45f,0x461,0x461,0x463,0x463,0x465,0x465,0x467,0x467,0x469,0x469,0x46b,0x46b,0x46d,0x46d,0x46f,0x46f,0x471,0x471,0x473,0x473,0x475,0x475,0x477,0x477,0x479,0x479,0x47b,0x47b,0x47d,0x47d,0x47f,0x47f,0x481,0x481,0x482,0x483,0x484,0x485,0x486,0x487,0x488,0x489,0x48b,0x48b,0x48d,0x48d,0x48f,0x48f,0x491,0x491,0x493,0x493,0x495,0x495,0x497,0x497,0x499,0x499,0x49b,0x49b,0x49d,0x49d,0x49f,0x49f,0x4a1,0x4a1,0x4a3,0x4a3,0x4a5,0x4a5,0x4a7,0x4a7,0x4a9,0x4a9,0x4ab,0x4ab,0x4ad,0x4ad,0x4af,0x4af,0x4b1,0x4b1,0x4b3,0x4b3,0x4b5,0x4b5,0x4b7,0x4b7,0x4b9,0x4b9,0x4bb,0x4bb,0x4bd,0x4bd,0x4bf,0x4bf,0x4cf,0x4c2,0x4c2,0x4c4,0x4c4,0x4c6,0x4c6,0x4c8,0x4c8,0x4ca,0x4ca,0x4cc,0x4cc,0x4ce,0x4ce,0x4cf,0x4d1,0x4d1,0x4d3,0x4d3,0x4d5,0x4d5,0x4d7,0x4d7,0x4d9,0x4d9,0x4db,0x4db,0x4dd,0x4dd,0x4df,0x4df,0x4e1,0x4e1,0x4e3,0x4e3,0x4e5,0x4e5,0x4e7,0x4e7,0x4e9,0x4e9,0x4eb,0x4eb,0x4ed,0x4ed,0x4ef,0x4ef,0x4f1,0x4f1,0x4f3,0x4f3,0x4f5,0x4f5,0x4f7,0x4f7,0x4f9,0x4f9,0x4fb,0x4fb,0x4fd,0x4fd,0x4ff,0x4ff};
|
||||
static uint16_t const small05[] = {0x501,0x501,0x503,0x503,0x505,0x505,0x507,0x507,0x509,0x509,0x50b,0x50b,0x50d,0x50d,0x50f,0x50f,0x511,0x511,0x513,0x513,0x515,0x515,0x517,0x517,0x519,0x519,0x51b,0x51b,0x51d,0x51d,0x51f,0x51f,0x521,0x521,0x523,0x523,0x525,0x525,0x527,0x527,0x528,0x529,0x52a,0x52b,0x52c,0x52d,0x52e,0x52f,0x530,0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56a,0x56b,0x56c,0x56d,0x56e,0x56f,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57a,0x57b,0x57c,0x57d,0x57e,0x57f,0x580,0x581,0x582,0x583,0x584,0x585,0x586,0x557,0x558,0x559,0x55a,0x55b,0x55c,0x55d,0x55e,0x55f,0x560,0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56a,0x56b,0x56c,0x56d,0x56e,0x56f,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57a,0x57b,0x57c,0x57d,0x57e,0x57f,0x580,0x581,0x582,0x583,0x584,0x585,0x586,0x0,0x588,0x589,0x58a,0x58b,0x58c,0x58d,0x58e,0x58f,0x590,0x591,0x592,0x593,0x594,0x595,0x596,0x597,0x598,0x599,0x59a,0x59b,0x59c,0x59d,0x59e,0x59f,0x5a0,0x5a1,0x5a2,0x5a3,0x5a4,0x5a5,0x5a6,0x5a7,0x5a8,0x5a9,0x5aa,0x5ab,0x5ac,0x5ad,0x5ae,0x5af,0x5b0,0x5b1,0x5b2,0x5b3,0x5b4,0x5b5,0x5b6,0x5b7,0x5b8,0x5b9,0x5ba,0x5bb,0x5bc,0x5bd,0x5be,0x5bf,0x5c0,0x5c1,0x5c2,0x5c3,0x5c4,0x5c5,0x5c6,0x5c7,0x5c8,0x5c9,0x5ca,0x5cb,0x5cc,0x5cd,0x5ce,0x5cf,0x5d0,0x5d1,0x5d2,0x5d3,0x5d4,0x5d5,0x5d6,0x5d7,0x5d8,0x5d9,0x5da,0x5db,0x5dc,0x5dd,0x5de,0x5df,0x5e0,0x5e1,0x5e2,0x5e3,0x5e4,0x5e5,0x5e6,0x5e7,0x5e8,0x5e9,0x5ea,0x5eb,0x5ec,0x5ed,0x5ee,0x5ef,0x5f0,0x5f1,0x5f2,0x5f3,0x5f4,0x5f5,0x5f6,0x5f7,0x5f8,0x5f9,0x5fa,0x5fb,0x5fc,0x5fd,0x5fe,0x5ff};
|
||||
static uint16_t const small10[] = {0x1000,0x1001,0x1002,0x1003,0x1004,0x1005,0x1006,0x1007,0x1008,0x1009,0x100a,0x100b,0x100c,0x100d,0x100e,0x100f,0x1010,0x1011,0x1012,0x1013,0x1014,0x1015,0x1016,0x1017,0x1018,0x1019,0x101a,0x101b,0x101c,0x101d,0x101e,0x101f,0x1020,0x1021,0x1022,0x1023,0x1024,0x1025,0x1026,0x1027,0x1028,0x1029,0x102a,0x102b,0x102c,0x102d,0x102e,0x102f,0x1030,0x1031,0x1032,0x1033,0x1034,0x1035,0x1036,0x1037,0x1038,0x1039,0x103a,0x103b,0x103c,0x103d,0x103e,0x103f,0x1040,0x1041,0x1042,0x1043,0x1044,0x1045,0x1046,0x1047,0x1048,0x1049,0x104a,0x104b,0x104c,0x104d,0x104e,0x104f,0x1050,0x1051,0x1052,0x1053,0x1054,0x1055,0x1056,0x1057,0x1058,0x1059,0x105a,0x105b,0x105c,0x105d,0x105e,0x105f,0x1060,0x1061,0x1062,0x1063,0x1064,0x1065,0x1066,0x1067,0x1068,0x1069,0x106a,0x106b,0x106c,0x106d,0x106e,0x106f,0x1070,0x1071,0x1072,0x1073,0x1074,0x1075,0x1076,0x1077,0x1078,0x1079,0x107a,0x107b,0x107c,0x107d,0x107e,0x107f,0x1080,0x1081,0x1082,0x1083,0x1084,0x1085,0x1086,0x1087,0x1088,0x1089,0x108a,0x108b,0x108c,0x108d,0x108e,0x108f,0x1090,0x1091,0x1092,0x1093,0x1094,0x1095,0x1096,0x1097,0x1098,0x1099,0x109a,0x109b,0x109c,0x109d,0x109e,0x109f,0x2d00,0x2d01,0x2d02,0x2d03,0x2d04,0x2d05,0x2d06,0x2d07,0x2d08,0x2d09,0x2d0a,0x2d0b,0x2d0c,0x2d0d,0x2d0e,0x2d0f,0x2d10,0x2d11,0x2d12,0x2d13,0x2d14,0x2d15,0x2d16,0x2d17,0x2d18,0x2d19,0x2d1a,0x2d1b,0x2d1c,0x2d1d,0x2d1e,0x2d1f,0x2d20,0x2d21,0x2d22,0x2d23,0x2d24,0x2d25,0x10c6,0x10c7,0x10c8,0x10c9,0x10ca,0x10cb,0x10cc,0x10cd,0x10ce,0x10cf,0x10d0,0x10d1,0x10d2,0x10d3,0x10d4,0x10d5,0x10d6,0x10d7,0x10d8,0x10d9,0x10da,0x10db,0x10dc,0x10dd,0x10de,0x10df,0x10e0,0x10e1,0x10e2,0x10e3,0x10e4,0x10e5,0x10e6,0x10e7,0x10e8,0x10e9,0x10ea,0x10eb,0x10ec,0x10ed,0x10ee,0x10ef,0x10f0,0x10f1,0x10f2,0x10f3,0x10f4,0x10f5,0x10f6,0x10f7,0x10f8,0x10f9,0x10fa,0x10fb,0x10fc,0x10fd,0x10fe,0x10ff};
|
||||
static uint16_t const small1e[] = {0x1e01,0x1e01,0x1e03,0x1e03,0x1e05,0x1e05,0x1e07,0x1e07,0x1e09,0x1e09,0x1e0b,0x1e0b,0x1e0d,0x1e0d,0x1e0f,0x1e0f,0x1e11,0x1e11,0x1e13,0x1e13,0x1e15,0x1e15,0x1e17,0x1e17,0x1e19,0x1e19,0x1e1b,0x1e1b,0x1e1d,0x1e1d,0x1e1f,0x1e1f,0x1e21,0x1e21,0x1e23,0x1e23,0x1e25,0x1e25,0x1e27,0x1e27,0x1e29,0x1e29,0x1e2b,0x1e2b,0x1e2d,0x1e2d,0x1e2f,0x1e2f,0x1e31,0x1e31,0x1e33,0x1e33,0x1e35,0x1e35,0x1e37,0x1e37,0x1e39,0x1e39,0x1e3b,0x1e3b,0x1e3d,0x1e3d,0x1e3f,0x1e3f,0x1e41,0x1e41,0x1e43,0x1e43,0x1e45,0x1e45,0x1e47,0x1e47,0x1e49,0x1e49,0x1e4b,0x1e4b,0x1e4d,0x1e4d,0x1e4f,0x1e4f,0x1e51,0x1e51,0x1e53,0x1e53,0x1e55,0x1e55,0x1e57,0x1e57,0x1e59,0x1e59,0x1e5b,0x1e5b,0x1e5d,0x1e5d,0x1e5f,0x1e5f,0x1e61,0x1e61,0x1e63,0x1e63,0x1e65,0x1e65,0x1e67,0x1e67,0x1e69,0x1e69,0x1e6b,0x1e6b,0x1e6d,0x1e6d,0x1e6f,0x1e6f,0x1e71,0x1e71,0x1e73,0x1e73,0x1e75,0x1e75,0x1e77,0x1e77,0x1e79,0x1e79,0x1e7b,0x1e7b,0x1e7d,0x1e7d,0x1e7f,0x1e7f,0x1e81,0x1e81,0x1e83,0x1e83,0x1e85,0x1e85,0x1e87,0x1e87,0x1e89,0x1e89,0x1e8b,0x1e8b,0x1e8d,0x1e8d,0x1e8f,0x1e8f,0x1e91,0x1e91,0x1e93,0x1e93,0x1e95,0x1e95,0x0,0x0,0x0,0x0,0x0,0x1e61,0x1e9c,0x1e9d,0x0,0x1e9f,0x1ea1,0x1ea1,0x1ea3,0x1ea3,0x1ea5,0x1ea5,0x1ea7,0x1ea7,0x1ea9,0x1ea9,0x1eab,0x1eab,0x1ead,0x1ead,0x1eaf,0x1eaf,0x1eb1,0x1eb1,0x1eb3,0x1eb3,0x1eb5,0x1eb5,0x1eb7,0x1eb7,0x1eb9,0x1eb9,0x1ebb,0x1ebb,0x1ebd,0x1ebd,0x1ebf,0x1ebf,0x1ec1,0x1ec1,0x1ec3,0x1ec3,0x1ec5,0x1ec5,0x1ec7,0x1ec7,0x1ec9,0x1ec9,0x1ecb,0x1ecb,0x1ecd,0x1ecd,0x1ecf,0x1ecf,0x1ed1,0x1ed1,0x1ed3,0x1ed3,0x1ed5,0x1ed5,0x1ed7,0x1ed7,0x1ed9,0x1ed9,0x1edb,0x1edb,0x1edd,0x1edd,0x1edf,0x1edf,0x1ee1,0x1ee1,0x1ee3,0x1ee3,0x1ee5,0x1ee5,0x1ee7,0x1ee7,0x1ee9,0x1ee9,0x1eeb,0x1eeb,0x1eed,0x1eed,0x1eef,0x1eef,0x1ef1,0x1ef1,0x1ef3,0x1ef3,0x1ef5,0x1ef5,0x1ef7,0x1ef7,0x1ef9,0x1ef9,0x1efb,0x1efb,0x1efd,0x1efd,0x1eff,0x1eff};
|
||||
static uint16_t const small1f[] = {0x1f00,0x1f01,0x1f02,0x1f03,0x1f04,0x1f05,0x1f06,0x1f07,0x1f00,0x1f01,0x1f02,0x1f03,0x1f04,0x1f05,0x1f06,0x1f07,0x1f10,0x1f11,0x1f12,0x1f13,0x1f14,0x1f15,0x1f16,0x1f17,0x1f10,0x1f11,0x1f12,0x1f13,0x1f14,0x1f15,0x1f1e,0x1f1f,0x1f20,0x1f21,0x1f22,0x1f23,0x1f24,0x1f25,0x1f26,0x1f27,0x1f20,0x1f21,0x1f22,0x1f23,0x1f24,0x1f25,0x1f26,0x1f27,0x1f30,0x1f31,0x1f32,0x1f33,0x1f34,0x1f35,0x1f36,0x1f37,0x1f30,0x1f31,0x1f32,0x1f33,0x1f34,0x1f35,0x1f36,0x1f37,0x1f40,0x1f41,0x1f42,0x1f43,0x1f44,0x1f45,0x1f46,0x1f47,0x1f40,0x1f41,0x1f42,0x1f43,0x1f44,0x1f45,0x1f4e,0x1f4f,0x0,0x1f51,0x0,0x1f53,0x0,0x1f55,0x0,0x1f57,0x1f58,0x1f51,0x1f5a,0x1f53,0x1f5c,0x1f55,0x1f5e,0x1f57,0x1f60,0x1f61,0x1f62,0x1f63,0x1f64,0x1f65,0x1f66,0x1f67,0x1f60,0x1f61,0x1f62,0x1f63,0x1f64,0x1f65,0x1f66,0x1f67,0x1f70,0x1f71,0x1f72,0x1f73,0x1f74,0x1f75,0x1f76,0x1f77,0x1f78,0x1f79,0x1f7a,0x1f7b,0x1f7c,0x1f7d,0x1f7e,0x1f7f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fb0,0x1fb1,0x0,0x0,0x0,0x1fb5,0x0,0x0,0x1fb0,0x1fb1,0x1f70,0x1f71,0x0,0x1fbd,0x3b9,0x1fbf,0x1fc0,0x1fc1,0x0,0x0,0x0,0x1fc5,0x0,0x0,0x1f72,0x1f73,0x1f74,0x1f75,0x0,0x1fcd,0x1fce,0x1fcf,0x1fd0,0x1fd1,0x0,0x0,0x1fd4,0x1fd5,0x0,0x0,0x1fd0,0x1fd1,0x1f76,0x1f77,0x1fdc,0x1fdd,0x1fde,0x1fdf,0x1fe0,0x1fe1,0x0,0x0,0x0,0x1fe5,0x0,0x0,0x1fe0,0x1fe1,0x1f7a,0x1f7b,0x1fe5,0x1fed,0x1fee,0x1fef,0x1ff0,0x1ff1,0x0,0x0,0x0,0x1ff5,0x0,0x0,0x1f78,0x1f79,0x1f7c,0x1f7d,0x0,0x1ffd,0x1ffe,0x1fff};
|
||||
static uint16_t const small21[] = {0x2100,0x2101,0x2102,0x2103,0x2104,0x2105,0x2106,0x2107,0x2108,0x2109,0x210a,0x210b,0x210c,0x210d,0x210e,0x210f,0x2110,0x2111,0x2112,0x2113,0x2114,0x2115,0x2116,0x2117,0x2118,0x2119,0x211a,0x211b,0x211c,0x211d,0x211e,0x211f,0x2120,0x2121,0x2122,0x2123,0x2124,0x2125,0x3c9,0x2127,0x2128,0x2129,0x6b,0xe5,0x212c,0x212d,0x212e,0x212f,0x2130,0x2131,0x214e,0x2133,0x2134,0x2135,0x2136,0x2137,0x2138,0x2139,0x213a,0x213b,0x213c,0x213d,0x213e,0x213f,0x2140,0x2141,0x2142,0x2143,0x2144,0x2145,0x2146,0x2147,0x2148,0x2149,0x214a,0x214b,0x214c,0x214d,0x214e,0x214f,0x2150,0x2151,0x2152,0x2153,0x2154,0x2155,0x2156,0x2157,0x2158,0x2159,0x215a,0x215b,0x215c,0x215d,0x215e,0x215f,0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217a,0x217b,0x217c,0x217d,0x217e,0x217f,0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217a,0x217b,0x217c,0x217d,0x217e,0x217f,0x2180,0x2181,0x2182,0x2184,0x2184,0x2185,0x2186,0x2187,0x2188,0x2189,0x218a,0x218b,0x218c,0x218d,0x218e,0x218f,0x2190,0x2191,0x2192,0x2193,0x2194,0x2195,0x2196,0x2197,0x2198,0x2199,0x219a,0x219b,0x219c,0x219d,0x219e,0x219f,0x21a0,0x21a1,0x21a2,0x21a3,0x21a4,0x21a5,0x21a6,0x21a7,0x21a8,0x21a9,0x21aa,0x21ab,0x21ac,0x21ad,0x21ae,0x21af,0x21b0,0x21b1,0x21b2,0x21b3,0x21b4,0x21b5,0x21b6,0x21b7,0x21b8,0x21b9,0x21ba,0x21bb,0x21bc,0x21bd,0x21be,0x21bf,0x21c0,0x21c1,0x21c2,0x21c3,0x21c4,0x21c5,0x21c6,0x21c7,0x21c8,0x21c9,0x21ca,0x21cb,0x21cc,0x21cd,0x21ce,0x21cf,0x21d0,0x21d1,0x21d2,0x21d3,0x21d4,0x21d5,0x21d6,0x21d7,0x21d8,0x21d9,0x21da,0x21db,0x21dc,0x21dd,0x21de,0x21df,0x21e0,0x21e1,0x21e2,0x21e3,0x21e4,0x21e5,0x21e6,0x21e7,0x21e8,0x21e9,0x21ea,0x21eb,0x21ec,0x21ed,0x21ee,0x21ef,0x21f0,0x21f1,0x21f2,0x21f3,0x21f4,0x21f5,0x21f6,0x21f7,0x21f8,0x21f9,0x21fa,0x21fb,0x21fc,0x21fd,0x21fe,0x21ff};
|
||||
static uint16_t const small24[] = {0x2400,0x2401,0x2402,0x2403,0x2404,0x2405,0x2406,0x2407,0x2408,0x2409,0x240a,0x240b,0x240c,0x240d,0x240e,0x240f,0x2410,0x2411,0x2412,0x2413,0x2414,0x2415,0x2416,0x2417,0x2418,0x2419,0x241a,0x241b,0x241c,0x241d,0x241e,0x241f,0x2420,0x2421,0x2422,0x2423,0x2424,0x2425,0x2426,0x2427,0x2428,0x2429,0x242a,0x242b,0x242c,0x242d,0x242e,0x242f,0x2430,0x2431,0x2432,0x2433,0x2434,0x2435,0x2436,0x2437,0x2438,0x2439,0x243a,0x243b,0x243c,0x243d,0x243e,0x243f,0x2440,0x2441,0x2442,0x2443,0x2444,0x2445,0x2446,0x2447,0x2448,0x2449,0x244a,0x244b,0x244c,0x244d,0x244e,0x244f,0x2450,0x2451,0x2452,0x2453,0x2454,0x2455,0x2456,0x2457,0x2458,0x2459,0x245a,0x245b,0x245c,0x245d,0x245e,0x245f,0x2460,0x2461,0x2462,0x2463,0x2464,0x2465,0x2466,0x2467,0x2468,0x2469,0x246a,0x246b,0x246c,0x246d,0x246e,0x246f,0x2470,0x2471,0x2472,0x2473,0x2474,0x2475,0x2476,0x2477,0x2478,0x2479,0x247a,0x247b,0x247c,0x247d,0x247e,0x247f,0x2480,0x2481,0x2482,0x2483,0x2484,0x2485,0x2486,0x2487,0x2488,0x2489,0x248a,0x248b,0x248c,0x248d,0x248e,0x248f,0x2490,0x2491,0x2492,0x2493,0x2494,0x2495,0x2496,0x2497,0x2498,0x2499,0x249a,0x249b,0x249c,0x249d,0x249e,0x249f,0x24a0,0x24a1,0x24a2,0x24a3,0x24a4,0x24a5,0x24a6,0x24a7,0x24a8,0x24a9,0x24aa,0x24ab,0x24ac,0x24ad,0x24ae,0x24af,0x24b0,0x24b1,0x24b2,0x24b3,0x24b4,0x24b5,0x24d0,0x24d1,0x24d2,0x24d3,0x24d4,0x24d5,0x24d6,0x24d7,0x24d8,0x24d9,0x24da,0x24db,0x24dc,0x24dd,0x24de,0x24df,0x24e0,0x24e1,0x24e2,0x24e3,0x24e4,0x24e5,0x24e6,0x24e7,0x24e8,0x24e9,0x24d0,0x24d1,0x24d2,0x24d3,0x24d4,0x24d5,0x24d6,0x24d7,0x24d8,0x24d9,0x24da,0x24db,0x24dc,0x24dd,0x24de,0x24df,0x24e0,0x24e1,0x24e2,0x24e3,0x24e4,0x24e5,0x24e6,0x24e7,0x24e8,0x24e9,0x24ea,0x24eb,0x24ec,0x24ed,0x24ee,0x24ef,0x24f0,0x24f1,0x24f2,0x24f3,0x24f4,0x24f5,0x24f6,0x24f7,0x24f8,0x24f9,0x24fa,0x24fb,0x24fc,0x24fd,0x24fe,0x24ff};
|
||||
static uint16_t const small2c[] = {0x2c30,0x2c31,0x2c32,0x2c33,0x2c34,0x2c35,0x2c36,0x2c37,0x2c38,0x2c39,0x2c3a,0x2c3b,0x2c3c,0x2c3d,0x2c3e,0x2c3f,0x2c40,0x2c41,0x2c42,0x2c43,0x2c44,0x2c45,0x2c46,0x2c47,0x2c48,0x2c49,0x2c4a,0x2c4b,0x2c4c,0x2c4d,0x2c4e,0x2c4f,0x2c50,0x2c51,0x2c52,0x2c53,0x2c54,0x2c55,0x2c56,0x2c57,0x2c58,0x2c59,0x2c5a,0x2c5b,0x2c5c,0x2c5d,0x2c5e,0x2c2f,0x2c30,0x2c31,0x2c32,0x2c33,0x2c34,0x2c35,0x2c36,0x2c37,0x2c38,0x2c39,0x2c3a,0x2c3b,0x2c3c,0x2c3d,0x2c3e,0x2c3f,0x2c40,0x2c41,0x2c42,0x2c43,0x2c44,0x2c45,0x2c46,0x2c47,0x2c48,0x2c49,0x2c4a,0x2c4b,0x2c4c,0x2c4d,0x2c4e,0x2c4f,0x2c50,0x2c51,0x2c52,0x2c53,0x2c54,0x2c55,0x2c56,0x2c57,0x2c58,0x2c59,0x2c5a,0x2c5b,0x2c5c,0x2c5d,0x2c5e,0x2c5f,0x2c61,0x2c61,0x26b,0x1d7d,0x27d,0x2c65,0x2c66,0x2c68,0x2c68,0x2c6a,0x2c6a,0x2c6c,0x2c6c,0x251,0x271,0x250,0x252,0x2c71,0x2c73,0x2c73,0x2c74,0x2c76,0x2c76,0x2c77,0x2c78,0x2c79,0x2c7a,0x2c7b,0x2c7c,0x2c7d,0x23f,0x240,0x2c81,0x2c81,0x2c83,0x2c83,0x2c85,0x2c85,0x2c87,0x2c87,0x2c89,0x2c89,0x2c8b,0x2c8b,0x2c8d,0x2c8d,0x2c8f,0x2c8f,0x2c91,0x2c91,0x2c93,0x2c93,0x2c95,0x2c95,0x2c97,0x2c97,0x2c99,0x2c99,0x2c9b,0x2c9b,0x2c9d,0x2c9d,0x2c9f,0x2c9f,0x2ca1,0x2ca1,0x2ca3,0x2ca3,0x2ca5,0x2ca5,0x2ca7,0x2ca7,0x2ca9,0x2ca9,0x2cab,0x2cab,0x2cad,0x2cad,0x2caf,0x2caf,0x2cb1,0x2cb1,0x2cb3,0x2cb3,0x2cb5,0x2cb5,0x2cb7,0x2cb7,0x2cb9,0x2cb9,0x2cbb,0x2cbb,0x2cbd,0x2cbd,0x2cbf,0x2cbf,0x2cc1,0x2cc1,0x2cc3,0x2cc3,0x2cc5,0x2cc5,0x2cc7,0x2cc7,0x2cc9,0x2cc9,0x2ccb,0x2ccb,0x2ccd,0x2ccd,0x2ccf,0x2ccf,0x2cd1,0x2cd1,0x2cd3,0x2cd3,0x2cd5,0x2cd5,0x2cd7,0x2cd7,0x2cd9,0x2cd9,0x2cdb,0x2cdb,0x2cdd,0x2cdd,0x2cdf,0x2cdf,0x2ce1,0x2ce1,0x2ce3,0x2ce3,0x2ce4,0x2ce5,0x2ce6,0x2ce7,0x2ce8,0x2ce9,0x2cea,0x2cec,0x2cec,0x2cee,0x2cee,0x2cef,0x2cf0,0x2cf1,0x2cf2,0x2cf3,0x2cf4,0x2cf5,0x2cf6,0x2cf7,0x2cf8,0x2cf9,0x2cfa,0x2cfb,0x2cfc,0x2cfd,0x2cfe,0x2cff};
|
||||
static uint16_t const smalla6[] = {0xa600,0xa601,0xa602,0xa603,0xa604,0xa605,0xa606,0xa607,0xa608,0xa609,0xa60a,0xa60b,0xa60c,0xa60d,0xa60e,0xa60f,0xa610,0xa611,0xa612,0xa613,0xa614,0xa615,0xa616,0xa617,0xa618,0xa619,0xa61a,0xa61b,0xa61c,0xa61d,0xa61e,0xa61f,0xa620,0xa621,0xa622,0xa623,0xa624,0xa625,0xa626,0xa627,0xa628,0xa629,0xa62a,0xa62b,0xa62c,0xa62d,0xa62e,0xa62f,0xa630,0xa631,0xa632,0xa633,0xa634,0xa635,0xa636,0xa637,0xa638,0xa639,0xa63a,0xa63b,0xa63c,0xa63d,0xa63e,0xa63f,0xa641,0xa641,0xa643,0xa643,0xa645,0xa645,0xa647,0xa647,0xa649,0xa649,0xa64b,0xa64b,0xa64d,0xa64d,0xa64f,0xa64f,0xa651,0xa651,0xa653,0xa653,0xa655,0xa655,0xa657,0xa657,0xa659,0xa659,0xa65b,0xa65b,0xa65d,0xa65d,0xa65f,0xa65f,0xa661,0xa661,0xa663,0xa663,0xa665,0xa665,0xa667,0xa667,0xa669,0xa669,0xa66b,0xa66b,0xa66d,0xa66d,0xa66e,0xa66f,0xa670,0xa671,0xa672,0xa673,0xa674,0xa675,0xa676,0xa677,0xa678,0xa679,0xa67a,0xa67b,0xa67c,0xa67d,0xa67e,0xa67f,0xa681,0xa681,0xa683,0xa683,0xa685,0xa685,0xa687,0xa687,0xa689,0xa689,0xa68b,0xa68b,0xa68d,0xa68d,0xa68f,0xa68f,0xa691,0xa691,0xa693,0xa693,0xa695,0xa695,0xa697,0xa697,0xa698,0xa699,0xa69a,0xa69b,0xa69c,0xa69d,0xa69e,0xa69f,0xa6a0,0xa6a1,0xa6a2,0xa6a3,0xa6a4,0xa6a5,0xa6a6,0xa6a7,0xa6a8,0xa6a9,0xa6aa,0xa6ab,0xa6ac,0xa6ad,0xa6ae,0xa6af,0xa6b0,0xa6b1,0xa6b2,0xa6b3,0xa6b4,0xa6b5,0xa6b6,0xa6b7,0xa6b8,0xa6b9,0xa6ba,0xa6bb,0xa6bc,0xa6bd,0xa6be,0xa6bf,0xa6c0,0xa6c1,0xa6c2,0xa6c3,0xa6c4,0xa6c5,0xa6c6,0xa6c7,0xa6c8,0xa6c9,0xa6ca,0xa6cb,0xa6cc,0xa6cd,0xa6ce,0xa6cf,0xa6d0,0xa6d1,0xa6d2,0xa6d3,0xa6d4,0xa6d5,0xa6d6,0xa6d7,0xa6d8,0xa6d9,0xa6da,0xa6db,0xa6dc,0xa6dd,0xa6de,0xa6df,0xa6e0,0xa6e1,0xa6e2,0xa6e3,0xa6e4,0xa6e5,0xa6e6,0xa6e7,0xa6e8,0xa6e9,0xa6ea,0xa6eb,0xa6ec,0xa6ed,0xa6ee,0xa6ef,0xa6f0,0xa6f1,0xa6f2,0xa6f3,0xa6f4,0xa6f5,0xa6f6,0xa6f7,0xa6f8,0xa6f9,0xa6fa,0xa6fb,0xa6fc,0xa6fd,0xa6fe,0xa6ff};
|
||||
static uint16_t const smalla7[] = {0xa700,0xa701,0xa702,0xa703,0xa704,0xa705,0xa706,0xa707,0xa708,0xa709,0xa70a,0xa70b,0xa70c,0xa70d,0xa70e,0xa70f,0xa710,0xa711,0xa712,0xa713,0xa714,0xa715,0xa716,0xa717,0xa718,0xa719,0xa71a,0xa71b,0xa71c,0xa71d,0xa71e,0xa71f,0xa720,0xa721,0xa723,0xa723,0xa725,0xa725,0xa727,0xa727,0xa729,0xa729,0xa72b,0xa72b,0xa72d,0xa72d,0xa72f,0xa72f,0xa730,0xa731,0xa733,0xa733,0xa735,0xa735,0xa737,0xa737,0xa739,0xa739,0xa73b,0xa73b,0xa73d,0xa73d,0xa73f,0xa73f,0xa741,0xa741,0xa743,0xa743,0xa745,0xa745,0xa747,0xa747,0xa749,0xa749,0xa74b,0xa74b,0xa74d,0xa74d,0xa74f,0xa74f,0xa751,0xa751,0xa753,0xa753,0xa755,0xa755,0xa757,0xa757,0xa759,0xa759,0xa75b,0xa75b,0xa75d,0xa75d,0xa75f,0xa75f,0xa761,0xa761,0xa763,0xa763,0xa765,0xa765,0xa767,0xa767,0xa769,0xa769,0xa76b,0xa76b,0xa76d,0xa76d,0xa76f,0xa76f,0xa770,0xa771,0xa772,0xa773,0xa774,0xa775,0xa776,0xa777,0xa778,0xa77a,0xa77a,0xa77c,0xa77c,0x1d79,0xa77f,0xa77f,0xa781,0xa781,0xa783,0xa783,0xa785,0xa785,0xa787,0xa787,0xa788,0xa789,0xa78a,0xa78c,0xa78c,0x265,0xa78e,0xa78f,0xa791,0xa791,0xa792,0xa793,0xa794,0xa795,0xa796,0xa797,0xa798,0xa799,0xa79a,0xa79b,0xa79c,0xa79d,0xa79e,0xa79f,0xa7a1,0xa7a1,0xa7a3,0xa7a3,0xa7a5,0xa7a5,0xa7a7,0xa7a7,0xa7a9,0xa7a9,0xa7aa,0xa7ab,0xa7ac,0xa7ad,0xa7ae,0xa7af,0xa7b0,0xa7b1,0xa7b2,0xa7b3,0xa7b4,0xa7b5,0xa7b6,0xa7b7,0xa7b8,0xa7b9,0xa7ba,0xa7bb,0xa7bc,0xa7bd,0xa7be,0xa7bf,0xa7c0,0xa7c1,0xa7c2,0xa7c3,0xa7c4,0xa7c5,0xa7c6,0xa7c7,0xa7c8,0xa7c9,0xa7ca,0xa7cb,0xa7cc,0xa7cd,0xa7ce,0xa7cf,0xa7d0,0xa7d1,0xa7d2,0xa7d3,0xa7d4,0xa7d5,0xa7d6,0xa7d7,0xa7d8,0xa7d9,0xa7da,0xa7db,0xa7dc,0xa7dd,0xa7de,0xa7df,0xa7e0,0xa7e1,0xa7e2,0xa7e3,0xa7e4,0xa7e5,0xa7e6,0xa7e7,0xa7e8,0xa7e9,0xa7ea,0xa7eb,0xa7ec,0xa7ed,0xa7ee,0xa7ef,0xa7f0,0xa7f1,0xa7f2,0xa7f3,0xa7f4,0xa7f5,0xa7f6,0xa7f7,0xa7f8,0xa7f9,0xa7fa,0xa7fb,0xa7fc,0xa7fd,0xa7fe,0xa7ff};
|
||||
static uint16_t const smallff[] = {0xff00,0xff01,0xff02,0xff03,0xff04,0xff05,0xff06,0xff07,0xff08,0xff09,0xff0a,0xff0b,0xff0c,0xff0d,0xff0e,0xff0f,0xff10,0xff11,0xff12,0xff13,0xff14,0xff15,0xff16,0xff17,0xff18,0xff19,0xff1a,0xff1b,0xff1c,0xff1d,0xff1e,0xff1f,0xff20,0xff41,0xff42,0xff43,0xff44,0xff45,0xff46,0xff47,0xff48,0xff49,0xff4a,0xff4b,0xff4c,0xff4d,0xff4e,0xff4f,0xff50,0xff51,0xff52,0xff53,0xff54,0xff55,0xff56,0xff57,0xff58,0xff59,0xff5a,0xff3b,0xff3c,0xff3d,0xff3e,0xff3f,0xff40,0xff41,0xff42,0xff43,0xff44,0xff45,0xff46,0xff47,0xff48,0xff49,0xff4a,0xff4b,0xff4c,0xff4d,0xff4e,0xff4f,0xff50,0xff51,0xff52,0xff53,0xff54,0xff55,0xff56,0xff57,0xff58,0xff59,0xff5a,0xff5b,0xff5c,0xff5d,0xff5e,0xff5f,0xff60,0xff61,0xff62,0xff63,0xff64,0xff65,0xff66,0xff67,0xff68,0xff69,0xff6a,0xff6b,0xff6c,0xff6d,0xff6e,0xff6f,0xff70,0xff71,0xff72,0xff73,0xff74,0xff75,0xff76,0xff77,0xff78,0xff79,0xff7a,0xff7b,0xff7c,0xff7d,0xff7e,0xff7f,0xff80,0xff81,0xff82,0xff83,0xff84,0xff85,0xff86,0xff87,0xff88,0xff89,0xff8a,0xff8b,0xff8c,0xff8d,0xff8e,0xff8f,0xff90,0xff91,0xff92,0xff93,0xff94,0xff95,0xff96,0xff97,0xff98,0xff99,0xff9a,0xff9b,0xff9c,0xff9d,0xff9e,0xff9f,0xffa0,0xffa1,0xffa2,0xffa3,0xffa4,0xffa5,0xffa6,0xffa7,0xffa8,0xffa9,0xffaa,0xffab,0xffac,0xffad,0xffae,0xffaf,0xffb0,0xffb1,0xffb2,0xffb3,0xffb4,0xffb5,0xffb6,0xffb7,0xffb8,0xffb9,0xffba,0xffbb,0xffbc,0xffbd,0xffbe,0xffbf,0xffc0,0xffc1,0xffc2,0xffc3,0xffc4,0xffc5,0xffc6,0xffc7,0xffc8,0xffc9,0xffca,0xffcb,0xffcc,0xffcd,0xffce,0xffcf,0xffd0,0xffd1,0xffd2,0xffd3,0xffd4,0xffd5,0xffd6,0xffd7,0xffd8,0xffd9,0xffda,0xffdb,0xffdc,0xffdd,0xffde,0xffdf,0xffe0,0xffe1,0xffe2,0xffe3,0xffe4,0xffe5,0xffe6,0xffe7,0xffe8,0xffe9,0xffea,0xffeb,0xffec,0xffed,0xffee,0xffef,0xfff0,0xfff1,0xfff2,0xfff3,0xfff4,0xfff5,0xfff6,0xfff7,0xfff8,0xfff9,0xfffa,0xfffb,0xfffc,0xfffd,0xfffe,0xffff};
|
||||
static uint16_t const small00[] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12,
|
||||
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
|
||||
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e,
|
||||
0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84,
|
||||
0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
|
||||
0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x3bc, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd,
|
||||
0xbe, 0xbf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0x0, 0xe0, 0xe1, 0xe2, 0xe3,
|
||||
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
||||
0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
|
||||
static uint16_t const small01[] = {
|
||||
0x101, 0x101, 0x103, 0x103, 0x105, 0x105, 0x107, 0x107, 0x109, 0x109, 0x10b, 0x10b, 0x10d, 0x10d, 0x10f, 0x10f,
|
||||
0x111, 0x111, 0x113, 0x113, 0x115, 0x115, 0x117, 0x117, 0x119, 0x119, 0x11b, 0x11b, 0x11d, 0x11d, 0x11f, 0x11f,
|
||||
0x121, 0x121, 0x123, 0x123, 0x125, 0x125, 0x127, 0x127, 0x129, 0x129, 0x12b, 0x12b, 0x12d, 0x12d, 0x12f, 0x12f,
|
||||
0x0, 0x131, 0x133, 0x133, 0x135, 0x135, 0x137, 0x137, 0x138, 0x13a, 0x13a, 0x13c, 0x13c, 0x13e, 0x13e, 0x140,
|
||||
0x140, 0x142, 0x142, 0x144, 0x144, 0x146, 0x146, 0x148, 0x148, 0x0, 0x14b, 0x14b, 0x14d, 0x14d, 0x14f, 0x14f,
|
||||
0x151, 0x151, 0x153, 0x153, 0x155, 0x155, 0x157, 0x157, 0x159, 0x159, 0x15b, 0x15b, 0x15d, 0x15d, 0x15f, 0x15f,
|
||||
0x161, 0x161, 0x163, 0x163, 0x165, 0x165, 0x167, 0x167, 0x169, 0x169, 0x16b, 0x16b, 0x16d, 0x16d, 0x16f, 0x16f,
|
||||
0x171, 0x171, 0x173, 0x173, 0x175, 0x175, 0x177, 0x177, 0xff, 0x17a, 0x17a, 0x17c, 0x17c, 0x17e, 0x17e, 0x73,
|
||||
0x180, 0x253, 0x183, 0x183, 0x185, 0x185, 0x254, 0x188, 0x188, 0x256, 0x257, 0x18c, 0x18c, 0x18d, 0x1dd, 0x259,
|
||||
0x25b, 0x192, 0x192, 0x260, 0x263, 0x195, 0x269, 0x268, 0x199, 0x199, 0x19a, 0x19b, 0x26f, 0x272, 0x19e, 0x275,
|
||||
0x1a1, 0x1a1, 0x1a3, 0x1a3, 0x1a5, 0x1a5, 0x280, 0x1a8, 0x1a8, 0x283, 0x1aa, 0x1ab, 0x1ad, 0x1ad, 0x288, 0x1b0,
|
||||
0x1b0, 0x28a, 0x28b, 0x1b4, 0x1b4, 0x1b6, 0x1b6, 0x292, 0x1b9, 0x1b9, 0x1ba, 0x1bb, 0x1bd, 0x1bd, 0x1be, 0x1bf,
|
||||
0x1c0, 0x1c1, 0x1c2, 0x1c3, 0x1c6, 0x1c6, 0x1c6, 0x1c9, 0x1c9, 0x1c9, 0x1cc, 0x1cc, 0x1cc, 0x1ce, 0x1ce, 0x1d0,
|
||||
0x1d0, 0x1d2, 0x1d2, 0x1d4, 0x1d4, 0x1d6, 0x1d6, 0x1d8, 0x1d8, 0x1da, 0x1da, 0x1dc, 0x1dc, 0x1dd, 0x1df, 0x1df,
|
||||
0x1e1, 0x1e1, 0x1e3, 0x1e3, 0x1e5, 0x1e5, 0x1e7, 0x1e7, 0x1e9, 0x1e9, 0x1eb, 0x1eb, 0x1ed, 0x1ed, 0x1ef, 0x1ef,
|
||||
0x0, 0x1f3, 0x1f3, 0x1f3, 0x1f5, 0x1f5, 0x195, 0x1bf, 0x1f9, 0x1f9, 0x1fb, 0x1fb, 0x1fd, 0x1fd, 0x1ff, 0x1ff};
|
||||
static uint16_t const small02[] = {
|
||||
0x201, 0x201, 0x203, 0x203, 0x205, 0x205, 0x207, 0x207, 0x209, 0x209, 0x20b, 0x20b, 0x20d, 0x20d, 0x20f, 0x20f,
|
||||
0x211, 0x211, 0x213, 0x213, 0x215, 0x215, 0x217, 0x217, 0x219, 0x219, 0x21b, 0x21b, 0x21d, 0x21d, 0x21f, 0x21f,
|
||||
0x19e, 0x221, 0x223, 0x223, 0x225, 0x225, 0x227, 0x227, 0x229, 0x229, 0x22b, 0x22b, 0x22d, 0x22d, 0x22f, 0x22f,
|
||||
0x231, 0x231, 0x233, 0x233, 0x234, 0x235, 0x236, 0x237, 0x238, 0x239, 0x2c65, 0x23c, 0x23c, 0x19a, 0x2c66, 0x23f,
|
||||
0x240, 0x242, 0x242, 0x180, 0x289, 0x28c, 0x247, 0x247, 0x249, 0x249, 0x24b, 0x24b, 0x24d, 0x24d, 0x24f, 0x24f,
|
||||
0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, 0x258, 0x259, 0x25a, 0x25b, 0x25c, 0x25d, 0x25e, 0x25f,
|
||||
0x260, 0x261, 0x262, 0x263, 0x264, 0x265, 0x266, 0x267, 0x268, 0x269, 0x26a, 0x26b, 0x26c, 0x26d, 0x26e, 0x26f,
|
||||
0x270, 0x271, 0x272, 0x273, 0x274, 0x275, 0x276, 0x277, 0x278, 0x279, 0x27a, 0x27b, 0x27c, 0x27d, 0x27e, 0x27f,
|
||||
0x280, 0x281, 0x282, 0x283, 0x284, 0x285, 0x286, 0x287, 0x288, 0x289, 0x28a, 0x28b, 0x28c, 0x28d, 0x28e, 0x28f,
|
||||
0x290, 0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0x297, 0x298, 0x299, 0x29a, 0x29b, 0x29c, 0x29d, 0x29e, 0x29f,
|
||||
0x2a0, 0x2a1, 0x2a2, 0x2a3, 0x2a4, 0x2a5, 0x2a6, 0x2a7, 0x2a8, 0x2a9, 0x2aa, 0x2ab, 0x2ac, 0x2ad, 0x2ae, 0x2af,
|
||||
0x2b0, 0x2b1, 0x2b2, 0x2b3, 0x2b4, 0x2b5, 0x2b6, 0x2b7, 0x2b8, 0x2b9, 0x2ba, 0x2bb, 0x2bc, 0x2bd, 0x2be, 0x2bf,
|
||||
0x2c0, 0x2c1, 0x2c2, 0x2c3, 0x2c4, 0x2c5, 0x2c6, 0x2c7, 0x2c8, 0x2c9, 0x2ca, 0x2cb, 0x2cc, 0x2cd, 0x2ce, 0x2cf,
|
||||
0x2d0, 0x2d1, 0x2d2, 0x2d3, 0x2d4, 0x2d5, 0x2d6, 0x2d7, 0x2d8, 0x2d9, 0x2da, 0x2db, 0x2dc, 0x2dd, 0x2de, 0x2df,
|
||||
0x2e0, 0x2e1, 0x2e2, 0x2e3, 0x2e4, 0x2e5, 0x2e6, 0x2e7, 0x2e8, 0x2e9, 0x2ea, 0x2eb, 0x2ec, 0x2ed, 0x2ee, 0x2ef,
|
||||
0x2f0, 0x2f1, 0x2f2, 0x2f3, 0x2f4, 0x2f5, 0x2f6, 0x2f7, 0x2f8, 0x2f9, 0x2fa, 0x2fb, 0x2fc, 0x2fd, 0x2fe, 0x2ff};
|
||||
static uint16_t const small03[] = {
|
||||
0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x306, 0x307, 0x308, 0x309, 0x30a, 0x30b, 0x30c, 0x30d, 0x30e, 0x30f,
|
||||
0x310, 0x311, 0x312, 0x313, 0x314, 0x315, 0x316, 0x317, 0x318, 0x319, 0x31a, 0x31b, 0x31c, 0x31d, 0x31e, 0x31f,
|
||||
0x320, 0x321, 0x322, 0x323, 0x324, 0x325, 0x326, 0x327, 0x328, 0x329, 0x32a, 0x32b, 0x32c, 0x32d, 0x32e, 0x32f,
|
||||
0x330, 0x331, 0x332, 0x333, 0x334, 0x335, 0x336, 0x337, 0x338, 0x339, 0x33a, 0x33b, 0x33c, 0x33d, 0x33e, 0x33f,
|
||||
0x340, 0x341, 0x342, 0x343, 0x344, 0x3b9, 0x346, 0x347, 0x348, 0x349, 0x34a, 0x34b, 0x34c, 0x34d, 0x34e, 0x34f,
|
||||
0x350, 0x351, 0x352, 0x353, 0x354, 0x355, 0x356, 0x357, 0x358, 0x359, 0x35a, 0x35b, 0x35c, 0x35d, 0x35e, 0x35f,
|
||||
0x360, 0x361, 0x362, 0x363, 0x364, 0x365, 0x366, 0x367, 0x368, 0x369, 0x36a, 0x36b, 0x36c, 0x36d, 0x36e, 0x36f,
|
||||
0x371, 0x371, 0x373, 0x373, 0x374, 0x375, 0x377, 0x377, 0x378, 0x379, 0x37a, 0x37b, 0x37c, 0x37d, 0x37e, 0x37f,
|
||||
0x380, 0x381, 0x382, 0x383, 0x384, 0x385, 0x3ac, 0x387, 0x3ad, 0x3ae, 0x3af, 0x38b, 0x3cc, 0x38d, 0x3cd, 0x3ce,
|
||||
0x0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf,
|
||||
0x3c0, 0x3c1, 0x3a2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3ac, 0x3ad, 0x3ae, 0x3af,
|
||||
0x0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf,
|
||||
0x3c0, 0x3c1, 0x3c3, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3cc, 0x3cd, 0x3ce, 0x3d7,
|
||||
0x3b2, 0x3b8, 0x3d2, 0x3d3, 0x3d4, 0x3c6, 0x3c0, 0x3d7, 0x3d9, 0x3d9, 0x3db, 0x3db, 0x3dd, 0x3dd, 0x3df, 0x3df,
|
||||
0x3e1, 0x3e1, 0x3e3, 0x3e3, 0x3e5, 0x3e5, 0x3e7, 0x3e7, 0x3e9, 0x3e9, 0x3eb, 0x3eb, 0x3ed, 0x3ed, 0x3ef, 0x3ef,
|
||||
0x3ba, 0x3c1, 0x3f2, 0x3f3, 0x3b8, 0x3b5, 0x3f6, 0x3f8, 0x3f8, 0x3f2, 0x3fb, 0x3fb, 0x3fc, 0x37b, 0x37c, 0x37d};
|
||||
static uint16_t const small04[] = {
|
||||
0x450, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45a, 0x45b, 0x45c, 0x45d, 0x45e, 0x45f,
|
||||
0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
|
||||
0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f,
|
||||
0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
|
||||
0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f,
|
||||
0x450, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45a, 0x45b, 0x45c, 0x45d, 0x45e, 0x45f,
|
||||
0x461, 0x461, 0x463, 0x463, 0x465, 0x465, 0x467, 0x467, 0x469, 0x469, 0x46b, 0x46b, 0x46d, 0x46d, 0x46f, 0x46f,
|
||||
0x471, 0x471, 0x473, 0x473, 0x475, 0x475, 0x477, 0x477, 0x479, 0x479, 0x47b, 0x47b, 0x47d, 0x47d, 0x47f, 0x47f,
|
||||
0x481, 0x481, 0x482, 0x483, 0x484, 0x485, 0x486, 0x487, 0x488, 0x489, 0x48b, 0x48b, 0x48d, 0x48d, 0x48f, 0x48f,
|
||||
0x491, 0x491, 0x493, 0x493, 0x495, 0x495, 0x497, 0x497, 0x499, 0x499, 0x49b, 0x49b, 0x49d, 0x49d, 0x49f, 0x49f,
|
||||
0x4a1, 0x4a1, 0x4a3, 0x4a3, 0x4a5, 0x4a5, 0x4a7, 0x4a7, 0x4a9, 0x4a9, 0x4ab, 0x4ab, 0x4ad, 0x4ad, 0x4af, 0x4af,
|
||||
0x4b1, 0x4b1, 0x4b3, 0x4b3, 0x4b5, 0x4b5, 0x4b7, 0x4b7, 0x4b9, 0x4b9, 0x4bb, 0x4bb, 0x4bd, 0x4bd, 0x4bf, 0x4bf,
|
||||
0x4cf, 0x4c2, 0x4c2, 0x4c4, 0x4c4, 0x4c6, 0x4c6, 0x4c8, 0x4c8, 0x4ca, 0x4ca, 0x4cc, 0x4cc, 0x4ce, 0x4ce, 0x4cf,
|
||||
0x4d1, 0x4d1, 0x4d3, 0x4d3, 0x4d5, 0x4d5, 0x4d7, 0x4d7, 0x4d9, 0x4d9, 0x4db, 0x4db, 0x4dd, 0x4dd, 0x4df, 0x4df,
|
||||
0x4e1, 0x4e1, 0x4e3, 0x4e3, 0x4e5, 0x4e5, 0x4e7, 0x4e7, 0x4e9, 0x4e9, 0x4eb, 0x4eb, 0x4ed, 0x4ed, 0x4ef, 0x4ef,
|
||||
0x4f1, 0x4f1, 0x4f3, 0x4f3, 0x4f5, 0x4f5, 0x4f7, 0x4f7, 0x4f9, 0x4f9, 0x4fb, 0x4fb, 0x4fd, 0x4fd, 0x4ff, 0x4ff};
|
||||
static uint16_t const small05[] = {
|
||||
0x501, 0x501, 0x503, 0x503, 0x505, 0x505, 0x507, 0x507, 0x509, 0x509, 0x50b, 0x50b, 0x50d, 0x50d, 0x50f, 0x50f,
|
||||
0x511, 0x511, 0x513, 0x513, 0x515, 0x515, 0x517, 0x517, 0x519, 0x519, 0x51b, 0x51b, 0x51d, 0x51d, 0x51f, 0x51f,
|
||||
0x521, 0x521, 0x523, 0x523, 0x525, 0x525, 0x527, 0x527, 0x528, 0x529, 0x52a, 0x52b, 0x52c, 0x52d, 0x52e, 0x52f,
|
||||
0x530, 0x561, 0x562, 0x563, 0x564, 0x565, 0x566, 0x567, 0x568, 0x569, 0x56a, 0x56b, 0x56c, 0x56d, 0x56e, 0x56f,
|
||||
0x570, 0x571, 0x572, 0x573, 0x574, 0x575, 0x576, 0x577, 0x578, 0x579, 0x57a, 0x57b, 0x57c, 0x57d, 0x57e, 0x57f,
|
||||
0x580, 0x581, 0x582, 0x583, 0x584, 0x585, 0x586, 0x557, 0x558, 0x559, 0x55a, 0x55b, 0x55c, 0x55d, 0x55e, 0x55f,
|
||||
0x560, 0x561, 0x562, 0x563, 0x564, 0x565, 0x566, 0x567, 0x568, 0x569, 0x56a, 0x56b, 0x56c, 0x56d, 0x56e, 0x56f,
|
||||
0x570, 0x571, 0x572, 0x573, 0x574, 0x575, 0x576, 0x577, 0x578, 0x579, 0x57a, 0x57b, 0x57c, 0x57d, 0x57e, 0x57f,
|
||||
0x580, 0x581, 0x582, 0x583, 0x584, 0x585, 0x586, 0x0, 0x588, 0x589, 0x58a, 0x58b, 0x58c, 0x58d, 0x58e, 0x58f,
|
||||
0x590, 0x591, 0x592, 0x593, 0x594, 0x595, 0x596, 0x597, 0x598, 0x599, 0x59a, 0x59b, 0x59c, 0x59d, 0x59e, 0x59f,
|
||||
0x5a0, 0x5a1, 0x5a2, 0x5a3, 0x5a4, 0x5a5, 0x5a6, 0x5a7, 0x5a8, 0x5a9, 0x5aa, 0x5ab, 0x5ac, 0x5ad, 0x5ae, 0x5af,
|
||||
0x5b0, 0x5b1, 0x5b2, 0x5b3, 0x5b4, 0x5b5, 0x5b6, 0x5b7, 0x5b8, 0x5b9, 0x5ba, 0x5bb, 0x5bc, 0x5bd, 0x5be, 0x5bf,
|
||||
0x5c0, 0x5c1, 0x5c2, 0x5c3, 0x5c4, 0x5c5, 0x5c6, 0x5c7, 0x5c8, 0x5c9, 0x5ca, 0x5cb, 0x5cc, 0x5cd, 0x5ce, 0x5cf,
|
||||
0x5d0, 0x5d1, 0x5d2, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7, 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df,
|
||||
0x5e0, 0x5e1, 0x5e2, 0x5e3, 0x5e4, 0x5e5, 0x5e6, 0x5e7, 0x5e8, 0x5e9, 0x5ea, 0x5eb, 0x5ec, 0x5ed, 0x5ee, 0x5ef,
|
||||
0x5f0, 0x5f1, 0x5f2, 0x5f3, 0x5f4, 0x5f5, 0x5f6, 0x5f7, 0x5f8, 0x5f9, 0x5fa, 0x5fb, 0x5fc, 0x5fd, 0x5fe, 0x5ff};
|
||||
static uint16_t const small10[] = {
|
||||
0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x100a, 0x100b, 0x100c, 0x100d,
|
||||
0x100e, 0x100f, 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017, 0x1018, 0x1019, 0x101a, 0x101b,
|
||||
0x101c, 0x101d, 0x101e, 0x101f, 0x1020, 0x1021, 0x1022, 0x1023, 0x1024, 0x1025, 0x1026, 0x1027, 0x1028, 0x1029,
|
||||
0x102a, 0x102b, 0x102c, 0x102d, 0x102e, 0x102f, 0x1030, 0x1031, 0x1032, 0x1033, 0x1034, 0x1035, 0x1036, 0x1037,
|
||||
0x1038, 0x1039, 0x103a, 0x103b, 0x103c, 0x103d, 0x103e, 0x103f, 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045,
|
||||
0x1046, 0x1047, 0x1048, 0x1049, 0x104a, 0x104b, 0x104c, 0x104d, 0x104e, 0x104f, 0x1050, 0x1051, 0x1052, 0x1053,
|
||||
0x1054, 0x1055, 0x1056, 0x1057, 0x1058, 0x1059, 0x105a, 0x105b, 0x105c, 0x105d, 0x105e, 0x105f, 0x1060, 0x1061,
|
||||
0x1062, 0x1063, 0x1064, 0x1065, 0x1066, 0x1067, 0x1068, 0x1069, 0x106a, 0x106b, 0x106c, 0x106d, 0x106e, 0x106f,
|
||||
0x1070, 0x1071, 0x1072, 0x1073, 0x1074, 0x1075, 0x1076, 0x1077, 0x1078, 0x1079, 0x107a, 0x107b, 0x107c, 0x107d,
|
||||
0x107e, 0x107f, 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086, 0x1087, 0x1088, 0x1089, 0x108a, 0x108b,
|
||||
0x108c, 0x108d, 0x108e, 0x108f, 0x1090, 0x1091, 0x1092, 0x1093, 0x1094, 0x1095, 0x1096, 0x1097, 0x1098, 0x1099,
|
||||
0x109a, 0x109b, 0x109c, 0x109d, 0x109e, 0x109f, 0x2d00, 0x2d01, 0x2d02, 0x2d03, 0x2d04, 0x2d05, 0x2d06, 0x2d07,
|
||||
0x2d08, 0x2d09, 0x2d0a, 0x2d0b, 0x2d0c, 0x2d0d, 0x2d0e, 0x2d0f, 0x2d10, 0x2d11, 0x2d12, 0x2d13, 0x2d14, 0x2d15,
|
||||
0x2d16, 0x2d17, 0x2d18, 0x2d19, 0x2d1a, 0x2d1b, 0x2d1c, 0x2d1d, 0x2d1e, 0x2d1f, 0x2d20, 0x2d21, 0x2d22, 0x2d23,
|
||||
0x2d24, 0x2d25, 0x10c6, 0x10c7, 0x10c8, 0x10c9, 0x10ca, 0x10cb, 0x10cc, 0x10cd, 0x10ce, 0x10cf, 0x10d0, 0x10d1,
|
||||
0x10d2, 0x10d3, 0x10d4, 0x10d5, 0x10d6, 0x10d7, 0x10d8, 0x10d9, 0x10da, 0x10db, 0x10dc, 0x10dd, 0x10de, 0x10df,
|
||||
0x10e0, 0x10e1, 0x10e2, 0x10e3, 0x10e4, 0x10e5, 0x10e6, 0x10e7, 0x10e8, 0x10e9, 0x10ea, 0x10eb, 0x10ec, 0x10ed,
|
||||
0x10ee, 0x10ef, 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x10f8, 0x10f9, 0x10fa, 0x10fb,
|
||||
0x10fc, 0x10fd, 0x10fe, 0x10ff};
|
||||
static uint16_t const small1e[] = {
|
||||
0x1e01, 0x1e01, 0x1e03, 0x1e03, 0x1e05, 0x1e05, 0x1e07, 0x1e07, 0x1e09, 0x1e09, 0x1e0b, 0x1e0b, 0x1e0d, 0x1e0d,
|
||||
0x1e0f, 0x1e0f, 0x1e11, 0x1e11, 0x1e13, 0x1e13, 0x1e15, 0x1e15, 0x1e17, 0x1e17, 0x1e19, 0x1e19, 0x1e1b, 0x1e1b,
|
||||
0x1e1d, 0x1e1d, 0x1e1f, 0x1e1f, 0x1e21, 0x1e21, 0x1e23, 0x1e23, 0x1e25, 0x1e25, 0x1e27, 0x1e27, 0x1e29, 0x1e29,
|
||||
0x1e2b, 0x1e2b, 0x1e2d, 0x1e2d, 0x1e2f, 0x1e2f, 0x1e31, 0x1e31, 0x1e33, 0x1e33, 0x1e35, 0x1e35, 0x1e37, 0x1e37,
|
||||
0x1e39, 0x1e39, 0x1e3b, 0x1e3b, 0x1e3d, 0x1e3d, 0x1e3f, 0x1e3f, 0x1e41, 0x1e41, 0x1e43, 0x1e43, 0x1e45, 0x1e45,
|
||||
0x1e47, 0x1e47, 0x1e49, 0x1e49, 0x1e4b, 0x1e4b, 0x1e4d, 0x1e4d, 0x1e4f, 0x1e4f, 0x1e51, 0x1e51, 0x1e53, 0x1e53,
|
||||
0x1e55, 0x1e55, 0x1e57, 0x1e57, 0x1e59, 0x1e59, 0x1e5b, 0x1e5b, 0x1e5d, 0x1e5d, 0x1e5f, 0x1e5f, 0x1e61, 0x1e61,
|
||||
0x1e63, 0x1e63, 0x1e65, 0x1e65, 0x1e67, 0x1e67, 0x1e69, 0x1e69, 0x1e6b, 0x1e6b, 0x1e6d, 0x1e6d, 0x1e6f, 0x1e6f,
|
||||
0x1e71, 0x1e71, 0x1e73, 0x1e73, 0x1e75, 0x1e75, 0x1e77, 0x1e77, 0x1e79, 0x1e79, 0x1e7b, 0x1e7b, 0x1e7d, 0x1e7d,
|
||||
0x1e7f, 0x1e7f, 0x1e81, 0x1e81, 0x1e83, 0x1e83, 0x1e85, 0x1e85, 0x1e87, 0x1e87, 0x1e89, 0x1e89, 0x1e8b, 0x1e8b,
|
||||
0x1e8d, 0x1e8d, 0x1e8f, 0x1e8f, 0x1e91, 0x1e91, 0x1e93, 0x1e93, 0x1e95, 0x1e95, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x1e61, 0x1e9c, 0x1e9d, 0x0, 0x1e9f, 0x1ea1, 0x1ea1, 0x1ea3, 0x1ea3, 0x1ea5, 0x1ea5, 0x1ea7, 0x1ea7,
|
||||
0x1ea9, 0x1ea9, 0x1eab, 0x1eab, 0x1ead, 0x1ead, 0x1eaf, 0x1eaf, 0x1eb1, 0x1eb1, 0x1eb3, 0x1eb3, 0x1eb5, 0x1eb5,
|
||||
0x1eb7, 0x1eb7, 0x1eb9, 0x1eb9, 0x1ebb, 0x1ebb, 0x1ebd, 0x1ebd, 0x1ebf, 0x1ebf, 0x1ec1, 0x1ec1, 0x1ec3, 0x1ec3,
|
||||
0x1ec5, 0x1ec5, 0x1ec7, 0x1ec7, 0x1ec9, 0x1ec9, 0x1ecb, 0x1ecb, 0x1ecd, 0x1ecd, 0x1ecf, 0x1ecf, 0x1ed1, 0x1ed1,
|
||||
0x1ed3, 0x1ed3, 0x1ed5, 0x1ed5, 0x1ed7, 0x1ed7, 0x1ed9, 0x1ed9, 0x1edb, 0x1edb, 0x1edd, 0x1edd, 0x1edf, 0x1edf,
|
||||
0x1ee1, 0x1ee1, 0x1ee3, 0x1ee3, 0x1ee5, 0x1ee5, 0x1ee7, 0x1ee7, 0x1ee9, 0x1ee9, 0x1eeb, 0x1eeb, 0x1eed, 0x1eed,
|
||||
0x1eef, 0x1eef, 0x1ef1, 0x1ef1, 0x1ef3, 0x1ef3, 0x1ef5, 0x1ef5, 0x1ef7, 0x1ef7, 0x1ef9, 0x1ef9, 0x1efb, 0x1efb,
|
||||
0x1efd, 0x1efd, 0x1eff, 0x1eff};
|
||||
static uint16_t const small1f[] = {
|
||||
0x1f00, 0x1f01, 0x1f02, 0x1f03, 0x1f04, 0x1f05, 0x1f06, 0x1f07, 0x1f00, 0x1f01, 0x1f02, 0x1f03, 0x1f04, 0x1f05,
|
||||
0x1f06, 0x1f07, 0x1f10, 0x1f11, 0x1f12, 0x1f13, 0x1f14, 0x1f15, 0x1f16, 0x1f17, 0x1f10, 0x1f11, 0x1f12, 0x1f13,
|
||||
0x1f14, 0x1f15, 0x1f1e, 0x1f1f, 0x1f20, 0x1f21, 0x1f22, 0x1f23, 0x1f24, 0x1f25, 0x1f26, 0x1f27, 0x1f20, 0x1f21,
|
||||
0x1f22, 0x1f23, 0x1f24, 0x1f25, 0x1f26, 0x1f27, 0x1f30, 0x1f31, 0x1f32, 0x1f33, 0x1f34, 0x1f35, 0x1f36, 0x1f37,
|
||||
0x1f30, 0x1f31, 0x1f32, 0x1f33, 0x1f34, 0x1f35, 0x1f36, 0x1f37, 0x1f40, 0x1f41, 0x1f42, 0x1f43, 0x1f44, 0x1f45,
|
||||
0x1f46, 0x1f47, 0x1f40, 0x1f41, 0x1f42, 0x1f43, 0x1f44, 0x1f45, 0x1f4e, 0x1f4f, 0x0, 0x1f51, 0x0, 0x1f53,
|
||||
0x0, 0x1f55, 0x0, 0x1f57, 0x1f58, 0x1f51, 0x1f5a, 0x1f53, 0x1f5c, 0x1f55, 0x1f5e, 0x1f57, 0x1f60, 0x1f61,
|
||||
0x1f62, 0x1f63, 0x1f64, 0x1f65, 0x1f66, 0x1f67, 0x1f60, 0x1f61, 0x1f62, 0x1f63, 0x1f64, 0x1f65, 0x1f66, 0x1f67,
|
||||
0x1f70, 0x1f71, 0x1f72, 0x1f73, 0x1f74, 0x1f75, 0x1f76, 0x1f77, 0x1f78, 0x1f79, 0x1f7a, 0x1f7b, 0x1f7c, 0x1f7d,
|
||||
0x1f7e, 0x1f7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1fb0, 0x1fb1, 0x0, 0x0, 0x0, 0x1fb5,
|
||||
0x0, 0x0, 0x1fb0, 0x1fb1, 0x1f70, 0x1f71, 0x0, 0x1fbd, 0x3b9, 0x1fbf, 0x1fc0, 0x1fc1, 0x0, 0x0,
|
||||
0x0, 0x1fc5, 0x0, 0x0, 0x1f72, 0x1f73, 0x1f74, 0x1f75, 0x0, 0x1fcd, 0x1fce, 0x1fcf, 0x1fd0, 0x1fd1,
|
||||
0x0, 0x0, 0x1fd4, 0x1fd5, 0x0, 0x0, 0x1fd0, 0x1fd1, 0x1f76, 0x1f77, 0x1fdc, 0x1fdd, 0x1fde, 0x1fdf,
|
||||
0x1fe0, 0x1fe1, 0x0, 0x0, 0x0, 0x1fe5, 0x0, 0x0, 0x1fe0, 0x1fe1, 0x1f7a, 0x1f7b, 0x1fe5, 0x1fed,
|
||||
0x1fee, 0x1fef, 0x1ff0, 0x1ff1, 0x0, 0x0, 0x0, 0x1ff5, 0x0, 0x0, 0x1f78, 0x1f79, 0x1f7c, 0x1f7d,
|
||||
0x0, 0x1ffd, 0x1ffe, 0x1fff};
|
||||
static uint16_t const small21[] = {
|
||||
0x2100, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2109, 0x210a, 0x210b, 0x210c, 0x210d,
|
||||
0x210e, 0x210f, 0x2110, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, 0x2119, 0x211a, 0x211b,
|
||||
0x211c, 0x211d, 0x211e, 0x211f, 0x2120, 0x2121, 0x2122, 0x2123, 0x2124, 0x2125, 0x3c9, 0x2127, 0x2128, 0x2129,
|
||||
0x6b, 0xe5, 0x212c, 0x212d, 0x212e, 0x212f, 0x2130, 0x2131, 0x214e, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137,
|
||||
0x2138, 0x2139, 0x213a, 0x213b, 0x213c, 0x213d, 0x213e, 0x213f, 0x2140, 0x2141, 0x2142, 0x2143, 0x2144, 0x2145,
|
||||
0x2146, 0x2147, 0x2148, 0x2149, 0x214a, 0x214b, 0x214c, 0x214d, 0x214e, 0x214f, 0x2150, 0x2151, 0x2152, 0x2153,
|
||||
0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, 0x215b, 0x215c, 0x215d, 0x215e, 0x215f, 0x2170, 0x2171,
|
||||
0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217a, 0x217b, 0x217c, 0x217d, 0x217e, 0x217f,
|
||||
0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217a, 0x217b, 0x217c, 0x217d,
|
||||
0x217e, 0x217f, 0x2180, 0x2181, 0x2182, 0x2184, 0x2184, 0x2185, 0x2186, 0x2187, 0x2188, 0x2189, 0x218a, 0x218b,
|
||||
0x218c, 0x218d, 0x218e, 0x218f, 0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199,
|
||||
0x219a, 0x219b, 0x219c, 0x219d, 0x219e, 0x219f, 0x21a0, 0x21a1, 0x21a2, 0x21a3, 0x21a4, 0x21a5, 0x21a6, 0x21a7,
|
||||
0x21a8, 0x21a9, 0x21aa, 0x21ab, 0x21ac, 0x21ad, 0x21ae, 0x21af, 0x21b0, 0x21b1, 0x21b2, 0x21b3, 0x21b4, 0x21b5,
|
||||
0x21b6, 0x21b7, 0x21b8, 0x21b9, 0x21ba, 0x21bb, 0x21bc, 0x21bd, 0x21be, 0x21bf, 0x21c0, 0x21c1, 0x21c2, 0x21c3,
|
||||
0x21c4, 0x21c5, 0x21c6, 0x21c7, 0x21c8, 0x21c9, 0x21ca, 0x21cb, 0x21cc, 0x21cd, 0x21ce, 0x21cf, 0x21d0, 0x21d1,
|
||||
0x21d2, 0x21d3, 0x21d4, 0x21d5, 0x21d6, 0x21d7, 0x21d8, 0x21d9, 0x21da, 0x21db, 0x21dc, 0x21dd, 0x21de, 0x21df,
|
||||
0x21e0, 0x21e1, 0x21e2, 0x21e3, 0x21e4, 0x21e5, 0x21e6, 0x21e7, 0x21e8, 0x21e9, 0x21ea, 0x21eb, 0x21ec, 0x21ed,
|
||||
0x21ee, 0x21ef, 0x21f0, 0x21f1, 0x21f2, 0x21f3, 0x21f4, 0x21f5, 0x21f6, 0x21f7, 0x21f8, 0x21f9, 0x21fa, 0x21fb,
|
||||
0x21fc, 0x21fd, 0x21fe, 0x21ff};
|
||||
static uint16_t const small24[] = {
|
||||
0x2400, 0x2401, 0x2402, 0x2403, 0x2404, 0x2405, 0x2406, 0x2407, 0x2408, 0x2409, 0x240a, 0x240b, 0x240c, 0x240d,
|
||||
0x240e, 0x240f, 0x2410, 0x2411, 0x2412, 0x2413, 0x2414, 0x2415, 0x2416, 0x2417, 0x2418, 0x2419, 0x241a, 0x241b,
|
||||
0x241c, 0x241d, 0x241e, 0x241f, 0x2420, 0x2421, 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427, 0x2428, 0x2429,
|
||||
0x242a, 0x242b, 0x242c, 0x242d, 0x242e, 0x242f, 0x2430, 0x2431, 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437,
|
||||
0x2438, 0x2439, 0x243a, 0x243b, 0x243c, 0x243d, 0x243e, 0x243f, 0x2440, 0x2441, 0x2442, 0x2443, 0x2444, 0x2445,
|
||||
0x2446, 0x2447, 0x2448, 0x2449, 0x244a, 0x244b, 0x244c, 0x244d, 0x244e, 0x244f, 0x2450, 0x2451, 0x2452, 0x2453,
|
||||
0x2454, 0x2455, 0x2456, 0x2457, 0x2458, 0x2459, 0x245a, 0x245b, 0x245c, 0x245d, 0x245e, 0x245f, 0x2460, 0x2461,
|
||||
0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x246f,
|
||||
0x2470, 0x2471, 0x2472, 0x2473, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a, 0x247b, 0x247c, 0x247d,
|
||||
0x247e, 0x247f, 0x2480, 0x2481, 0x2482, 0x2483, 0x2484, 0x2485, 0x2486, 0x2487, 0x2488, 0x2489, 0x248a, 0x248b,
|
||||
0x248c, 0x248d, 0x248e, 0x248f, 0x2490, 0x2491, 0x2492, 0x2493, 0x2494, 0x2495, 0x2496, 0x2497, 0x2498, 0x2499,
|
||||
0x249a, 0x249b, 0x249c, 0x249d, 0x249e, 0x249f, 0x24a0, 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5, 0x24a6, 0x24a7,
|
||||
0x24a8, 0x24a9, 0x24aa, 0x24ab, 0x24ac, 0x24ad, 0x24ae, 0x24af, 0x24b0, 0x24b1, 0x24b2, 0x24b3, 0x24b4, 0x24b5,
|
||||
0x24d0, 0x24d1, 0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd,
|
||||
0x24de, 0x24df, 0x24e0, 0x24e1, 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x24d0, 0x24d1,
|
||||
0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd, 0x24de, 0x24df,
|
||||
0x24e0, 0x24e1, 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x24ea, 0x24eb, 0x24ec, 0x24ed,
|
||||
0x24ee, 0x24ef, 0x24f0, 0x24f1, 0x24f2, 0x24f3, 0x24f4, 0x24f5, 0x24f6, 0x24f7, 0x24f8, 0x24f9, 0x24fa, 0x24fb,
|
||||
0x24fc, 0x24fd, 0x24fe, 0x24ff};
|
||||
static uint16_t const small2c[] = {
|
||||
0x2c30, 0x2c31, 0x2c32, 0x2c33, 0x2c34, 0x2c35, 0x2c36, 0x2c37, 0x2c38, 0x2c39, 0x2c3a, 0x2c3b, 0x2c3c, 0x2c3d,
|
||||
0x2c3e, 0x2c3f, 0x2c40, 0x2c41, 0x2c42, 0x2c43, 0x2c44, 0x2c45, 0x2c46, 0x2c47, 0x2c48, 0x2c49, 0x2c4a, 0x2c4b,
|
||||
0x2c4c, 0x2c4d, 0x2c4e, 0x2c4f, 0x2c50, 0x2c51, 0x2c52, 0x2c53, 0x2c54, 0x2c55, 0x2c56, 0x2c57, 0x2c58, 0x2c59,
|
||||
0x2c5a, 0x2c5b, 0x2c5c, 0x2c5d, 0x2c5e, 0x2c2f, 0x2c30, 0x2c31, 0x2c32, 0x2c33, 0x2c34, 0x2c35, 0x2c36, 0x2c37,
|
||||
0x2c38, 0x2c39, 0x2c3a, 0x2c3b, 0x2c3c, 0x2c3d, 0x2c3e, 0x2c3f, 0x2c40, 0x2c41, 0x2c42, 0x2c43, 0x2c44, 0x2c45,
|
||||
0x2c46, 0x2c47, 0x2c48, 0x2c49, 0x2c4a, 0x2c4b, 0x2c4c, 0x2c4d, 0x2c4e, 0x2c4f, 0x2c50, 0x2c51, 0x2c52, 0x2c53,
|
||||
0x2c54, 0x2c55, 0x2c56, 0x2c57, 0x2c58, 0x2c59, 0x2c5a, 0x2c5b, 0x2c5c, 0x2c5d, 0x2c5e, 0x2c5f, 0x2c61, 0x2c61,
|
||||
0x26b, 0x1d7d, 0x27d, 0x2c65, 0x2c66, 0x2c68, 0x2c68, 0x2c6a, 0x2c6a, 0x2c6c, 0x2c6c, 0x251, 0x271, 0x250,
|
||||
0x252, 0x2c71, 0x2c73, 0x2c73, 0x2c74, 0x2c76, 0x2c76, 0x2c77, 0x2c78, 0x2c79, 0x2c7a, 0x2c7b, 0x2c7c, 0x2c7d,
|
||||
0x23f, 0x240, 0x2c81, 0x2c81, 0x2c83, 0x2c83, 0x2c85, 0x2c85, 0x2c87, 0x2c87, 0x2c89, 0x2c89, 0x2c8b, 0x2c8b,
|
||||
0x2c8d, 0x2c8d, 0x2c8f, 0x2c8f, 0x2c91, 0x2c91, 0x2c93, 0x2c93, 0x2c95, 0x2c95, 0x2c97, 0x2c97, 0x2c99, 0x2c99,
|
||||
0x2c9b, 0x2c9b, 0x2c9d, 0x2c9d, 0x2c9f, 0x2c9f, 0x2ca1, 0x2ca1, 0x2ca3, 0x2ca3, 0x2ca5, 0x2ca5, 0x2ca7, 0x2ca7,
|
||||
0x2ca9, 0x2ca9, 0x2cab, 0x2cab, 0x2cad, 0x2cad, 0x2caf, 0x2caf, 0x2cb1, 0x2cb1, 0x2cb3, 0x2cb3, 0x2cb5, 0x2cb5,
|
||||
0x2cb7, 0x2cb7, 0x2cb9, 0x2cb9, 0x2cbb, 0x2cbb, 0x2cbd, 0x2cbd, 0x2cbf, 0x2cbf, 0x2cc1, 0x2cc1, 0x2cc3, 0x2cc3,
|
||||
0x2cc5, 0x2cc5, 0x2cc7, 0x2cc7, 0x2cc9, 0x2cc9, 0x2ccb, 0x2ccb, 0x2ccd, 0x2ccd, 0x2ccf, 0x2ccf, 0x2cd1, 0x2cd1,
|
||||
0x2cd3, 0x2cd3, 0x2cd5, 0x2cd5, 0x2cd7, 0x2cd7, 0x2cd9, 0x2cd9, 0x2cdb, 0x2cdb, 0x2cdd, 0x2cdd, 0x2cdf, 0x2cdf,
|
||||
0x2ce1, 0x2ce1, 0x2ce3, 0x2ce3, 0x2ce4, 0x2ce5, 0x2ce6, 0x2ce7, 0x2ce8, 0x2ce9, 0x2cea, 0x2cec, 0x2cec, 0x2cee,
|
||||
0x2cee, 0x2cef, 0x2cf0, 0x2cf1, 0x2cf2, 0x2cf3, 0x2cf4, 0x2cf5, 0x2cf6, 0x2cf7, 0x2cf8, 0x2cf9, 0x2cfa, 0x2cfb,
|
||||
0x2cfc, 0x2cfd, 0x2cfe, 0x2cff};
|
||||
static uint16_t const smalla6[] = {
|
||||
0xa600, 0xa601, 0xa602, 0xa603, 0xa604, 0xa605, 0xa606, 0xa607, 0xa608, 0xa609, 0xa60a, 0xa60b, 0xa60c, 0xa60d,
|
||||
0xa60e, 0xa60f, 0xa610, 0xa611, 0xa612, 0xa613, 0xa614, 0xa615, 0xa616, 0xa617, 0xa618, 0xa619, 0xa61a, 0xa61b,
|
||||
0xa61c, 0xa61d, 0xa61e, 0xa61f, 0xa620, 0xa621, 0xa622, 0xa623, 0xa624, 0xa625, 0xa626, 0xa627, 0xa628, 0xa629,
|
||||
0xa62a, 0xa62b, 0xa62c, 0xa62d, 0xa62e, 0xa62f, 0xa630, 0xa631, 0xa632, 0xa633, 0xa634, 0xa635, 0xa636, 0xa637,
|
||||
0xa638, 0xa639, 0xa63a, 0xa63b, 0xa63c, 0xa63d, 0xa63e, 0xa63f, 0xa641, 0xa641, 0xa643, 0xa643, 0xa645, 0xa645,
|
||||
0xa647, 0xa647, 0xa649, 0xa649, 0xa64b, 0xa64b, 0xa64d, 0xa64d, 0xa64f, 0xa64f, 0xa651, 0xa651, 0xa653, 0xa653,
|
||||
0xa655, 0xa655, 0xa657, 0xa657, 0xa659, 0xa659, 0xa65b, 0xa65b, 0xa65d, 0xa65d, 0xa65f, 0xa65f, 0xa661, 0xa661,
|
||||
0xa663, 0xa663, 0xa665, 0xa665, 0xa667, 0xa667, 0xa669, 0xa669, 0xa66b, 0xa66b, 0xa66d, 0xa66d, 0xa66e, 0xa66f,
|
||||
0xa670, 0xa671, 0xa672, 0xa673, 0xa674, 0xa675, 0xa676, 0xa677, 0xa678, 0xa679, 0xa67a, 0xa67b, 0xa67c, 0xa67d,
|
||||
0xa67e, 0xa67f, 0xa681, 0xa681, 0xa683, 0xa683, 0xa685, 0xa685, 0xa687, 0xa687, 0xa689, 0xa689, 0xa68b, 0xa68b,
|
||||
0xa68d, 0xa68d, 0xa68f, 0xa68f, 0xa691, 0xa691, 0xa693, 0xa693, 0xa695, 0xa695, 0xa697, 0xa697, 0xa698, 0xa699,
|
||||
0xa69a, 0xa69b, 0xa69c, 0xa69d, 0xa69e, 0xa69f, 0xa6a0, 0xa6a1, 0xa6a2, 0xa6a3, 0xa6a4, 0xa6a5, 0xa6a6, 0xa6a7,
|
||||
0xa6a8, 0xa6a9, 0xa6aa, 0xa6ab, 0xa6ac, 0xa6ad, 0xa6ae, 0xa6af, 0xa6b0, 0xa6b1, 0xa6b2, 0xa6b3, 0xa6b4, 0xa6b5,
|
||||
0xa6b6, 0xa6b7, 0xa6b8, 0xa6b9, 0xa6ba, 0xa6bb, 0xa6bc, 0xa6bd, 0xa6be, 0xa6bf, 0xa6c0, 0xa6c1, 0xa6c2, 0xa6c3,
|
||||
0xa6c4, 0xa6c5, 0xa6c6, 0xa6c7, 0xa6c8, 0xa6c9, 0xa6ca, 0xa6cb, 0xa6cc, 0xa6cd, 0xa6ce, 0xa6cf, 0xa6d0, 0xa6d1,
|
||||
0xa6d2, 0xa6d3, 0xa6d4, 0xa6d5, 0xa6d6, 0xa6d7, 0xa6d8, 0xa6d9, 0xa6da, 0xa6db, 0xa6dc, 0xa6dd, 0xa6de, 0xa6df,
|
||||
0xa6e0, 0xa6e1, 0xa6e2, 0xa6e3, 0xa6e4, 0xa6e5, 0xa6e6, 0xa6e7, 0xa6e8, 0xa6e9, 0xa6ea, 0xa6eb, 0xa6ec, 0xa6ed,
|
||||
0xa6ee, 0xa6ef, 0xa6f0, 0xa6f1, 0xa6f2, 0xa6f3, 0xa6f4, 0xa6f5, 0xa6f6, 0xa6f7, 0xa6f8, 0xa6f9, 0xa6fa, 0xa6fb,
|
||||
0xa6fc, 0xa6fd, 0xa6fe, 0xa6ff};
|
||||
static uint16_t const smalla7[] = {
|
||||
0xa700, 0xa701, 0xa702, 0xa703, 0xa704, 0xa705, 0xa706, 0xa707, 0xa708, 0xa709, 0xa70a, 0xa70b, 0xa70c, 0xa70d,
|
||||
0xa70e, 0xa70f, 0xa710, 0xa711, 0xa712, 0xa713, 0xa714, 0xa715, 0xa716, 0xa717, 0xa718, 0xa719, 0xa71a, 0xa71b,
|
||||
0xa71c, 0xa71d, 0xa71e, 0xa71f, 0xa720, 0xa721, 0xa723, 0xa723, 0xa725, 0xa725, 0xa727, 0xa727, 0xa729, 0xa729,
|
||||
0xa72b, 0xa72b, 0xa72d, 0xa72d, 0xa72f, 0xa72f, 0xa730, 0xa731, 0xa733, 0xa733, 0xa735, 0xa735, 0xa737, 0xa737,
|
||||
0xa739, 0xa739, 0xa73b, 0xa73b, 0xa73d, 0xa73d, 0xa73f, 0xa73f, 0xa741, 0xa741, 0xa743, 0xa743, 0xa745, 0xa745,
|
||||
0xa747, 0xa747, 0xa749, 0xa749, 0xa74b, 0xa74b, 0xa74d, 0xa74d, 0xa74f, 0xa74f, 0xa751, 0xa751, 0xa753, 0xa753,
|
||||
0xa755, 0xa755, 0xa757, 0xa757, 0xa759, 0xa759, 0xa75b, 0xa75b, 0xa75d, 0xa75d, 0xa75f, 0xa75f, 0xa761, 0xa761,
|
||||
0xa763, 0xa763, 0xa765, 0xa765, 0xa767, 0xa767, 0xa769, 0xa769, 0xa76b, 0xa76b, 0xa76d, 0xa76d, 0xa76f, 0xa76f,
|
||||
0xa770, 0xa771, 0xa772, 0xa773, 0xa774, 0xa775, 0xa776, 0xa777, 0xa778, 0xa77a, 0xa77a, 0xa77c, 0xa77c, 0x1d79,
|
||||
0xa77f, 0xa77f, 0xa781, 0xa781, 0xa783, 0xa783, 0xa785, 0xa785, 0xa787, 0xa787, 0xa788, 0xa789, 0xa78a, 0xa78c,
|
||||
0xa78c, 0x265, 0xa78e, 0xa78f, 0xa791, 0xa791, 0xa792, 0xa793, 0xa794, 0xa795, 0xa796, 0xa797, 0xa798, 0xa799,
|
||||
0xa79a, 0xa79b, 0xa79c, 0xa79d, 0xa79e, 0xa79f, 0xa7a1, 0xa7a1, 0xa7a3, 0xa7a3, 0xa7a5, 0xa7a5, 0xa7a7, 0xa7a7,
|
||||
0xa7a9, 0xa7a9, 0xa7aa, 0xa7ab, 0xa7ac, 0xa7ad, 0xa7ae, 0xa7af, 0xa7b0, 0xa7b1, 0xa7b2, 0xa7b3, 0xa7b4, 0xa7b5,
|
||||
0xa7b6, 0xa7b7, 0xa7b8, 0xa7b9, 0xa7ba, 0xa7bb, 0xa7bc, 0xa7bd, 0xa7be, 0xa7bf, 0xa7c0, 0xa7c1, 0xa7c2, 0xa7c3,
|
||||
0xa7c4, 0xa7c5, 0xa7c6, 0xa7c7, 0xa7c8, 0xa7c9, 0xa7ca, 0xa7cb, 0xa7cc, 0xa7cd, 0xa7ce, 0xa7cf, 0xa7d0, 0xa7d1,
|
||||
0xa7d2, 0xa7d3, 0xa7d4, 0xa7d5, 0xa7d6, 0xa7d7, 0xa7d8, 0xa7d9, 0xa7da, 0xa7db, 0xa7dc, 0xa7dd, 0xa7de, 0xa7df,
|
||||
0xa7e0, 0xa7e1, 0xa7e2, 0xa7e3, 0xa7e4, 0xa7e5, 0xa7e6, 0xa7e7, 0xa7e8, 0xa7e9, 0xa7ea, 0xa7eb, 0xa7ec, 0xa7ed,
|
||||
0xa7ee, 0xa7ef, 0xa7f0, 0xa7f1, 0xa7f2, 0xa7f3, 0xa7f4, 0xa7f5, 0xa7f6, 0xa7f7, 0xa7f8, 0xa7f9, 0xa7fa, 0xa7fb,
|
||||
0xa7fc, 0xa7fd, 0xa7fe, 0xa7ff};
|
||||
static uint16_t const smallff[] = {
|
||||
0xff00, 0xff01, 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, 0xff0b, 0xff0c, 0xff0d,
|
||||
0xff0e, 0xff0f, 0xff10, 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0xff1a, 0xff1b,
|
||||
0xff1c, 0xff1d, 0xff1e, 0xff1f, 0xff20, 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49,
|
||||
0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57,
|
||||
0xff58, 0xff59, 0xff5a, 0xff3b, 0xff3c, 0xff3d, 0xff3e, 0xff3f, 0xff40, 0xff41, 0xff42, 0xff43, 0xff44, 0xff45,
|
||||
0xff46, 0xff47, 0xff48, 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52, 0xff53,
|
||||
0xff54, 0xff55, 0xff56, 0xff57, 0xff58, 0xff59, 0xff5a, 0xff5b, 0xff5c, 0xff5d, 0xff5e, 0xff5f, 0xff60, 0xff61,
|
||||
0xff62, 0xff63, 0xff64, 0xff65, 0xff66, 0xff67, 0xff68, 0xff69, 0xff6a, 0xff6b, 0xff6c, 0xff6d, 0xff6e, 0xff6f,
|
||||
0xff70, 0xff71, 0xff72, 0xff73, 0xff74, 0xff75, 0xff76, 0xff77, 0xff78, 0xff79, 0xff7a, 0xff7b, 0xff7c, 0xff7d,
|
||||
0xff7e, 0xff7f, 0xff80, 0xff81, 0xff82, 0xff83, 0xff84, 0xff85, 0xff86, 0xff87, 0xff88, 0xff89, 0xff8a, 0xff8b,
|
||||
0xff8c, 0xff8d, 0xff8e, 0xff8f, 0xff90, 0xff91, 0xff92, 0xff93, 0xff94, 0xff95, 0xff96, 0xff97, 0xff98, 0xff99,
|
||||
0xff9a, 0xff9b, 0xff9c, 0xff9d, 0xff9e, 0xff9f, 0xffa0, 0xffa1, 0xffa2, 0xffa3, 0xffa4, 0xffa5, 0xffa6, 0xffa7,
|
||||
0xffa8, 0xffa9, 0xffaa, 0xffab, 0xffac, 0xffad, 0xffae, 0xffaf, 0xffb0, 0xffb1, 0xffb2, 0xffb3, 0xffb4, 0xffb5,
|
||||
0xffb6, 0xffb7, 0xffb8, 0xffb9, 0xffba, 0xffbb, 0xffbc, 0xffbd, 0xffbe, 0xffbf, 0xffc0, 0xffc1, 0xffc2, 0xffc3,
|
||||
0xffc4, 0xffc5, 0xffc6, 0xffc7, 0xffc8, 0xffc9, 0xffca, 0xffcb, 0xffcc, 0xffcd, 0xffce, 0xffcf, 0xffd0, 0xffd1,
|
||||
0xffd2, 0xffd3, 0xffd4, 0xffd5, 0xffd6, 0xffd7, 0xffd8, 0xffd9, 0xffda, 0xffdb, 0xffdc, 0xffdd, 0xffde, 0xffdf,
|
||||
0xffe0, 0xffe1, 0xffe2, 0xffe3, 0xffe4, 0xffe5, 0xffe6, 0xffe7, 0xffe8, 0xffe9, 0xffea, 0xffeb, 0xffec, 0xffed,
|
||||
0xffee, 0xffef, 0xfff0, 0xfff1, 0xfff2, 0xfff3, 0xfff4, 0xfff5, 0xfff6, 0xfff7, 0xfff8, 0xfff9, 0xfffa, 0xfffb,
|
||||
0xfffc, 0xfffd, 0xfffe, 0xffff};
|
||||
|
||||
/// @return 0 if char should be replaced with 2 or more chars
|
||||
UniChar LowerUniChar(UniChar c)
|
||||
{
|
||||
switch (c & 0xffffff00)
|
||||
{
|
||||
case 0x0000: return small00[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0100: return small01[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0200: return small02[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0300: return small03[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0400: return small04[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0500: return small05[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1000: return small10[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1e00: return small1e[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1f00: return small1f[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2100: return small21[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2400: return small24[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2c00: return small2c[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xa600: return smalla6[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xa700: return smalla7[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xfb00:
|
||||
{
|
||||
if (c >= 0xfb00 && c <= 0xfb06)
|
||||
return 0;
|
||||
if (c >= 0xfb13 && c <= 0xfb17)
|
||||
return 0;
|
||||
return c;
|
||||
}
|
||||
case 0xff00: return smallff[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x10400:
|
||||
{
|
||||
if (c >= 0x10400 && c <= 0x10427)
|
||||
return c + 0x28;
|
||||
return c;
|
||||
}
|
||||
default: return c;
|
||||
case 0x0000: return small00[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0100: return small01[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0200: return small02[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0300: return small03[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0400: return small04[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x0500: return small05[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1000: return small10[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1e00: return small1e[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x1f00: return small1f[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2100: return small21[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2400: return small24[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x2c00: return small2c[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xa600: return smalla6[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xa700: return smalla7[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0xfb00:
|
||||
{
|
||||
if (c >= 0xfb00 && c <= 0xfb06)
|
||||
return 0;
|
||||
if (c >= 0xfb13 && c <= 0xfb17)
|
||||
return 0;
|
||||
return c;
|
||||
}
|
||||
case 0xff00: return smallff[static_cast<uint8_t>(c & 0x00ff)];
|
||||
case 0x10400:
|
||||
{
|
||||
if (c >= 0x10400 && c <= 0x10427)
|
||||
return c + 0x28;
|
||||
return c;
|
||||
}
|
||||
default: return c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,111 +330,439 @@ static size_t w(UniChar c, UniChar * buf)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 0xdf: *buf++ = 0x73; *buf++ = 0x73; return 2;
|
||||
case 0x130: *buf++ = 0x69; *buf++ = 0x307; return 2;
|
||||
case 0x149: *buf++ = 0x2bc; *buf++ = 0x6e; return 2;
|
||||
case 0x1f0: *buf++ = 0x6a; *buf++ = 0x30c; return 2;
|
||||
case 0x390: *buf++ = 0x3b9; *buf++ = 0x308; *buf++ = 0x301; return 3;
|
||||
case 0x3B0: *buf++ = 0x3c5; *buf++ = 0x308; *buf++ = 0x301; return 3;
|
||||
case 0x587: *buf++ = 0x565; *buf++ = 0x582; return 2;
|
||||
case 0x1e96: *buf++ = 0x68; *buf++ = 0x331; return 2;
|
||||
case 0x1e97: *buf++ = 0x74; *buf++ = 0x308; return 2;
|
||||
case 0x1e98: *buf++ = 0x77; *buf++ = 0x30a; return 2;
|
||||
case 0x1e99: *buf++ = 0x79; *buf++ = 0x30a; return 2;
|
||||
case 0x1e9a: *buf++ = 0x61; *buf++ = 0x2be; return 2;
|
||||
case 0x1e9e: *buf++ = 0x73; *buf++ = 0x73; return 2;
|
||||
case 0x1f50: *buf++ = 0x3c5; *buf++ = 0x313; return 2;
|
||||
case 0x1f52: *buf++ = 0x3c5; *buf++ = 0x313; *buf++ = 0x300; return 3;
|
||||
case 0x1f54: *buf++ = 0x3c5; *buf++ = 0x313; *buf++ = 0x301; return 3;
|
||||
case 0x1f56: *buf++ = 0x3c5; *buf++ = 0x313; *buf++ = 0x342; return 3;
|
||||
case 0x1f80: *buf++ = 0x1f00; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f81: *buf++ = 0x1f01; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f82: *buf++ = 0x1f02; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f83: *buf++ = 0x1f03; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f84: *buf++ = 0x1f04; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f85: *buf++ = 0x1f05; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f86: *buf++ = 0x1f06; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f87: *buf++ = 0x1f07; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f88: *buf++ = 0x1f00; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f89: *buf++ = 0x1f01; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8a: *buf++ = 0x1f02; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8b: *buf++ = 0x1f03; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8c: *buf++ = 0x1f04; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8d: *buf++ = 0x1f05; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8e: *buf++ = 0x1f06; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f8f: *buf++ = 0x1f07; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f90: *buf++ = 0x1f20; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f91: *buf++ = 0x1f21; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f92: *buf++ = 0x1f22; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f93: *buf++ = 0x1f23; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f94: *buf++ = 0x1f24; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f95: *buf++ = 0x1f25; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f96: *buf++ = 0x1f26; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f97: *buf++ = 0x1f27; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f98: *buf++ = 0x1f20; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f99: *buf++ = 0x1f21; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9a: *buf++ = 0x1f22; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9b: *buf++ = 0x1f23; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9c: *buf++ = 0x1f24; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9d: *buf++ = 0x1f25; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9e: *buf++ = 0x1f26; *buf++ = 0x3b9; return 2;
|
||||
case 0x1f9f: *buf++ = 0x1f27; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa0: *buf++ = 0x1f60; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa1: *buf++ = 0x1f61; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa2: *buf++ = 0x1f62; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa3: *buf++ = 0x1f63; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa4: *buf++ = 0x1f64; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa5: *buf++ = 0x1f65; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa6: *buf++ = 0x1f66; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa7: *buf++ = 0x1f67; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa8: *buf++ = 0x1f60; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fa9: *buf++ = 0x1f61; *buf++ = 0x3b9; return 2;
|
||||
case 0x1faa: *buf++ = 0x1f62; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fab: *buf++ = 0x1f63; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fac: *buf++ = 0x1f64; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fad: *buf++ = 0x1f65; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fae: *buf++ = 0x1f66; *buf++ = 0x3b9; return 2;
|
||||
case 0x1faf: *buf++ = 0x1f67; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fb2: *buf++ = 0x1f70; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fb3: *buf++ = 0x3b1; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fb4: *buf++ = 0x3ac; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fb6: *buf++ = 0x3b1; *buf++ = 0x342; return 2;
|
||||
case 0x1fb7: *buf++ = 0x3b1; *buf++ = 0x342; *buf++ = 0x3b9; return 3;
|
||||
case 0x1fbc: *buf++ = 0x3b1; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fc2: *buf++ = 0x1f74; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fc3: *buf++ = 0x3b7; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fc4: *buf++ = 0x3ae; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fc6: *buf++ = 0x3b7; *buf++ = 0x342; return 2;
|
||||
case 0x1fc7: *buf++ = 0x3b7; *buf++ = 0x342; *buf++ = 0x3b9; return 3;
|
||||
case 0x1fcc: *buf++ = 0x3b7; *buf++ = 0x3b9; return 2;
|
||||
case 0x1fd2: *buf++ = 0x3b9; *buf++ = 0x308; *buf++ = 0x300; return 3;
|
||||
case 0x1fd3: *buf++ = 0x3b9; *buf++ = 0x308; *buf++ = 0x301; return 3;
|
||||
case 0x1fd6: *buf++ = 0x3b9; *buf++ = 0x342; return 2;
|
||||
case 0x1fd7: *buf++ = 0x3b9; *buf++ = 0x308; *buf++ = 0x342; return 3;
|
||||
case 0x1fe2: *buf++ = 0x3c5; *buf++ = 0x308; *buf++ = 0x300; return 3;
|
||||
case 0x1fe3: *buf++ = 0x3c5; *buf++ = 0x308; *buf++ = 0x301; return 3;
|
||||
case 0x1fe4: *buf++ = 0x3c1; *buf++ = 0x313; return 2;
|
||||
case 0x1fe6: *buf++ = 0x3c5; *buf++ = 0x342; return 2;
|
||||
case 0x1fe7: *buf++ = 0x3c5; *buf++ = 0x308; *buf++ = 0x342; return 3;
|
||||
case 0x1ff2: *buf++ = 0x1f7c; *buf++ = 0x3b9; return 2;
|
||||
case 0x1ff3: *buf++ = 0x3c9; *buf++ = 0x3b9; return 2;
|
||||
case 0x1ff4: *buf++ = 0x3ce; *buf++ = 0x3b9; return 2;
|
||||
case 0x1ff6: *buf++ = 0x3c9; *buf++ = 0x342; return 2;
|
||||
case 0x1ff7: *buf++ = 0x3c9; *buf++ = 0x342; *buf++ = 0x3b9; return 3;
|
||||
case 0x1ffc: *buf++ = 0x3c9; *buf++ = 0x3b9; return 2;
|
||||
case 0xfb00: *buf++ = 0x66; *buf++ = 0x66; return 2;
|
||||
case 0xfb01: *buf++ = 0x66; *buf++ = 0x69; return 2;
|
||||
case 0xfb02: *buf++ = 0x66; *buf++ = 0x6c; return 2;
|
||||
case 0xfb03: *buf++ = 0x66; *buf++ = 0x66; *buf++ = 0x69; return 3;
|
||||
case 0xfb04: *buf++ = 0x66; *buf++ = 0x66; *buf++ = 0x6c; return 3;
|
||||
case 0xfb05: *buf++ = 0x73; *buf++ = 0x74; return 2;
|
||||
case 0xfb06: *buf++ = 0x73; *buf++ = 0x74; return 2;
|
||||
case 0xfb13: *buf++ = 0x574; *buf++ = 0x576; return 2;
|
||||
case 0xfb14: *buf++ = 0x574; *buf++ = 0x565; return 2;
|
||||
case 0xfb15: *buf++ = 0x574; *buf++ = 0x56b; return 2;
|
||||
case 0xfb16: *buf++ = 0x57e; *buf++ = 0x576; return 2;
|
||||
case 0xfb17: *buf++ = 0x574; *buf++ = 0x56d; return 2;
|
||||
default: ASSERT(false, ("Invalid UniChar", c));
|
||||
case 0xdf:
|
||||
*buf++ = 0x73;
|
||||
*buf++ = 0x73;
|
||||
return 2;
|
||||
case 0x130:
|
||||
*buf++ = 0x69;
|
||||
*buf++ = 0x307;
|
||||
return 2;
|
||||
case 0x149:
|
||||
*buf++ = 0x2bc;
|
||||
*buf++ = 0x6e;
|
||||
return 2;
|
||||
case 0x1f0:
|
||||
*buf++ = 0x6a;
|
||||
*buf++ = 0x30c;
|
||||
return 2;
|
||||
case 0x390:
|
||||
*buf++ = 0x3b9;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x301;
|
||||
return 3;
|
||||
case 0x3B0:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x301;
|
||||
return 3;
|
||||
case 0x587:
|
||||
*buf++ = 0x565;
|
||||
*buf++ = 0x582;
|
||||
return 2;
|
||||
case 0x1e96:
|
||||
*buf++ = 0x68;
|
||||
*buf++ = 0x331;
|
||||
return 2;
|
||||
case 0x1e97:
|
||||
*buf++ = 0x74;
|
||||
*buf++ = 0x308;
|
||||
return 2;
|
||||
case 0x1e98:
|
||||
*buf++ = 0x77;
|
||||
*buf++ = 0x30a;
|
||||
return 2;
|
||||
case 0x1e99:
|
||||
*buf++ = 0x79;
|
||||
*buf++ = 0x30a;
|
||||
return 2;
|
||||
case 0x1e9a:
|
||||
*buf++ = 0x61;
|
||||
*buf++ = 0x2be;
|
||||
return 2;
|
||||
case 0x1e9e:
|
||||
*buf++ = 0x73;
|
||||
*buf++ = 0x73;
|
||||
return 2;
|
||||
case 0x1f50:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x313;
|
||||
return 2;
|
||||
case 0x1f52:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x313;
|
||||
*buf++ = 0x300;
|
||||
return 3;
|
||||
case 0x1f54:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x313;
|
||||
*buf++ = 0x301;
|
||||
return 3;
|
||||
case 0x1f56:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x313;
|
||||
*buf++ = 0x342;
|
||||
return 3;
|
||||
case 0x1f80:
|
||||
*buf++ = 0x1f00;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f81:
|
||||
*buf++ = 0x1f01;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f82:
|
||||
*buf++ = 0x1f02;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f83:
|
||||
*buf++ = 0x1f03;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f84:
|
||||
*buf++ = 0x1f04;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f85:
|
||||
*buf++ = 0x1f05;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f86:
|
||||
*buf++ = 0x1f06;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f87:
|
||||
*buf++ = 0x1f07;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f88:
|
||||
*buf++ = 0x1f00;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f89:
|
||||
*buf++ = 0x1f01;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8a:
|
||||
*buf++ = 0x1f02;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8b:
|
||||
*buf++ = 0x1f03;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8c:
|
||||
*buf++ = 0x1f04;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8d:
|
||||
*buf++ = 0x1f05;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8e:
|
||||
*buf++ = 0x1f06;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f8f:
|
||||
*buf++ = 0x1f07;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f90:
|
||||
*buf++ = 0x1f20;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f91:
|
||||
*buf++ = 0x1f21;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f92:
|
||||
*buf++ = 0x1f22;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f93:
|
||||
*buf++ = 0x1f23;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f94:
|
||||
*buf++ = 0x1f24;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f95:
|
||||
*buf++ = 0x1f25;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f96:
|
||||
*buf++ = 0x1f26;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f97:
|
||||
*buf++ = 0x1f27;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f98:
|
||||
*buf++ = 0x1f20;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f99:
|
||||
*buf++ = 0x1f21;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9a:
|
||||
*buf++ = 0x1f22;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9b:
|
||||
*buf++ = 0x1f23;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9c:
|
||||
*buf++ = 0x1f24;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9d:
|
||||
*buf++ = 0x1f25;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9e:
|
||||
*buf++ = 0x1f26;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1f9f:
|
||||
*buf++ = 0x1f27;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa0:
|
||||
*buf++ = 0x1f60;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa1:
|
||||
*buf++ = 0x1f61;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa2:
|
||||
*buf++ = 0x1f62;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa3:
|
||||
*buf++ = 0x1f63;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa4:
|
||||
*buf++ = 0x1f64;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa5:
|
||||
*buf++ = 0x1f65;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa6:
|
||||
*buf++ = 0x1f66;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa7:
|
||||
*buf++ = 0x1f67;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa8:
|
||||
*buf++ = 0x1f60;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fa9:
|
||||
*buf++ = 0x1f61;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1faa:
|
||||
*buf++ = 0x1f62;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fab:
|
||||
*buf++ = 0x1f63;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fac:
|
||||
*buf++ = 0x1f64;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fad:
|
||||
*buf++ = 0x1f65;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fae:
|
||||
*buf++ = 0x1f66;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1faf:
|
||||
*buf++ = 0x1f67;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fb2:
|
||||
*buf++ = 0x1f70;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fb3:
|
||||
*buf++ = 0x3b1;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fb4:
|
||||
*buf++ = 0x3ac;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fb6:
|
||||
*buf++ = 0x3b1;
|
||||
*buf++ = 0x342;
|
||||
return 2;
|
||||
case 0x1fb7:
|
||||
*buf++ = 0x3b1;
|
||||
*buf++ = 0x342;
|
||||
*buf++ = 0x3b9;
|
||||
return 3;
|
||||
case 0x1fbc:
|
||||
*buf++ = 0x3b1;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fc2:
|
||||
*buf++ = 0x1f74;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fc3:
|
||||
*buf++ = 0x3b7;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fc4:
|
||||
*buf++ = 0x3ae;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fc6:
|
||||
*buf++ = 0x3b7;
|
||||
*buf++ = 0x342;
|
||||
return 2;
|
||||
case 0x1fc7:
|
||||
*buf++ = 0x3b7;
|
||||
*buf++ = 0x342;
|
||||
*buf++ = 0x3b9;
|
||||
return 3;
|
||||
case 0x1fcc:
|
||||
*buf++ = 0x3b7;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1fd2:
|
||||
*buf++ = 0x3b9;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x300;
|
||||
return 3;
|
||||
case 0x1fd3:
|
||||
*buf++ = 0x3b9;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x301;
|
||||
return 3;
|
||||
case 0x1fd6:
|
||||
*buf++ = 0x3b9;
|
||||
*buf++ = 0x342;
|
||||
return 2;
|
||||
case 0x1fd7:
|
||||
*buf++ = 0x3b9;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x342;
|
||||
return 3;
|
||||
case 0x1fe2:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x300;
|
||||
return 3;
|
||||
case 0x1fe3:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x301;
|
||||
return 3;
|
||||
case 0x1fe4:
|
||||
*buf++ = 0x3c1;
|
||||
*buf++ = 0x313;
|
||||
return 2;
|
||||
case 0x1fe6:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x342;
|
||||
return 2;
|
||||
case 0x1fe7:
|
||||
*buf++ = 0x3c5;
|
||||
*buf++ = 0x308;
|
||||
*buf++ = 0x342;
|
||||
return 3;
|
||||
case 0x1ff2:
|
||||
*buf++ = 0x1f7c;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1ff3:
|
||||
*buf++ = 0x3c9;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1ff4:
|
||||
*buf++ = 0x3ce;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0x1ff6:
|
||||
*buf++ = 0x3c9;
|
||||
*buf++ = 0x342;
|
||||
return 2;
|
||||
case 0x1ff7:
|
||||
*buf++ = 0x3c9;
|
||||
*buf++ = 0x342;
|
||||
*buf++ = 0x3b9;
|
||||
return 3;
|
||||
case 0x1ffc:
|
||||
*buf++ = 0x3c9;
|
||||
*buf++ = 0x3b9;
|
||||
return 2;
|
||||
case 0xfb00:
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x66;
|
||||
return 2;
|
||||
case 0xfb01:
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x69;
|
||||
return 2;
|
||||
case 0xfb02:
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x6c;
|
||||
return 2;
|
||||
case 0xfb03:
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x69;
|
||||
return 3;
|
||||
case 0xfb04:
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x66;
|
||||
*buf++ = 0x6c;
|
||||
return 3;
|
||||
case 0xfb05:
|
||||
*buf++ = 0x73;
|
||||
*buf++ = 0x74;
|
||||
return 2;
|
||||
case 0xfb06:
|
||||
*buf++ = 0x73;
|
||||
*buf++ = 0x74;
|
||||
return 2;
|
||||
case 0xfb13:
|
||||
*buf++ = 0x574;
|
||||
*buf++ = 0x576;
|
||||
return 2;
|
||||
case 0xfb14:
|
||||
*buf++ = 0x574;
|
||||
*buf++ = 0x565;
|
||||
return 2;
|
||||
case 0xfb15:
|
||||
*buf++ = 0x574;
|
||||
*buf++ = 0x56b;
|
||||
return 2;
|
||||
case 0xfb16:
|
||||
*buf++ = 0x57e;
|
||||
*buf++ = 0x576;
|
||||
return 2;
|
||||
case 0xfb17:
|
||||
*buf++ = 0x574;
|
||||
*buf++ = 0x56d;
|
||||
return 2;
|
||||
default: ASSERT(false, ("Invalid UniChar", c));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -207,7 +800,7 @@ size_t CountNormLowerSymbols(UniString const & s, UniString const & lowStr)
|
||||
while (lowIdx < lowSize)
|
||||
{
|
||||
if (sIdx == size)
|
||||
return 0; // low_s has more length than s
|
||||
return 0; // low_s has more length than s
|
||||
|
||||
UniString strCharNorm;
|
||||
strCharNorm.push_back(s[sIdx++]);
|
||||
@@ -215,16 +808,13 @@ size_t CountNormLowerSymbols(UniString const & s, UniString const & lowStr)
|
||||
NormalizeInplace(strCharNorm);
|
||||
|
||||
for (size_t i = 0; i < strCharNorm.size(); ++i)
|
||||
{
|
||||
if (lowIdx >= lowSize)
|
||||
return sIdx;
|
||||
else
|
||||
if (lowStr[lowIdx++] != strCharNorm[i])
|
||||
return 0;
|
||||
}
|
||||
else if (lowStr[lowIdx++] != strCharNorm[i])
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sIdx;
|
||||
}
|
||||
|
||||
} // namespace strings
|
||||
} // namespace strings
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
template <typename Key, typename Value>
|
||||
class LruCache
|
||||
{
|
||||
template <typename K, typename V> friend class LruCacheTest;
|
||||
template <typename K, typename V> friend class LruCacheKeyAgeTest;
|
||||
template <typename K, typename V>
|
||||
friend class LruCacheTest;
|
||||
template <typename K, typename V>
|
||||
friend class LruCacheKeyAgeTest;
|
||||
|
||||
public:
|
||||
/// \param maxCacheSize Maximum size of the cache in number of items. It should be one or greater.
|
||||
/// \param loader Function which is called if it's necessary to load a new item for the cache.
|
||||
/// For the same |key| should be loaded the same |value|.
|
||||
explicit LruCache(size_t maxCacheSize) : m_maxCacheSize(maxCacheSize)
|
||||
{
|
||||
CHECK_GREATER(maxCacheSize, 0, ());
|
||||
}
|
||||
explicit LruCache(size_t maxCacheSize) : m_maxCacheSize(maxCacheSize) { CHECK_GREATER(maxCacheSize, 0, ()); }
|
||||
|
||||
// Find value by @key. If @key is found, returns reference to its value.
|
||||
Value & Find(Key const & key, bool & found)
|
||||
@@ -59,10 +59,8 @@ public:
|
||||
return false;
|
||||
|
||||
for (auto const & kv : m_cache)
|
||||
{
|
||||
if (!m_keyAge.IsKeyValidForTesting(kv.first))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -77,7 +75,8 @@ private:
|
||||
/// \note Ages should be unique for all keys.
|
||||
class KeyAge
|
||||
{
|
||||
template <typename K, typename V> friend class LruCacheKeyAgeTest;
|
||||
template <typename K, typename V>
|
||||
friend class LruCacheKeyAgeTest;
|
||||
|
||||
public:
|
||||
void Clear()
|
||||
|
||||
@@ -7,32 +7,32 @@ namespace base
|
||||
namespace impl
|
||||
{
|
||||
// http://rsdn.ru/Forum/?mid=1025325
|
||||
template <typename T, unsigned int N> char(&ArraySize(T(&)[N]))[N];
|
||||
template <typename T, unsigned int N>
|
||||
char (&ArraySize(T (&)[N]))[N];
|
||||
} // namespace impl
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
// Number of elements in array. Compilation error if the type passed is not an array.
|
||||
#define ARRAY_SIZE(X) sizeof(::base::impl::ArraySize(X))
|
||||
|
||||
#define DISALLOW_COPY(className) \
|
||||
className(className const &) = delete; \
|
||||
#define DISALLOW_COPY(className) \
|
||||
className(className const &) = delete; \
|
||||
className & operator=(className const &) = delete
|
||||
|
||||
|
||||
#define DISALLOW_MOVE(className) \
|
||||
className(className &&) = delete; \
|
||||
#define DISALLOW_MOVE(className) \
|
||||
className(className &&) = delete; \
|
||||
className & operator=(className &&) = delete
|
||||
|
||||
#define DISALLOW_COPY_AND_MOVE(className) \
|
||||
DISALLOW_COPY(className); \
|
||||
#define DISALLOW_COPY_AND_MOVE(className) \
|
||||
DISALLOW_COPY(className); \
|
||||
DISALLOW_MOVE(className)
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
#define TO_STRING_IMPL(x) #x
|
||||
#define TO_STRING(x) TO_STRING_IMPL(x)
|
||||
#define TO_STRING(x) TO_STRING_IMPL(x)
|
||||
|
||||
#define UNUSED_VALUE(x) static_cast<void>(x)
|
||||
#define UNUSED_VALUE(x) static_cast<void>(x)
|
||||
|
||||
namespace base
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace impl
|
||||
template <typename T>
|
||||
void ForceUseValue(T const & t)
|
||||
{
|
||||
volatile T dummy = t;
|
||||
T volatile dummy = t;
|
||||
UNUSED_VALUE(dummy);
|
||||
}
|
||||
} // namespace impl
|
||||
@@ -53,28 +53,27 @@ void ForceUseValue(T const & t)
|
||||
#ifdef __GNUC__
|
||||
// https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
|
||||
#define PREDICT(x, prediction) __builtin_expect(static_cast<long>(x), static_cast<long>(prediction))
|
||||
#define PREDICT_TRUE(x) __builtin_expect(x, 1)
|
||||
#define PREDICT_FALSE(x) __builtin_expect(x, 0)
|
||||
#define PREDICT_TRUE(x) __builtin_expect(x, 1)
|
||||
#define PREDICT_FALSE(x) __builtin_expect(x, 0)
|
||||
#else
|
||||
#define PREDICT(x, prediction) (x)
|
||||
#define PREDICT_TRUE(x) (x)
|
||||
#define PREDICT_FALSE(x) (x)
|
||||
#define PREDICT_TRUE(x) (x)
|
||||
#define PREDICT_FALSE(x) (x)
|
||||
#endif
|
||||
|
||||
#define UINT16_FROM_UINT8(hi, lo) ((static_cast<uint16_t>(hi) << 8) | lo)
|
||||
#define UINT32_FROM_UINT16(hi, lo) ((static_cast<uint32_t>(hi) << 16) | lo)
|
||||
#define UINT64_FROM_UINT32(hi, lo) ((static_cast<uint64_t>(hi) << 32) | lo)
|
||||
#define UINT16_FROM_UINT8(hi, lo) ((static_cast<uint16_t>(hi) << 8) | lo)
|
||||
#define UINT32_FROM_UINT16(hi, lo) ((static_cast<uint32_t>(hi) << 16) | lo)
|
||||
#define UINT64_FROM_UINT32(hi, lo) ((static_cast<uint64_t>(hi) << 32) | lo)
|
||||
|
||||
#define UINT32_FROM_UINT8(u3, u2, u1, u0) \
|
||||
UINT32_FROM_UINT16(UINT16_FROM_UINT8(u3, u2), UINT16_FROM_UINT8(u1, u0))
|
||||
#define UINT64_FROM_UINT8(u7, u6, u5, u4, u3, u2, u1, u0) \
|
||||
#define UINT32_FROM_UINT8(u3, u2, u1, u0) UINT32_FROM_UINT16(UINT16_FROM_UINT8(u3, u2), UINT16_FROM_UINT8(u1, u0))
|
||||
#define UINT64_FROM_UINT8(u7, u6, u5, u4, u3, u2, u1, u0) \
|
||||
UINT64_FROM_UINT32(UINT32_FROM_UINT8(u7, u6, u5, u4), UINT32_FROM_UINT8(u3, u2, u1, u0))
|
||||
|
||||
#define UINT16_LO(x) (static_cast<uint8_t>(x & 0xFF))
|
||||
#define UINT16_HI(x) (static_cast<uint8_t>(x >> 8))
|
||||
#define UINT32_LO(x) (static_cast<uint16_t>(x & 0xFFFF))
|
||||
#define UINT32_HI(x) (static_cast<uint16_t>(x >> 16))
|
||||
#define UINT64_LO(x) (static_cast<uint32_t>(x & 0xFFFFFFFF))
|
||||
#define UINT64_HI(x) (static_cast<uint32_t>(x >> 32))
|
||||
#define UINT16_LO(x) (static_cast<uint8_t>(x & 0xFF))
|
||||
#define UINT16_HI(x) (static_cast<uint8_t>(x >> 8))
|
||||
#define UINT32_LO(x) (static_cast<uint16_t>(x & 0xFFFF))
|
||||
#define UINT32_HI(x) (static_cast<uint16_t>(x >> 16))
|
||||
#define UINT64_LO(x) (static_cast<uint32_t>(x & 0xFFFFFFFF))
|
||||
#define UINT64_HI(x) (static_cast<uint32_t>(x >> 32))
|
||||
|
||||
#define NOTIMPLEMENTED() ASSERT(false, ("Function", __func__, "is not implemented!"))
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <algorithm> // std::max
|
||||
#include <algorithm> // std::max
|
||||
#include <cmath>
|
||||
#include <functional> // std::hash
|
||||
#include <functional> // std::hash
|
||||
#include <type_traits>
|
||||
|
||||
namespace math
|
||||
@@ -25,9 +25,8 @@ T Abs(T x)
|
||||
return (x < 0 ? -x : x);
|
||||
}
|
||||
|
||||
template <typename Number,
|
||||
typename EnableIf = typename std::enable_if_t<
|
||||
std::is_integral_v<Number> || std::is_floating_point_v<Number>, void>>
|
||||
template <typename Number, typename EnableIf = typename std::enable_if_t<
|
||||
std::is_integral_v<Number> || std::is_floating_point_v<Number>, void>>
|
||||
int constexpr Sign(Number const number) noexcept
|
||||
{
|
||||
return number == 0 ? 0 : number > 0 ? 1 : -1;
|
||||
@@ -110,10 +109,8 @@ T PowUint(T x, uint64_t n)
|
||||
{
|
||||
T res = 1;
|
||||
for (T t = x; n > 0; n >>= 1, t *= t)
|
||||
{
|
||||
if (n & 1)
|
||||
res *= t;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -150,16 +147,14 @@ inline uint32_t NextPowOf2(uint32_t v)
|
||||
}
|
||||
|
||||
// Greatest Common Divisor.
|
||||
template <typename Number,
|
||||
typename EnableIf = typename std::enable_if_t<std::is_integral_v<Number>, void>>
|
||||
template <typename Number, typename EnableIf = typename std::enable_if_t<std::is_integral_v<Number>, void>>
|
||||
Number constexpr GCD(Number const a, Number const b)
|
||||
{
|
||||
return b == 0 ? a : GCD(b, a % b);
|
||||
}
|
||||
|
||||
// Least Common Multiple.
|
||||
template <typename Number,
|
||||
typename EnableIf = typename std::enable_if_t<std::is_integral_v<Number>, void>>
|
||||
template <typename Number, typename EnableIf = typename std::enable_if_t<std::is_integral_v<Number>, void>>
|
||||
Number constexpr LCM(Number const a, Number const b)
|
||||
{
|
||||
return a / GCD(a, b) * b;
|
||||
|
||||
@@ -7,207 +7,197 @@
|
||||
|
||||
namespace math
|
||||
{
|
||||
template <typename T, unsigned Rows, unsigned Cols>
|
||||
struct Matrix
|
||||
template <typename T, unsigned Rows, unsigned Cols>
|
||||
struct Matrix
|
||||
{
|
||||
T m_data[Rows * Cols];
|
||||
|
||||
Matrix() {}
|
||||
|
||||
template <typename U>
|
||||
Matrix(Matrix<U, Rows, Cols> const & src)
|
||||
{
|
||||
T m_data[Rows * Cols];
|
||||
for (size_t i = 0; i < Rows * Cols; ++i)
|
||||
m_data[i] = src.m_data[i];
|
||||
}
|
||||
|
||||
Matrix() {}
|
||||
Matrix(T * data) { copy(data, data + Rows * Cols, m_data); }
|
||||
|
||||
template <typename U>
|
||||
Matrix(Matrix<U, Rows, Cols> const & src)
|
||||
{
|
||||
Matrix(std::initializer_list<T> const & initList)
|
||||
{
|
||||
ASSERT(initList.size() == Rows * Cols, ());
|
||||
std::copy(initList.begin(), initList.end(), m_data);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
Matrix & operator=(Matrix<U, Rows, Cols> const & src)
|
||||
{
|
||||
if ((void *)this != (void *)&src)
|
||||
for (size_t i = 0; i < Rows * Cols; ++i)
|
||||
m_data[i] = src.m_data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Matrix(T * data)
|
||||
{
|
||||
copy(data, data + Rows * Cols, m_data);
|
||||
}
|
||||
T const & operator()(size_t row, size_t col) const { return m_data[row * Cols + col]; }
|
||||
|
||||
Matrix(std::initializer_list<T> const & initList)
|
||||
{
|
||||
ASSERT(initList.size() == Rows * Cols, ());
|
||||
std::copy(initList.begin(), initList.end(), m_data);
|
||||
}
|
||||
T & operator()(size_t row, size_t col) { return m_data[row * Cols + col]; }
|
||||
|
||||
template <typename U>
|
||||
Matrix & operator=(Matrix<U, Rows, Cols> const & src)
|
||||
{
|
||||
if ((void*)this != (void*)&src)
|
||||
template <typename U>
|
||||
bool operator==(Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
if (m_data[i * Cols + j] != m(i, j))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool Equal(Matrix<U, Rows, Cols> const & m, T eps = 0.0001) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
if (Abs(m_data[i * Cols + j] - m(i, j)) > eps)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator!=(Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
return !(*this == m);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator<(Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
{
|
||||
for (size_t i = 0; i < Rows * Cols; ++i)
|
||||
m_data[i] = src.m_data[i];
|
||||
if (m_data[i * Cols + j] > m(i, j))
|
||||
return false;
|
||||
if (m_data[i * Cols + j] < m(i, j))
|
||||
return true;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T const & operator()(size_t row, size_t col) const
|
||||
{
|
||||
return m_data[row * Cols + col];
|
||||
}
|
||||
/// All elements are equal
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
T & operator()(size_t row, size_t col)
|
||||
{
|
||||
return m_data[row * Cols + col];
|
||||
}
|
||||
template <typename T>
|
||||
T Determinant(Matrix<T, 1, 1> const & m)
|
||||
{
|
||||
return m(0, 0);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator == (Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
if (m_data[i * Cols + j] != m(i, j))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
template <typename T, unsigned M>
|
||||
T Determinant(Matrix<T, M, M> const & m)
|
||||
{
|
||||
T sign = 1;
|
||||
T res = 0;
|
||||
for (size_t i = 0; i < M; ++i, sign *= -1)
|
||||
res += sign * m(0, i) * Determinant(Splice(m, 0, i));
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool Equal(Matrix<U, Rows, Cols> const & m, T eps = 0.0001) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
if (Abs(m_data[i * Cols + j] - m(i, j)) > eps)
|
||||
return false;
|
||||
template <typename T, unsigned Rows, unsigned Cols>
|
||||
Matrix<T, Rows - 1, Cols - 1> const Splice(Matrix<T, Rows, Cols> const & m, size_t Row, size_t Col)
|
||||
{
|
||||
Matrix<T, Rows - 1, Cols - 1> res;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator != (Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
return !(*this == m);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator<(Matrix<U, Rows, Cols> const & m) const
|
||||
{
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
for (size_t j = 0; j < Cols; ++j)
|
||||
{
|
||||
if (m_data[i * Cols + j] > m(i, j))
|
||||
return false;
|
||||
if (m_data[i * Cols + j] < m(i, j))
|
||||
return true;
|
||||
}
|
||||
|
||||
/// All elements are equal
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T Determinant(Matrix<T, 1, 1> const & m)
|
||||
for (size_t i = 0; i < Row; ++i)
|
||||
{
|
||||
return m(0, 0);
|
||||
for (size_t j = 0; j < Col; ++j)
|
||||
res(i, j) = m(i, j);
|
||||
for (size_t j = Col + 1; j < Cols; ++j)
|
||||
res(i, j - 1) = m(i, j);
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
T Determinant(Matrix<T, M, M> const & m)
|
||||
for (size_t i = Row + 1; i < Rows; ++i)
|
||||
{
|
||||
T sign = 1;
|
||||
T res = 0;
|
||||
for (size_t i = 0; i < M; ++i, sign *= -1)
|
||||
res += sign * m(0, i) * Determinant(Splice(m, 0, i));
|
||||
return res;
|
||||
for (size_t j = 0; j < Col; ++j)
|
||||
res(i - 1, j) = m(i, j);
|
||||
for (size_t j = Col + 1; j < Cols; ++j)
|
||||
res(i - 1, j - 1) = m(i, j);
|
||||
}
|
||||
|
||||
template <typename T, unsigned Rows, unsigned Cols>
|
||||
Matrix<T, Rows - 1, Cols - 1> const Splice(Matrix<T, Rows, Cols> const & m, size_t Row, size_t Col)
|
||||
{
|
||||
Matrix<T, Rows - 1, Cols - 1> res;
|
||||
return res;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < Row; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < Col; ++j)
|
||||
res(i, j) = m(i, j);
|
||||
for (size_t j = Col + 1; j < Cols; ++j)
|
||||
res(i, j - 1) = m(i, j);
|
||||
}
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Inverse(Matrix<T, M, M> const & m)
|
||||
{
|
||||
T det = Determinant(m);
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = Row + 1; i < Rows; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < Col; ++j)
|
||||
res(i - 1, j) = m(i, j);
|
||||
for (size_t j = Col + 1; j < Cols; ++j)
|
||||
res(i - 1, j - 1) = m(i, j);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Inverse(Matrix<T, M, M> const & m)
|
||||
{
|
||||
T det = Determinant(m);
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
{
|
||||
T sign = 1.0 - 2.0 * ((i + j) % 2);
|
||||
res(j, i) = sign * Determinant(Splice(m, i, j)) / det;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Identity()
|
||||
{
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
res(i, j) = 0;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
res(i, i) = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Zero()
|
||||
{
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
res(i, j) = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M, unsigned N, unsigned K>
|
||||
Matrix<T, M, K> operator*(Matrix<T, M, N> const & l, Matrix<T, N, K> const & r)
|
||||
{
|
||||
Matrix<T, M, K> res;
|
||||
for (size_t m = 0; m < M; ++m)
|
||||
for (size_t k = 0; k < K; ++k)
|
||||
{
|
||||
T sum = 0;
|
||||
for (size_t n = 0; n < N; ++n)
|
||||
sum += l(m, n) * r(n, k);
|
||||
res(m, k) = sum;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M, unsigned N> std::string DebugPrint(Matrix<T, M, N> const & m)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << ":" << std::endl;
|
||||
|
||||
for (unsigned i = 0; i < M; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
ss << std::setfill(' ') << std::setw(10) << m(i, j) << " ";
|
||||
ss << std::endl;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Identity()
|
||||
{
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
res(i, j) = 0;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
res(i, i) = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M>
|
||||
Matrix<T, M, M> const Zero()
|
||||
{
|
||||
Matrix<T, M, M> res;
|
||||
|
||||
for (size_t i = 0; i < M; ++i)
|
||||
for (size_t j = 0; j < M; ++j)
|
||||
res(i, j) = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M, unsigned N, unsigned K>
|
||||
Matrix<T, M, K> operator*(Matrix<T, M, N> const & l, Matrix<T, N, K> const & r)
|
||||
{
|
||||
Matrix<T, M, K> res;
|
||||
for (size_t m = 0; m < M; ++m)
|
||||
for (size_t k = 0; k < K; ++k)
|
||||
{
|
||||
T sum = 0;
|
||||
for (size_t n = 0; n < N; ++n)
|
||||
sum += l(m, n) * r(n, k);
|
||||
res(m, k) = sum;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T, unsigned M, unsigned N>
|
||||
std::string DebugPrint(Matrix<T, M, N> const & m)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << ":" << std::endl;
|
||||
|
||||
for (unsigned i = 0; i < M; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
ss << std::setfill(' ') << std::setw(10) << m(i, j) << " ";
|
||||
ss << std::endl;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace math
|
||||
|
||||
@@ -126,14 +126,12 @@ private:
|
||||
|
||||
typename Entries::iterator Find(Char const & c)
|
||||
{
|
||||
return std::find_if(m_subtrees.begin(), m_subtrees.end(),
|
||||
[&c](Entry const & entry) { return entry.first == c; });
|
||||
return std::find_if(m_subtrees.begin(), m_subtrees.end(), [&c](Entry const & entry) { return entry.first == c; });
|
||||
}
|
||||
|
||||
typename Entries::const_iterator Find(Char const & c) const
|
||||
{
|
||||
return std::find_if(m_subtrees.cbegin(), m_subtrees.cend(),
|
||||
[&c](Entry const & entry) { return entry.first == c; });
|
||||
return std::find_if(m_subtrees.cbegin(), m_subtrees.cend(), [&c](Entry const & entry) { return entry.first == c; });
|
||||
}
|
||||
|
||||
Entries m_subtrees;
|
||||
@@ -278,10 +276,7 @@ public:
|
||||
curr->AddValue(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void Erase(String const & key, Value const & value)
|
||||
{
|
||||
Erase(m_root, key.begin(), key.end(), value);
|
||||
}
|
||||
void Erase(String const & key, Value const & value) { Erase(m_root, key.begin(), key.end(), value); }
|
||||
|
||||
// Traverses all key-value pairs in the trie and calls |toDo| on each of them.
|
||||
template <typename ToDo>
|
||||
@@ -298,16 +293,14 @@ public:
|
||||
void ForEachInNode(String const & prefix, ToDo && toDo) const
|
||||
{
|
||||
MoveTo(prefix, true /* fullMatch */,
|
||||
[&](Node const & node, Edge const & /* edge */, size_t /* offset */) {
|
||||
node.m_values.ForEach(toDo);
|
||||
});
|
||||
[&](Node const & node, Edge const & /* edge */, size_t /* offset */) { node.m_values.ForEach(toDo); });
|
||||
}
|
||||
|
||||
template <typename ToDo>
|
||||
void WithValuesHolder(String const & prefix, ToDo && toDo) const
|
||||
{
|
||||
MoveTo(prefix, true /* fullMatch */, [&toDo](Node const & node, Edge const & /* edge */,
|
||||
size_t /* offset */) { toDo(node.m_values); });
|
||||
MoveTo(prefix, true /* fullMatch */,
|
||||
[&toDo](Node const & node, Edge const & /* edge */, size_t /* offset */) { toDo(node.m_values); });
|
||||
}
|
||||
|
||||
// Calls |toDo| for each key-value pair in a subtree that is
|
||||
@@ -316,7 +309,8 @@ public:
|
||||
template <typename ToDo>
|
||||
void ForEachInSubtree(String const & prefix, ToDo && toDo) const
|
||||
{
|
||||
MoveTo(prefix, false /* fullMatch */, [&](Node const & node, Edge const & edge, size_t offset) {
|
||||
MoveTo(prefix, false /* fullMatch */, [&](Node const & node, Edge const & edge, size_t offset)
|
||||
{
|
||||
String p = prefix;
|
||||
for (; offset < edge.Size(); ++offset)
|
||||
p.push_back(edge[offset]);
|
||||
@@ -328,17 +322,15 @@ public:
|
||||
{
|
||||
bool exists = false;
|
||||
MoveTo(key, true /* fullMatch */,
|
||||
[&](Node const & node, Edge const & /* edge */, size_t /* offset */) {
|
||||
exists = !node.m_values.Empty();
|
||||
});
|
||||
[&](Node const & node, Edge const & /* edge */, size_t /* offset */) { exists = !node.m_values.Empty(); });
|
||||
return exists;
|
||||
}
|
||||
|
||||
bool HasPrefix(String const & prefix) const
|
||||
{
|
||||
bool exists = false;
|
||||
MoveTo(prefix, false /* fullMatch */, [&](Node const & node, Edge const & /* edge */,
|
||||
size_t /* offset */) { exists = !node.Empty(); });
|
||||
MoveTo(prefix, false /* fullMatch */,
|
||||
[&](Node const & node, Edge const & /* edge */, size_t /* offset */) { exists = !node.Empty(); });
|
||||
return exists;
|
||||
}
|
||||
|
||||
@@ -392,10 +384,7 @@ private:
|
||||
// Prepends |prefix| to the edge.
|
||||
//
|
||||
// Complexity: amortized O(|prefix|)
|
||||
void Prepend(Edge const & prefix)
|
||||
{
|
||||
m_label.insert(m_label.end(), prefix.m_label.cbegin(), prefix.m_label.cend());
|
||||
}
|
||||
void Prepend(Edge const & prefix) { m_label.insert(m_label.end(), prefix.m_label.cbegin(), prefix.m_label.cend()); }
|
||||
|
||||
Char operator[](size_t i) const
|
||||
{
|
||||
@@ -410,7 +399,10 @@ private:
|
||||
void Swap(Edge & rhs) { m_label.swap(rhs.m_label); }
|
||||
|
||||
template <typename Sequence>
|
||||
Sequence As() const { return {m_label.rbegin(), m_label.rend()}; }
|
||||
Sequence As() const
|
||||
{
|
||||
return {m_label.rbegin(), m_label.rend()};
|
||||
}
|
||||
|
||||
friend std::string DebugPrint(Edge const & edge) { return edge.template As<std::string>(); }
|
||||
|
||||
@@ -425,17 +417,11 @@ private:
|
||||
|
||||
Node & operator=(Node && /* rhs */) = default;
|
||||
|
||||
Node & GetOrCreateMove(Char const & c, bool & created)
|
||||
{
|
||||
return m_moves.GetOrCreateSubtree(c, created);
|
||||
}
|
||||
Node & GetOrCreateMove(Char const & c, bool & created) { return m_moves.GetOrCreateSubtree(c, created); }
|
||||
|
||||
Node * GetMove(Char const & c) const { return m_moves.GetSubtree(c); }
|
||||
|
||||
void AddChild(Char const & c, std::unique_ptr<Node> node)
|
||||
{
|
||||
m_moves.AddSubtree(c, std::move(node));
|
||||
}
|
||||
void AddChild(Char const & c, std::unique_ptr<Node> node) { m_moves.AddSubtree(c, std::move(node)); }
|
||||
|
||||
void EraseMove(Char const & c) { m_moves.EraseSubtree(c); }
|
||||
|
||||
@@ -445,10 +431,7 @@ private:
|
||||
m_values.Add(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void EraseValue(Value const & value)
|
||||
{
|
||||
m_values.Erase(value);
|
||||
}
|
||||
void EraseValue(Value const & value) { m_values.Erase(value); }
|
||||
|
||||
bool Empty() const { return m_moves.Empty() && m_values.Empty(); }
|
||||
|
||||
@@ -461,8 +444,7 @@ private:
|
||||
size_t GetNumNodes() const
|
||||
{
|
||||
size_t size = 1;
|
||||
m_moves.ForEach(
|
||||
[&size](Char const & /* c */, Node const & child) { size += child.GetNumNodes(); });
|
||||
m_moves.ForEach([&size](Char const & /* c */, Node const & child) { size += child.GetNumNodes(); });
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -533,7 +515,8 @@ private:
|
||||
{
|
||||
Node child;
|
||||
Char c;
|
||||
root.m_moves.ForEach([&](Char const & mc, Node & mn) {
|
||||
root.m_moves.ForEach([&](Char const & mc, Node & mn)
|
||||
{
|
||||
c = mc;
|
||||
child.Swap(mn);
|
||||
});
|
||||
@@ -571,19 +554,17 @@ private:
|
||||
template <typename ToDo>
|
||||
void ForEachInSubtree(Node const & node, String & prefix, ToDo && toDo) const
|
||||
{
|
||||
node.m_values.ForEach([&prefix, &toDo](Value const & value) {
|
||||
toDo(static_cast<String const &>(prefix), value);
|
||||
});
|
||||
node.m_values.ForEach([&prefix, &toDo](Value const & value) { toDo(static_cast<String const &>(prefix), value); });
|
||||
|
||||
node.m_moves.ForEach([&](Char const & c, Node const & node)
|
||||
{
|
||||
auto const size = prefix.size();
|
||||
auto const edge = node.m_edge.template As<String>();
|
||||
prefix.push_back(c);
|
||||
prefix.insert(prefix.end(), edge.begin(), edge.end());
|
||||
ForEachInSubtree(node, prefix, toDo);
|
||||
prefix.resize(size);
|
||||
});
|
||||
{
|
||||
auto const size = prefix.size();
|
||||
auto const edge = node.m_edge.template As<String>();
|
||||
prefix.push_back(c);
|
||||
prefix.insert(prefix.end(), edge.begin(), edge.end());
|
||||
ForEachInSubtree(node, prefix, toDo);
|
||||
prefix.resize(size);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename It>
|
||||
|
||||
@@ -24,8 +24,7 @@ public:
|
||||
|
||||
template <typename V, impl::IsConvertibleGuard<V, Type> = nullptr>
|
||||
constexpr explicit NewType(V const & v) : m_value(v)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
constexpr NewType() = default;
|
||||
|
||||
@@ -155,8 +154,8 @@ std::string SimpleDebugPrint(NewType<Type, Tag> const & nt)
|
||||
} // namespace newtype_default_output
|
||||
} // namespace base
|
||||
|
||||
#define NEWTYPE(REPR, NAME) \
|
||||
struct NAME##_tag; \
|
||||
#define NEWTYPE(REPR, NAME) \
|
||||
struct NAME##_tag; \
|
||||
using NAME = base::NewType<REPR, NAME##_tag>
|
||||
|
||||
#define NEWTYPE_SIMPLE_OUTPUT(NAME) \
|
||||
|
||||
@@ -64,15 +64,14 @@ bool NonIntersectingIntervals<T>::AddInterval(T left, T right)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
NonIntersectingIntervals<T>::Interval::Interval(T left, T right)
|
||||
: m_left(left), m_right(right)
|
||||
NonIntersectingIntervals<T>::Interval::Interval(T left, T right) : m_left(left)
|
||||
, m_right(right)
|
||||
{
|
||||
CHECK_LESS_OR_EQUAL(left, right, ());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NonIntersectingIntervals<T>::Interval::LessByLeftEnd::operator()(Interval const & lhs,
|
||||
Interval const & rhs) const
|
||||
bool NonIntersectingIntervals<T>::Interval::LessByLeftEnd::operator()(Interval const & lhs, Interval const & rhs) const
|
||||
{
|
||||
return lhs.m_left < rhs.m_left;
|
||||
}
|
||||
@@ -82,4 +81,4 @@ bool NonIntersectingIntervals<T>::Interval::Intersects(Interval const & rhs) con
|
||||
{
|
||||
return std::max(m_left, rhs.m_left) <= std::min(m_right, rhs.m_right);
|
||||
}
|
||||
} // namespace coding
|
||||
} // namespace base
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5,7 +5,8 @@
|
||||
|
||||
namespace base
|
||||
{
|
||||
template <class T> class UniformRandom
|
||||
template <class T>
|
||||
class UniformRandom
|
||||
{
|
||||
static_assert(std::is_integral<T>::value);
|
||||
|
||||
@@ -19,4 +20,4 @@ public:
|
||||
|
||||
T operator()() { return m_distr(m_gen); }
|
||||
};
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -16,9 +16,17 @@ template <typename TCounter>
|
||||
struct RangeIterator
|
||||
{
|
||||
explicit RangeIterator(TCounter const current) : m_current(current) {}
|
||||
RangeIterator & operator++() { ++m_current; return *this; }
|
||||
RangeIterator & operator++()
|
||||
{
|
||||
++m_current;
|
||||
return *this;
|
||||
}
|
||||
RangeIterator operator++(int) { return RangeIterator(m_current++); }
|
||||
RangeIterator & operator--() { --m_current; return *this; }
|
||||
RangeIterator & operator--()
|
||||
{
|
||||
--m_current;
|
||||
return *this;
|
||||
}
|
||||
RangeIterator operator--(int) { return RangeIterator(m_current--); }
|
||||
bool operator==(RangeIterator const & it) const { return m_current == it.m_current; }
|
||||
bool operator!=(RangeIterator const & it) const { return !(*this == it); }
|
||||
@@ -40,7 +48,7 @@ struct iterator_traits<base::RangeIterator<T>>
|
||||
using reference = T;
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
};
|
||||
} // namespace std
|
||||
} // namespace std
|
||||
|
||||
namespace base
|
||||
{
|
||||
@@ -51,11 +59,7 @@ struct RangeWrapper
|
||||
using iterator_base = RangeIterator<value_type>;
|
||||
using iterator = std::conditional_t<forward, iterator_base, std::reverse_iterator<iterator_base>>;
|
||||
|
||||
RangeWrapper(TCounter const from, TCounter const to):
|
||||
m_begin(from),
|
||||
m_end(to)
|
||||
{
|
||||
}
|
||||
RangeWrapper(TCounter const from, TCounter const to) : m_begin(from), m_end(to) {}
|
||||
|
||||
iterator begin() const { return iterator(iterator_base(m_begin)); }
|
||||
iterator end() const { return iterator(iterator_base(m_end)); }
|
||||
|
||||
@@ -7,16 +7,14 @@
|
||||
#include <queue>
|
||||
#endif
|
||||
|
||||
template <typename T, typename HashT> class RabinKarpRollingHasher
|
||||
template <typename T, typename HashT>
|
||||
class RabinKarpRollingHasher
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using hash_type = HashT;
|
||||
|
||||
explicit RabinKarpRollingHasher(HashT multiplier)
|
||||
: m_multiplier(multiplier)
|
||||
{
|
||||
}
|
||||
explicit RabinKarpRollingHasher(HashT multiplier) : m_multiplier(multiplier) {}
|
||||
|
||||
template <typename Iter>
|
||||
hash_type Init(Iter it, uint64_t windowSize)
|
||||
@@ -25,7 +23,8 @@ public:
|
||||
m_windowSize = windowSize;
|
||||
m_removeMultiplier = math::PowUint(m_multiplier, m_windowSize - 1);
|
||||
#ifdef DEBUG
|
||||
while (!m_queue.empty()) m_queue.pop();
|
||||
while (!m_queue.empty())
|
||||
m_queue.pop();
|
||||
#endif
|
||||
m_hash = 0;
|
||||
for (uint64_t i = 0; i < m_windowSize; ++it, ++i)
|
||||
@@ -66,15 +65,13 @@ private:
|
||||
class RabinKarpRollingHasher32 : public RabinKarpRollingHasher<uint32_t, uint32_t>
|
||||
{
|
||||
public:
|
||||
RabinKarpRollingHasher32()
|
||||
: RabinKarpRollingHasher(1103515245U) {}
|
||||
RabinKarpRollingHasher32() : RabinKarpRollingHasher(1103515245U) {}
|
||||
};
|
||||
|
||||
class RabinKarpRollingHasher64 : public RabinKarpRollingHasher<uint64_t, uint64_t>
|
||||
{
|
||||
public:
|
||||
RabinKarpRollingHasher64()
|
||||
: RabinKarpRollingHasher(6364136223846793005ULL) {}
|
||||
RabinKarpRollingHasher64() : RabinKarpRollingHasher(6364136223846793005ULL) {}
|
||||
};
|
||||
|
||||
using RollingHasher32 = RabinKarpRollingHasher32;
|
||||
|
||||
@@ -8,44 +8,37 @@ namespace base
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
/// Base class for all ScopeGuards.
|
||||
class GuardBase
|
||||
/// Base class for all ScopeGuards.
|
||||
class GuardBase
|
||||
{
|
||||
public:
|
||||
/// Disable ScopeGuard functionality on it's destruction
|
||||
void release() const { m_bDoRollback = false; }
|
||||
|
||||
protected:
|
||||
GuardBase() : m_bDoRollback(true) {}
|
||||
|
||||
// Do something in the destructor
|
||||
mutable bool m_bDoRollback;
|
||||
};
|
||||
|
||||
/// ScopeGuard for specific functor
|
||||
template <typename TFunctor>
|
||||
class GuardImpl : public GuardBase
|
||||
{
|
||||
public:
|
||||
explicit GuardImpl(TFunctor const & F) : m_Functor(F) {}
|
||||
|
||||
~GuardImpl()
|
||||
{
|
||||
public:
|
||||
/// Disable ScopeGuard functionality on it's destruction
|
||||
void release() const
|
||||
{
|
||||
m_bDoRollback = false;
|
||||
}
|
||||
if (m_bDoRollback)
|
||||
m_Functor();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
GuardBase() : m_bDoRollback(true)
|
||||
{
|
||||
}
|
||||
|
||||
// Do something in the destructor
|
||||
mutable bool m_bDoRollback;
|
||||
};
|
||||
|
||||
/// ScopeGuard for specific functor
|
||||
template <typename TFunctor> class GuardImpl : public GuardBase
|
||||
{
|
||||
public:
|
||||
explicit GuardImpl(TFunctor const & F) : m_Functor(F)
|
||||
{
|
||||
}
|
||||
|
||||
~GuardImpl()
|
||||
{
|
||||
if (m_bDoRollback)
|
||||
m_Functor();
|
||||
}
|
||||
|
||||
private:
|
||||
TFunctor m_Functor;
|
||||
};
|
||||
} // namespace impl
|
||||
private:
|
||||
TFunctor m_Functor;
|
||||
};
|
||||
} // namespace impl
|
||||
|
||||
typedef impl::GuardBase const & scope_guard;
|
||||
|
||||
@@ -55,7 +48,7 @@ impl::GuardImpl<TFunctor> make_scope_guard(TFunctor const & F)
|
||||
{
|
||||
return impl::GuardImpl<TFunctor>(F);
|
||||
}
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
#define SCOPE_GUARD(name, func) \
|
||||
::base::scope_guard name = base::make_scope_guard(func); \
|
||||
|
||||
@@ -2,30 +2,28 @@
|
||||
|
||||
// Similar to set_difference(), but if element is present n times in the first sequence and once in
|
||||
// the second sequence, all n copies are filtered, insted of one.
|
||||
template<typename Iter1T, typename Iter2T, typename OutIterT, typename LessT>
|
||||
OutIterT SetDifferenceUnlimited(Iter1T beg1, Iter1T end1,
|
||||
Iter2T beg2, Iter2T end2,
|
||||
OutIterT out, LessT lessCompare)
|
||||
template <typename Iter1T, typename Iter2T, typename OutIterT, typename LessT>
|
||||
OutIterT SetDifferenceUnlimited(Iter1T beg1, Iter1T end1, Iter2T beg2, Iter2T end2, OutIterT out, LessT lessCompare)
|
||||
{
|
||||
while (beg1 != end1 && beg2 != end2)
|
||||
{
|
||||
while (beg1 != end1 && beg2 != end2)
|
||||
if (lessCompare(*beg1, *beg2))
|
||||
{
|
||||
if (lessCompare(*beg1, *beg2))
|
||||
{
|
||||
*out = *beg1;
|
||||
++beg1;
|
||||
++out;
|
||||
}
|
||||
else if (lessCompare(*beg2, *beg1))
|
||||
{
|
||||
++beg2;
|
||||
}
|
||||
else
|
||||
{
|
||||
++beg1;
|
||||
// This is the difference between set_difference and this function:
|
||||
// In set_difference the commented line should be present.
|
||||
// ++beg2;
|
||||
}
|
||||
*out = *beg1;
|
||||
++beg1;
|
||||
++out;
|
||||
}
|
||||
else if (lessCompare(*beg2, *beg1))
|
||||
{
|
||||
++beg2;
|
||||
}
|
||||
else
|
||||
{
|
||||
++beg1;
|
||||
// This is the difference between set_difference and this function:
|
||||
// In set_difference the commented line should be present.
|
||||
// ++beg2;
|
||||
}
|
||||
return std::copy(beg1, end1, out);
|
||||
}
|
||||
return std::copy(beg1, end1, out);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
typedef std::shared_ptr<shared_buffer_t> shared_buffer_ptr_t;
|
||||
typedef std::list<shared_buffer_ptr_t> shared_buffer_ptr_list_t;
|
||||
typedef std::map<size_t, shared_buffer_ptr_list_t> shared_buffers_t;
|
||||
private:
|
||||
|
||||
private:
|
||||
std::mutex m_mutex;
|
||||
shared_buffers_t m_sharedBuffers;
|
||||
|
||||
|
||||
@@ -9,14 +9,17 @@ namespace base
|
||||
|
||||
/// Consider using as a replacement of unordered_map (map) when:
|
||||
/// - very small amount of elements (<8)
|
||||
template <class Key, class Value> class SmallMapBase
|
||||
template <class Key, class Value>
|
||||
class SmallMapBase
|
||||
{
|
||||
public:
|
||||
using ValueType = std::pair<Key, Value>;
|
||||
|
||||
SmallMapBase() = default;
|
||||
SmallMapBase(std::initializer_list<ValueType> init) : m_map(std::move(init)) {}
|
||||
template <class Iter> SmallMapBase(Iter beg, Iter end) : m_map(beg, end) {}
|
||||
template <class Iter>
|
||||
SmallMapBase(Iter beg, Iter end) : m_map(beg, end)
|
||||
{}
|
||||
|
||||
bool operator==(SmallMapBase const & rhs) const { return m_map == rhs.m_map; }
|
||||
|
||||
@@ -26,10 +29,8 @@ public:
|
||||
Value const * Find(Key const & k) const
|
||||
{
|
||||
for (auto const & e : m_map)
|
||||
{
|
||||
if (e.first == k)
|
||||
return &e.second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -45,7 +46,8 @@ protected:
|
||||
/// Consider using as a replacement of unordered_map (map) when:
|
||||
/// - initialize and don't modify
|
||||
/// - relatively small amount of elements (8-128)
|
||||
template <class Key, class Value> class SmallMap : public SmallMapBase<Key, Value>
|
||||
template <class Key, class Value>
|
||||
class SmallMap : public SmallMapBase<Key, Value>
|
||||
{
|
||||
using BaseT = SmallMapBase<Key, Value>;
|
||||
|
||||
@@ -53,13 +55,9 @@ public:
|
||||
using ValueType = typename BaseT::ValueType;
|
||||
|
||||
SmallMap() = default;
|
||||
SmallMap(std::initializer_list<ValueType> init)
|
||||
: BaseT(std::move(init))
|
||||
{
|
||||
FinishBuilding();
|
||||
}
|
||||
template <class Iter> SmallMap(Iter beg, Iter end)
|
||||
: BaseT(beg, end)
|
||||
SmallMap(std::initializer_list<ValueType> init) : BaseT(std::move(init)) { FinishBuilding(); }
|
||||
template <class Iter>
|
||||
SmallMap(Iter beg, Iter end) : BaseT(beg, end)
|
||||
{
|
||||
FinishBuilding();
|
||||
}
|
||||
@@ -67,20 +65,14 @@ public:
|
||||
void FinishBuilding()
|
||||
{
|
||||
auto & theMap = this->m_map;
|
||||
std::sort(theMap.begin(), theMap.end(), [](ValueType const & l, ValueType const & r)
|
||||
{
|
||||
return l.first < r.first;
|
||||
});
|
||||
std::sort(theMap.begin(), theMap.end(), [](ValueType const & l, ValueType const & r) { return l.first < r.first; });
|
||||
}
|
||||
|
||||
Value const * Find(Key const & k) const
|
||||
{
|
||||
auto const & theMap = this->m_map;
|
||||
auto const it = std::lower_bound(theMap.cbegin(), theMap.cend(), k,
|
||||
[](ValueType const & l, Key const & r)
|
||||
{
|
||||
return l.first < r;
|
||||
});
|
||||
[](ValueType const & l, Key const & r) { return l.first < r; });
|
||||
|
||||
if (it != theMap.cend() && it->first == k)
|
||||
return &(it->second);
|
||||
@@ -91,10 +83,7 @@ public:
|
||||
{
|
||||
auto & theMap = this->m_map;
|
||||
auto it = std::lower_bound(theMap.begin(), theMap.end(), k,
|
||||
[](ValueType const & l, Key const & r)
|
||||
{
|
||||
return l.first < r;
|
||||
});
|
||||
[](ValueType const & l, Key const & r) { return l.first < r; });
|
||||
|
||||
ASSERT(it != theMap.end() && it->first == k, ());
|
||||
it->second = std::move(v);
|
||||
@@ -108,4 +97,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -34,7 +34,9 @@ public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
Iterator(uint64_t const * blocks, uint64_t current_block_index)
|
||||
: m_blocks(blocks), m_current_block_index(current_block_index), m_current_block(0)
|
||||
: m_blocks(blocks)
|
||||
, m_current_block_index(current_block_index)
|
||||
, m_current_block(0)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(current_block_index, kNumBlocks, ());
|
||||
if (current_block_index < kNumBlocks)
|
||||
|
||||
@@ -24,8 +24,7 @@ std::string DebugPrint(SrcPoint const & srcPoint)
|
||||
{
|
||||
std::ostringstream out;
|
||||
if (srcPoint.Line() > 0)
|
||||
out << srcPoint.FileName() << ":" << srcPoint.Line() << " " << srcPoint.Function()
|
||||
<< srcPoint.Postfix() << ": ";
|
||||
out << srcPoint.FileName() << ":" << srcPoint.Line() << " " << srcPoint.Function() << srcPoint.Postfix() << ": ";
|
||||
return out.str();
|
||||
}
|
||||
} // namespace base
|
||||
|
||||
@@ -24,7 +24,10 @@ public:
|
||||
SrcPoint() : m_fileName(""), m_line(-1), m_function(""), m_postfix("") { TruncateFileName(); }
|
||||
|
||||
SrcPoint(char const * fileName, int line, char const * function, char const * postfix = "")
|
||||
: m_fileName(fileName), m_line(line), m_function(function), m_postfix(postfix)
|
||||
: m_fileName(fileName)
|
||||
, m_line(line)
|
||||
, m_function(function)
|
||||
, m_postfix(postfix)
|
||||
{
|
||||
TruncateFileName();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class NoopStats
|
||||
{
|
||||
public:
|
||||
NoopStats() {}
|
||||
void operator() (T const &) {}
|
||||
void operator()(T const &) {}
|
||||
std::string GetStatsStr() const { return ""; }
|
||||
};
|
||||
|
||||
@@ -25,7 +25,8 @@ class AverageStats
|
||||
{
|
||||
public:
|
||||
AverageStats() = default;
|
||||
template <class ContT> explicit AverageStats(ContT const & cont)
|
||||
template <class ContT>
|
||||
explicit AverageStats(ContT const & cont)
|
||||
{
|
||||
for (auto const & e : cont)
|
||||
(*this)(e);
|
||||
@@ -55,7 +56,8 @@ private:
|
||||
T m_sum = 0;
|
||||
};
|
||||
|
||||
template <class T> class StatsCollector
|
||||
template <class T>
|
||||
class StatsCollector
|
||||
{
|
||||
std::vector<std::pair<std::string, AverageStats<T>>> m_vec;
|
||||
|
||||
@@ -74,7 +76,8 @@ public:
|
||||
AverageStats<T> & Get(size_t i) { return m_vec[i].second; }
|
||||
};
|
||||
|
||||
template <class Key> class TopStatsCounter
|
||||
template <class Key>
|
||||
class TopStatsCounter
|
||||
{
|
||||
std::unordered_map<Key, size_t> m_data;
|
||||
|
||||
@@ -88,7 +91,7 @@ public:
|
||||
using PtrT = std::pair<Key const, size_t> const *;
|
||||
struct GreaterNumber
|
||||
{
|
||||
bool operator() (PtrT l, PtrT r) const { return l->second > r->second; }
|
||||
bool operator()(PtrT l, PtrT r) const { return l->second > r->second; }
|
||||
};
|
||||
|
||||
std::priority_queue<PtrT, std::vector<PtrT>, GreaterNumber> queue;
|
||||
|
||||
@@ -5,19 +5,18 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
/// @name std containers serialization
|
||||
/// TArchive should be an archive class in global namespace.
|
||||
//@{
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator << (TArchive & ar, std::pair<T1, T2> const & t)
|
||||
TArchive & operator<<(TArchive & ar, std::pair<T1, T2> const & t)
|
||||
{
|
||||
ar << t.first << t.second;
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator >> (TArchive & ar, std::pair<T1, T2> & t)
|
||||
TArchive & operator>>(TArchive & ar, std::pair<T1, T2> & t)
|
||||
{
|
||||
ar >> t.first >> t.second;
|
||||
return ar;
|
||||
@@ -103,77 +102,77 @@ void load_like_set(TArchive & ar, TCont & rSet)
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator << (TArchive & ar, std::map<T1, T2> const & rMap)
|
||||
TArchive & operator<<(TArchive & ar, std::map<T1, T2> const & rMap)
|
||||
{
|
||||
save_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator >> (TArchive & ar, std::map<T1, T2> & rMap)
|
||||
TArchive & operator>>(TArchive & ar, std::map<T1, T2> & rMap)
|
||||
{
|
||||
load_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator << (TArchive & ar, std::multimap<T1, T2> const & rMap)
|
||||
TArchive & operator<<(TArchive & ar, std::multimap<T1, T2> const & rMap)
|
||||
{
|
||||
save_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator >> (TArchive & ar, std::multimap<T1, T2> & rMap)
|
||||
TArchive & operator>>(TArchive & ar, std::multimap<T1, T2> & rMap)
|
||||
{
|
||||
load_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator << (TArchive & ar, std::unordered_map<T1, T2> const & rMap)
|
||||
TArchive & operator<<(TArchive & ar, std::unordered_map<T1, T2> const & rMap)
|
||||
{
|
||||
save_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T1, class T2>
|
||||
TArchive & operator >> (TArchive & ar, std::unordered_map<T1, T2> & rMap)
|
||||
TArchive & operator>>(TArchive & ar, std::unordered_map<T1, T2> & rMap)
|
||||
{
|
||||
load_like_map(ar, rMap);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T>
|
||||
TArchive & operator << (TArchive & ar, std::vector<T> const & rVector)
|
||||
TArchive & operator<<(TArchive & ar, std::vector<T> const & rVector)
|
||||
{
|
||||
save_like_vector(ar, rVector);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T>
|
||||
TArchive & operator >> (TArchive & ar, std::vector<T> & rVector)
|
||||
TArchive & operator>>(TArchive & ar, std::vector<T> & rVector)
|
||||
{
|
||||
load_like_vector(ar, rVector);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T>
|
||||
TArchive & operator << (TArchive & ar, std::set<T> const & rSet)
|
||||
TArchive & operator<<(TArchive & ar, std::set<T> const & rSet)
|
||||
{
|
||||
save_like_set(ar, rSet);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T>
|
||||
TArchive & operator >> (TArchive & ar, std::set<T> & rSet)
|
||||
TArchive & operator>>(TArchive & ar, std::set<T> & rSet)
|
||||
{
|
||||
load_like_set(ar, rSet);
|
||||
return ar;
|
||||
}
|
||||
|
||||
template <class TArchive, class T, size_t N>
|
||||
TArchive & operator << (TArchive & ar, std::array<T, N> const & rArray)
|
||||
TArchive & operator<<(TArchive & ar, std::array<T, N> const & rArray)
|
||||
{
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
ar << rArray[i];
|
||||
@@ -181,7 +180,7 @@ TArchive & operator << (TArchive & ar, std::array<T, N> const & rArray)
|
||||
}
|
||||
|
||||
template <class TArchive, class T, size_t N>
|
||||
TArchive & operator >> (TArchive & ar, std::array<T, N> & rArray)
|
||||
TArchive & operator>>(TArchive & ar, std::array<T, N> & rArray)
|
||||
{
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
ar >> rArray[i];
|
||||
|
||||
@@ -29,10 +29,7 @@ struct Less<true, T, C>
|
||||
|
||||
bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p < rhs.*m_p; }
|
||||
|
||||
bool operator()(C const * const lhs, C const * const rhs) const
|
||||
{
|
||||
return lhs->*m_p < rhs->*m_p;
|
||||
}
|
||||
bool operator()(C const * const lhs, C const * const rhs) const { return lhs->*m_p < rhs->*m_p; }
|
||||
|
||||
T C::* m_p;
|
||||
};
|
||||
@@ -44,10 +41,7 @@ struct Less<false, T, C>
|
||||
|
||||
bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() < (rhs.*m_p)(); }
|
||||
|
||||
bool operator()(C const * const lhs, C const * const rhs) const
|
||||
{
|
||||
return (lhs->*m_p)() < (rhs->*m_p)();
|
||||
}
|
||||
bool operator()(C const * const lhs, C const * const rhs) const { return (lhs->*m_p)() < (rhs->*m_p)(); }
|
||||
|
||||
T (C::*m_p)() const;
|
||||
};
|
||||
@@ -62,10 +56,7 @@ struct Equals<true, T, C>
|
||||
|
||||
bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p == rhs.*m_p; }
|
||||
|
||||
bool operator()(C const * const lhs, C const * const rhs) const
|
||||
{
|
||||
return lhs->*m_p == rhs->*m_p;
|
||||
}
|
||||
bool operator()(C const * const lhs, C const * const rhs) const { return lhs->*m_p == rhs->*m_p; }
|
||||
|
||||
T C::* m_p;
|
||||
};
|
||||
@@ -77,10 +68,7 @@ struct Equals<false, T, C>
|
||||
|
||||
bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() == (rhs.*m_p)(); }
|
||||
|
||||
bool operator()(C const * const lhs, C const * const rhs) const
|
||||
{
|
||||
return (lhs->*m_p)() == (rhs->*m_p)();
|
||||
}
|
||||
bool operator()(C const * const lhs, C const * const rhs) const { return (lhs->*m_p)() == (rhs->*m_p)(); }
|
||||
|
||||
T (C::*m_p)() const;
|
||||
};
|
||||
@@ -89,9 +77,7 @@ template <typename Container, typename Deletor>
|
||||
class DeleteRangeFunctor
|
||||
{
|
||||
public:
|
||||
DeleteRangeFunctor(Container & cont, Deletor const & deletor) : m_cont(cont), m_deletor(deletor)
|
||||
{
|
||||
}
|
||||
DeleteRangeFunctor(Container & cont, Deletor const & deletor) : m_cont(cont), m_deletor(deletor) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
@@ -227,10 +213,11 @@ class IgnoreFirstArgument
|
||||
{
|
||||
public:
|
||||
template <typename Gn>
|
||||
explicit IgnoreFirstArgument(Gn && gn) : m_fn(std::forward<Gn>(gn)) {}
|
||||
explicit IgnoreFirstArgument(Gn && gn) : m_fn(std::forward<Gn>(gn))
|
||||
{}
|
||||
|
||||
template <typename Arg, typename... Args>
|
||||
std::invoke_result_t<Fn, Args&&...> operator()(Arg &&, Args &&... args)
|
||||
std::invoke_result_t<Fn, Args &&...> operator()(Arg &&, Args &&... args)
|
||||
{
|
||||
return m_fn(std::forward<Args>(args)...);
|
||||
}
|
||||
@@ -246,28 +233,22 @@ IgnoreFirstArgument<Fn> MakeIgnoreFirstArgument(Fn && fn)
|
||||
}
|
||||
|
||||
template <size_t I = 0, typename Fn, typename... Tp>
|
||||
std::enable_if_t<I == sizeof...(Tp), void>
|
||||
for_each_in_tuple(std::tuple<Tp...> &, Fn &&)
|
||||
{
|
||||
}
|
||||
std::enable_if_t<I == sizeof...(Tp), void> for_each_in_tuple(std::tuple<Tp...> &, Fn &&)
|
||||
{}
|
||||
|
||||
template <size_t I = 0, typename Fn, typename... Tp>
|
||||
std::enable_if_t<I != sizeof...(Tp), void>
|
||||
for_each_in_tuple(std::tuple<Tp...> & t, Fn && fn)
|
||||
std::enable_if_t<I != sizeof...(Tp), void> for_each_in_tuple(std::tuple<Tp...> & t, Fn && fn)
|
||||
{
|
||||
fn(I, std::get<I>(t));
|
||||
for_each_in_tuple<I + 1, Fn, Tp...>(t, std::forward<Fn>(fn));
|
||||
}
|
||||
|
||||
template <size_t I = 0, typename Fn, typename... Tp>
|
||||
std::enable_if_t<I == sizeof...(Tp), void>
|
||||
for_each_in_tuple_const(std::tuple<Tp...> const &, Fn &&)
|
||||
{
|
||||
}
|
||||
std::enable_if_t<I == sizeof...(Tp), void> for_each_in_tuple_const(std::tuple<Tp...> const &, Fn &&)
|
||||
{}
|
||||
|
||||
template <size_t I = 0, typename Fn, typename... Tp>
|
||||
std::enable_if_t<I != sizeof...(Tp), void>
|
||||
for_each_in_tuple_const(std::tuple<Tp...> const & t, Fn && fn)
|
||||
std::enable_if_t<I != sizeof...(Tp), void> for_each_in_tuple_const(std::tuple<Tp...> const & t, Fn && fn)
|
||||
{
|
||||
fn(I, std::get<I>(t));
|
||||
for_each_in_tuple_const<I + 1, Fn, Tp...>(t, std::forward<Fn>(fn));
|
||||
@@ -278,7 +259,11 @@ class BackInsertFunctor
|
||||
{
|
||||
public:
|
||||
explicit BackInsertFunctor(Container & container) : m_Container(container) {}
|
||||
template <class T> void operator()(T && t) const { m_Container.push_back(std::forward<T>(t)); }
|
||||
template <class T>
|
||||
void operator()(T && t) const
|
||||
{
|
||||
m_Container.push_back(std::forward<T>(t));
|
||||
}
|
||||
|
||||
private:
|
||||
Container & m_Container;
|
||||
@@ -295,10 +280,7 @@ class InsertFunctor
|
||||
{
|
||||
public:
|
||||
explicit InsertFunctor(Container & container) : m_Container(container) {}
|
||||
void operator()(typename Container::value_type const & t) const
|
||||
{
|
||||
m_Container.insert(end(m_Container), t);
|
||||
}
|
||||
void operator()(typename Container::value_type const & t) const { m_Container.insert(end(m_Container), t); }
|
||||
|
||||
private:
|
||||
Container & m_Container;
|
||||
@@ -317,10 +299,8 @@ bool IsSortedAndUnique(Iter beg, Iter end, Compare comp)
|
||||
return true;
|
||||
Iter prev = beg;
|
||||
for (++beg; beg != end; ++beg, ++prev)
|
||||
{
|
||||
if (!comp(*prev, *beg))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -364,8 +344,7 @@ struct DeleteFunctor
|
||||
};
|
||||
|
||||
template <typename Container, typename Deletor>
|
||||
impl::DeleteRangeFunctor<Container, Deletor> GetRangeDeletor(Container & cont,
|
||||
Deletor const & deletor)
|
||||
impl::DeleteRangeFunctor<Container, Deletor> GetRangeDeletor(Container & cont, Deletor const & deletor)
|
||||
{
|
||||
return impl::DeleteRangeFunctor<Container, Deletor>(cont, deletor);
|
||||
}
|
||||
@@ -473,7 +452,7 @@ void AccumulateIntervals1With2(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, InsertIte
|
||||
|
||||
struct EnumClassHash
|
||||
{
|
||||
template<typename T, std::enable_if_t<std::is_enum<T>::value> * = nullptr>
|
||||
template <typename T, std::enable_if_t<std::is_enum<T>::value> * = nullptr>
|
||||
size_t operator()(T const & t) const noexcept
|
||||
{
|
||||
return static_cast<size_t>(t);
|
||||
|
||||
@@ -6,14 +6,19 @@ namespace stl_iterator_detail
|
||||
{
|
||||
struct Dummy
|
||||
{
|
||||
template <class T> Dummy & operator=(T const &) { return *this; }
|
||||
template <class T>
|
||||
Dummy & operator=(T const &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
} // namespace stl_iterator_detail
|
||||
|
||||
class CounterIterator :
|
||||
public boost::iterator_facade<CounterIterator, stl_iterator_detail::Dummy, boost::forward_traversal_tag>
|
||||
class CounterIterator
|
||||
: public boost::iterator_facade<CounterIterator, stl_iterator_detail::Dummy, boost::forward_traversal_tag>
|
||||
{
|
||||
size_t m_count;
|
||||
|
||||
public:
|
||||
CounterIterator() : m_count(0) {}
|
||||
size_t GetCount() const { return m_count; }
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <fast_double_parser.h>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
namespace strings
|
||||
{
|
||||
@@ -75,7 +75,10 @@ SimpleDelimiter::SimpleDelimiter(char const * delims)
|
||||
m_delims.push_back(utf8::unchecked::next(it));
|
||||
}
|
||||
|
||||
SimpleDelimiter::SimpleDelimiter(char delim) { m_delims.push_back(delim); }
|
||||
SimpleDelimiter::SimpleDelimiter(char delim)
|
||||
{
|
||||
m_delims.push_back(delim);
|
||||
}
|
||||
|
||||
bool SimpleDelimiter::operator()(UniChar c) const
|
||||
{
|
||||
@@ -220,7 +223,7 @@ void AsciiToUpper(std::string & s)
|
||||
if (in >= 'a' && in <= 'z')
|
||||
return char(in - diff);
|
||||
return in;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void Trim(std::string & s)
|
||||
@@ -278,21 +281,13 @@ bool Truncate(std::string & utf8, size_t const maxTextLengthPlus1)
|
||||
uint8_t bytesInCodepoint = 1;
|
||||
|
||||
if ((byte & 0x80) == 0x00)
|
||||
{
|
||||
bytesInCodepoint = 1;
|
||||
}
|
||||
else if ((byte & 0xE0) == 0xC0)
|
||||
{
|
||||
bytesInCodepoint = 2;
|
||||
}
|
||||
else if ((byte & 0xF0) == 0xE0)
|
||||
{
|
||||
bytesInCodepoint = 3;
|
||||
}
|
||||
else if ((byte & 0xF8) == 0xF0)
|
||||
{
|
||||
bytesInCodepoint = 4;
|
||||
}
|
||||
|
||||
utf8.resize(i + bytesInCodepoint);
|
||||
return true;
|
||||
@@ -351,21 +346,25 @@ std::u16string ToUtf16(std::string_view utf8)
|
||||
bool IsASCIIString(std::string_view sv)
|
||||
{
|
||||
for (auto c : sv)
|
||||
{
|
||||
if (c & 0x80)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsASCIIDigit(UniChar c) { return c >= '0' && c <= '9'; }
|
||||
bool IsASCIIDigit(UniChar c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
bool IsASCIISpace(UniChar c)
|
||||
{
|
||||
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
|
||||
}
|
||||
|
||||
bool IsASCIILatin(UniChar c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }
|
||||
bool IsASCIILatin(UniChar c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
bool StartsWith(UniString const & s, UniString const & p)
|
||||
{
|
||||
@@ -460,8 +459,7 @@ bool AlmostEqual(std::string const & str1, std::string const & str2, size_t mism
|
||||
|
||||
for (size_t i = 0; i <= mismatchedCount; ++i)
|
||||
{
|
||||
auto const end =
|
||||
mis.first + std::min(distance(mis.first, str1End), distance(mis.second, str2End));
|
||||
auto const end = mis.first + std::min(distance(mis.first, str1End), distance(mis.second, str2End));
|
||||
mis = mismatch(mis.first, end, mis.second);
|
||||
if (mis.first == str1End && mis.second == str2End)
|
||||
return true;
|
||||
@@ -499,7 +497,9 @@ void ParseCSVRow(std::string const & row, char const delimiter, std::vector<std:
|
||||
target.clear();
|
||||
|
||||
std::string prevColumns;
|
||||
for (TokenizeIterator<SimpleDelimiter, std::string::const_iterator, true /* KeepEmptyTokens */> it {row.begin(), row.end(), delimiter}; it; ++it)
|
||||
for (TokenizeIterator<SimpleDelimiter, std::string::const_iterator, true /* KeepEmptyTokens */> it{
|
||||
row.begin(), row.end(), delimiter};
|
||||
it; ++it)
|
||||
{
|
||||
std::string_view column = *it;
|
||||
size_t const quotesCount = std::count(column.begin(), column.end(), '"');
|
||||
@@ -512,7 +512,7 @@ void ParseCSVRow(std::string const & row, char const delimiter, std::vector<std:
|
||||
target.emplace_back(column);
|
||||
else
|
||||
{
|
||||
std::string strColumn {column};
|
||||
std::string strColumn{column};
|
||||
target.push_back(UnescapeCSVColumn(strColumn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "base/checked_cast.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <charconv>
|
||||
#include <cerrno>
|
||||
#include <charconv>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
@@ -39,8 +39,7 @@ public:
|
||||
|
||||
template <typename Iter>
|
||||
UniString(Iter b, Iter e) : BaseT(b, e)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool IsEqualAscii(char const * s) const;
|
||||
|
||||
@@ -133,17 +132,25 @@ std::string ToUtf8(UniString const & s);
|
||||
std::u16string ToUtf16(std::string_view utf8);
|
||||
bool IsASCIIString(std::string_view sv);
|
||||
bool IsASCIIDigit(UniChar c);
|
||||
template <class StringT> bool IsASCIINumeric(StringT const & str)
|
||||
template <class StringT>
|
||||
bool IsASCIINumeric(StringT const & str)
|
||||
{
|
||||
return !std::empty(str) && std::all_of(std::begin(str), std::end(str), &IsASCIIDigit);
|
||||
}
|
||||
inline bool IsASCIINumeric(char const * s) { return IsASCIINumeric(std::string_view(s)); }
|
||||
inline bool IsASCIINumeric(char const * s)
|
||||
{
|
||||
return IsASCIINumeric(std::string_view(s));
|
||||
}
|
||||
bool IsASCIISpace(UniChar c);
|
||||
bool IsASCIILatin(UniChar c);
|
||||
|
||||
inline std::string DebugPrint(UniString const & s) { return ToUtf8(s); }
|
||||
inline std::string DebugPrint(UniString const & s)
|
||||
{
|
||||
return ToUtf8(s);
|
||||
}
|
||||
|
||||
template <typename DelimFn, typename Iter> class TokenizeIteratorBase
|
||||
template <typename DelimFn, typename Iter>
|
||||
class TokenizeIteratorBase
|
||||
{
|
||||
public:
|
||||
using difference_type = std::ptrdiff_t;
|
||||
@@ -152,15 +159,23 @@ public:
|
||||
// Hack to get buffer pointer from any iterator.
|
||||
// Deliberately made non-static to simplify the call like this->ToCharPtr.
|
||||
char const * ToCharPtr(char const * p) const { return p; }
|
||||
template <class T> auto ToCharPtr(T const & i) const { return ToCharPtr(i.base()); }
|
||||
template <class T>
|
||||
auto ToCharPtr(T const & i) const
|
||||
{
|
||||
return ToCharPtr(i.base());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DelimFn, typename Iter, bool KeepEmptyTokens = false>
|
||||
class TokenizeIterator : public TokenizeIteratorBase<DelimFn, Iter>
|
||||
{
|
||||
public:
|
||||
template <class InIterT> TokenizeIterator(InIterT beg, InIterT end, DelimFn const & delimFn)
|
||||
: m_start(beg), m_end(beg), m_finish(end), m_delimFn(delimFn)
|
||||
template <class InIterT>
|
||||
TokenizeIterator(InIterT beg, InIterT end, DelimFn const & delimFn)
|
||||
: m_start(beg)
|
||||
, m_end(beg)
|
||||
, m_finish(end)
|
||||
, m_delimFn(delimFn)
|
||||
{
|
||||
Move();
|
||||
}
|
||||
@@ -233,8 +248,13 @@ template <typename DelimFn, typename Iter>
|
||||
class TokenizeIterator<DelimFn, Iter, true /* KeepEmptyTokens */> : public TokenizeIteratorBase<DelimFn, Iter>
|
||||
{
|
||||
public:
|
||||
template <class InIterT> TokenizeIterator(InIterT beg, InIterT end, DelimFn const & delimFn)
|
||||
: m_start(beg), m_end(beg), m_finish(end), m_delimFn(delimFn), m_finished(false)
|
||||
template <class InIterT>
|
||||
TokenizeIterator(InIterT beg, InIterT end, DelimFn const & delimFn)
|
||||
: m_start(beg)
|
||||
, m_end(beg)
|
||||
, m_finish(end)
|
||||
, m_delimFn(delimFn)
|
||||
, m_finished(false)
|
||||
{
|
||||
while (m_end != m_finish && !m_delimFn(*m_end))
|
||||
++m_end;
|
||||
@@ -261,10 +281,7 @@ public:
|
||||
if (!*this && !rhs)
|
||||
return true;
|
||||
if (*this && rhs)
|
||||
{
|
||||
return m_start == rhs.m_start && m_end == rhs.m_end && m_finish == rhs.m_finish &&
|
||||
m_finished == rhs.m_finished;
|
||||
}
|
||||
return m_start == rhs.m_start && m_end == rhs.m_end && m_finish == rhs.m_finish && m_finished == rhs.m_finished;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -322,15 +339,16 @@ public:
|
||||
bool operator()(UniChar c) const;
|
||||
};
|
||||
|
||||
template <class StringT> class SimpleTokenizer : public
|
||||
TokenizeIterator<SimpleDelimiter, ::utf8::unchecked::iterator<typename StringT::const_iterator>, false /* KeepEmptyTokens */>
|
||||
template <class StringT>
|
||||
class SimpleTokenizer
|
||||
: public TokenizeIterator<SimpleDelimiter, ::utf8::unchecked::iterator<typename StringT::const_iterator>,
|
||||
false /* KeepEmptyTokens */>
|
||||
{
|
||||
using BaseT = TokenizeIterator<SimpleDelimiter, ::utf8::unchecked::iterator<typename StringT::const_iterator>, false /* KeepEmptyTokens */>;
|
||||
using BaseT = TokenizeIterator<SimpleDelimiter, ::utf8::unchecked::iterator<typename StringT::const_iterator>,
|
||||
false /* KeepEmptyTokens */>;
|
||||
|
||||
public:
|
||||
SimpleTokenizer(StringT const & str, SimpleDelimiter const & delims)
|
||||
: BaseT(str.begin(), str.end(), delims)
|
||||
{
|
||||
}
|
||||
SimpleTokenizer(StringT const & str, SimpleDelimiter const & delims) : BaseT(str.begin(), str.end(), delims) {}
|
||||
};
|
||||
|
||||
template <typename TFunctor>
|
||||
@@ -364,22 +382,19 @@ UniChar LastUniChar(std::string const & s);
|
||||
//@{
|
||||
namespace internal
|
||||
{
|
||||
template <typename T, typename = std::enable_if_t<std::is_signed<T>::value &&
|
||||
sizeof(T) < sizeof(long long)>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_signed<T>::value && sizeof(T) < sizeof(long long)>>
|
||||
long IntConverter(char const * start, char ** stop, int base)
|
||||
{
|
||||
return std::strtol(start, stop, base);
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value &&
|
||||
sizeof(T) < sizeof(unsigned long long)>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value && sizeof(T) < sizeof(unsigned long long)>>
|
||||
unsigned long IntConverter(char const * start, char ** stop, int base)
|
||||
{
|
||||
return std::strtoul(start, stop, base);
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_signed<T>::value &&
|
||||
sizeof(T) == sizeof(long long)>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_signed<T>::value && sizeof(T) == sizeof(long long)>>
|
||||
long long IntConverter(char const * start, char ** stop, int base)
|
||||
{
|
||||
#ifdef OMIM_OS_WINDOWS_NATIVE
|
||||
@@ -389,8 +404,8 @@ long long IntConverter(char const * start, char ** stop, int base)
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_unsigned<T>::value &&
|
||||
sizeof(T) == sizeof(unsigned long long)>>
|
||||
template <typename T,
|
||||
typename = std::enable_if_t<std::is_unsigned<T>::value && sizeof(T) == sizeof(unsigned long long)>>
|
||||
unsigned long long IntConverter(char const * start, char ** stop, int base)
|
||||
{
|
||||
#ifdef OMIM_OS_WINDOWS_NATIVE
|
||||
@@ -400,8 +415,7 @@ unsigned long long IntConverter(char const * start, char ** stop, int base)
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T,
|
||||
typename = std::enable_if_t<std::is_integral<T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
|
||||
bool ToInteger(char const * start, T & result, int base = 10)
|
||||
{
|
||||
char * stop;
|
||||
@@ -409,8 +423,7 @@ bool ToInteger(char const * start, T & result, int base = 10)
|
||||
|
||||
auto const v = IntConverter<T>(start, &stop, base);
|
||||
|
||||
if (errno == EINVAL || errno == ERANGE || *stop != 0 || start == stop ||
|
||||
!base::IsCastValid<T>(v))
|
||||
if (errno == EINVAL || errno == ERANGE || *stop != 0 || start == stop || !base::IsCastValid<T>(v))
|
||||
{
|
||||
errno = 0;
|
||||
return false;
|
||||
@@ -512,19 +525,19 @@ bool ToInteger(char const * start, T & result, int base = 10)
|
||||
return to_double(s.c_str(), d);
|
||||
}
|
||||
|
||||
|
||||
namespace impl
|
||||
{
|
||||
template <typename T> bool from_sv(std::string_view sv, T & t)
|
||||
template <typename T>
|
||||
bool from_sv(std::string_view sv, T & t)
|
||||
{
|
||||
auto const end = sv.data() + sv.size();
|
||||
auto const res = std::from_chars(sv.data(), end, t);
|
||||
return (res.ec != std::errc::invalid_argument && res.ec != std::errc::result_out_of_range &&
|
||||
res.ptr == end);
|
||||
return (res.ec != std::errc::invalid_argument && res.ec != std::errc::result_out_of_range && res.ptr == end);
|
||||
}
|
||||
} // namespace impl
|
||||
} // namespace impl
|
||||
|
||||
template <class T> inline bool to_uint(std::string_view sv, T & i)
|
||||
template <class T>
|
||||
inline bool to_uint(std::string_view sv, T & i)
|
||||
{
|
||||
static_assert(std::is_unsigned<T>::value, "");
|
||||
return impl::from_sv(sv, i);
|
||||
@@ -537,11 +550,16 @@ inline bool to_double(std::string_view sv, double & d)
|
||||
}
|
||||
//@}
|
||||
|
||||
|
||||
/// @name From numeric to string.
|
||||
//@{
|
||||
inline std::string to_string(std::string const & s) { return s; }
|
||||
inline std::string to_string(char const * s) { return s; }
|
||||
inline std::string to_string(std::string const & s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
inline std::string to_string(char const * s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
template <typename T>
|
||||
std::string to_string(T t)
|
||||
{
|
||||
@@ -556,17 +574,32 @@ template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
|
||||
return internal::ToInteger(s.c_str(), i);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool to_any(std::string const & s, float & f) { return to_float(s, f); }
|
||||
[[nodiscard]] inline bool to_any(std::string const & s, double & d) { return to_double(s, d); }
|
||||
[[nodiscard]] inline bool to_any(std::string const & s, float & f)
|
||||
{
|
||||
return to_float(s, f);
|
||||
}
|
||||
[[nodiscard]] inline bool to_any(std::string const & s, double & d)
|
||||
{
|
||||
return to_double(s, d);
|
||||
}
|
||||
[[nodiscard]] inline bool to_any(std::string const & s, std::string & result)
|
||||
{
|
||||
result = s;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string to_string(int32_t i) { return std::to_string(i); }
|
||||
inline std::string to_string(int64_t i) { return std::to_string(i); }
|
||||
inline std::string to_string(uint64_t i) { return std::to_string(i); }
|
||||
inline std::string to_string(int32_t i)
|
||||
{
|
||||
return std::to_string(i);
|
||||
}
|
||||
inline std::string to_string(int64_t i)
|
||||
{
|
||||
return std::to_string(i);
|
||||
}
|
||||
inline std::string to_string(uint64_t i)
|
||||
{
|
||||
return std::to_string(i);
|
||||
}
|
||||
/// Use this function to get string with fixed count of
|
||||
/// "Digits after comma".
|
||||
std::string to_string_dac(double d, int dac);
|
||||
@@ -611,8 +644,8 @@ bool IsHTML(std::string const & utf8);
|
||||
bool AlmostEqual(std::string const & str1, std::string const & str2, size_t mismatchedCount);
|
||||
|
||||
template <typename Iterator, typename Delimiter>
|
||||
typename std::iterator_traits<Iterator>::value_type
|
||||
JoinStrings(Iterator begin, Iterator end, Delimiter const & delimiter)
|
||||
typename std::iterator_traits<Iterator>::value_type JoinStrings(Iterator begin, Iterator end,
|
||||
Delimiter const & delimiter)
|
||||
{
|
||||
if (begin == end)
|
||||
return {};
|
||||
|
||||
@@ -23,8 +23,7 @@ bool LEQ(size_t a1, size_t a2, size_t a3, size_t b1, size_t b2, size_t b3)
|
||||
// Actually this is a counting sort, but the name RadixSort is used
|
||||
// here to keep the correspondence with the article about Skew|DC3.
|
||||
template <typename Values>
|
||||
void RadixSort(size_t numKeys, size_t const * keys, size_t numValues, Values const & values,
|
||||
size_t * resultKeys)
|
||||
void RadixSort(size_t numKeys, size_t const * keys, size_t numValues, Values const & values, size_t * resultKeys)
|
||||
{
|
||||
std::vector<size_t> count(numValues, 0);
|
||||
for (size_t i = 0; i < numKeys; ++i)
|
||||
@@ -39,7 +38,10 @@ void RadixSort(size_t numKeys, size_t const * keys, size_t numValues, Values con
|
||||
resultKeys[--count[values[keys[i]]]] = keys[i];
|
||||
}
|
||||
|
||||
bool InLeftHalf(size_t middle, size_t pos) { return pos < middle; }
|
||||
bool InLeftHalf(size_t middle, size_t pos)
|
||||
{
|
||||
return pos < middle;
|
||||
}
|
||||
|
||||
size_t RestoreIndex(size_t middle, size_t pos)
|
||||
{
|
||||
@@ -128,10 +130,8 @@ void RawSkew(size_t n, size_t maxValue, S const & s, size_t * sa)
|
||||
// should be the same as the number of =0 (mod 3) suffixes. That's
|
||||
// why we need that s[n] = s[n + 1] = s[n + 2] = 0.
|
||||
for (size_t i = 0, j = 0; i < n + fake1; ++i)
|
||||
{
|
||||
if (i % 3 != 0)
|
||||
s12[j++] = i;
|
||||
}
|
||||
|
||||
// Following three lines perform a stable sorting of all triples
|
||||
// <s[i], s[i + 1], s[i + 2]> where i =(1|2) (mod 3), including
|
||||
@@ -187,10 +187,8 @@ void RawSkew(size_t n, size_t maxValue, S const & s, size_t * sa)
|
||||
std::vector<size_t> s0(n0);
|
||||
std::vector<size_t> sa0(n0);
|
||||
for (size_t i = 0, j = 0; i < n02; ++i)
|
||||
{
|
||||
if (sa12[i] < n0)
|
||||
s0[j++] = 3 * sa12[i];
|
||||
}
|
||||
|
||||
// s0 is pre-sorted now in accordance with their tails (=1 (mod 3)
|
||||
// suffixes). For full sorting we need to do a stable sort =0 (mod
|
||||
@@ -211,10 +209,9 @@ void RawSkew(size_t n, size_t maxValue, S const & s, size_t * sa)
|
||||
size_t const p12 = RestoreIndex(n0, sa12[i12]);
|
||||
ASSERT_LESS(p12 / 3, n0, ());
|
||||
|
||||
bool const isLEQ =
|
||||
InLeftHalf(n0, sa12[i12])
|
||||
? LEQ(s[p12], s12[sa12[i12] + n0], s[p0], s12[p0 / 3])
|
||||
: LEQ(s[p12], s[p12 + 1], s12[sa12[i12] - n0 + 1], s[p0], s[p0 + 1], s12[p0 / 3 + n0]);
|
||||
bool const isLEQ = InLeftHalf(n0, sa12[i12])
|
||||
? LEQ(s[p12], s12[sa12[i12] + n0], s[p0], s12[p0 / 3])
|
||||
: LEQ(s[p12], s[p12 + 1], s12[sa12[i12] - n0 + 1], s[p0], s[p0 + 1], s12[p0 / 3 + n0]);
|
||||
|
||||
if (isLEQ)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace
|
||||
// civil = 96 degrees
|
||||
// nautical = 102 degrees
|
||||
// astronomical = 108 degrees
|
||||
double constexpr kZenith = 90 + 50. / 60.; // 90 degrees 50'
|
||||
double constexpr kZenith = 90 + 50. / 60.; // 90 degrees 50'
|
||||
|
||||
time_t constexpr kOneDaySeconds = 24 * 60 * 60;
|
||||
|
||||
@@ -83,9 +83,7 @@ enum class DayEventType
|
||||
// This function was taken from source http://williams.best.vwh.net/sunrise_sunset_algorithm.htm.
|
||||
// Notation is kept to have source close to source.
|
||||
// Original article is // http://babel.hathitrust.org/cgi/pt?id=uiug.30112059294311;view=1up;seq=25
|
||||
std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc,
|
||||
double latitude, double longitude,
|
||||
bool sunrise)
|
||||
std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc, double latitude, double longitude, bool sunrise)
|
||||
{
|
||||
tm const * const gmt = gmtime(&timeUtc);
|
||||
if (nullptr == gmt)
|
||||
@@ -124,13 +122,13 @@ std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc,
|
||||
|
||||
// 5a. calculate the Sun's right ascension
|
||||
|
||||
double RA = math::RadToDeg( atan(0.91764 * tan(math::DegToRad(L))) );
|
||||
double RA = math::RadToDeg(atan(0.91764 * tan(math::DegToRad(L))));
|
||||
// NOTE: RA potentially needs to be adjusted into the range [0,360) by adding/subtracting 360
|
||||
RA = NormalizeAngle(RA);
|
||||
|
||||
// 5b. right ascension value needs to be in the same quadrant as L
|
||||
|
||||
double const Lquadrant = (floor( L / 90)) * 90;
|
||||
double const Lquadrant = (floor(L / 90)) * 90;
|
||||
double const RAquadrant = (floor(RA / 90)) * 90;
|
||||
RA = RA + (Lquadrant - RAquadrant);
|
||||
|
||||
@@ -145,7 +143,8 @@ std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc,
|
||||
|
||||
// 7a. calculate the Sun's local hour angle
|
||||
|
||||
double cosH = (cos(math::DegToRad(kZenith)) - (sinDec * sin(math::DegToRad(latitude)))) / (cosDec * cos(math::DegToRad(latitude)));
|
||||
double cosH = (cos(math::DegToRad(kZenith)) - (sinDec * sin(math::DegToRad(latitude)))) /
|
||||
(cosDec * cos(math::DegToRad(latitude)));
|
||||
|
||||
// if cosH > 1 then sun is never rises on this location on specified date (polar night)
|
||||
// if cosH < -1 then sun is never sets on this location on specified date (polar day)
|
||||
@@ -156,7 +155,7 @@ std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc,
|
||||
int const s = sunrise ? 0 : 59;
|
||||
|
||||
return std::make_pair((cosH < -1) ? DayEventType::PolarDay : DayEventType::PolarNight,
|
||||
base::TimeGM(year, month, day, h, m, s));
|
||||
base::TimeGM(year, month, day, h, m, s));
|
||||
}
|
||||
|
||||
// 7b. finish calculating H and convert into hours
|
||||
@@ -195,15 +194,15 @@ std::pair<DayEventType, time_t> CalculateDayEventTime(time_t timeUtc,
|
||||
|
||||
// UT - is a hour with fractional part of date year/month/day, in range of [0;24)
|
||||
|
||||
int const h = floor(UT); // [0;24)
|
||||
int const m = floor((UT - h) * 60); // [0;60)
|
||||
int const s = fmod(floor(UT * 60 * 60) /* number of seconds from 0:0 to UT */, 60); // [0;60)
|
||||
int const h = floor(UT); // [0;24)
|
||||
int const m = floor((UT - h) * 60); // [0;60)
|
||||
int const s = fmod(floor(UT * 60 * 60) /* number of seconds from 0:0 to UT */, 60); // [0;60)
|
||||
|
||||
return std::make_pair(sunrise ? DayEventType::Sunrise : DayEventType::Sunset,
|
||||
base::TimeGM(year, month, day, h, m, s));
|
||||
base::TimeGM(year, month, day, h, m, s));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
DayTimeType GetDayTime(time_t timeUtc, double latitude, double longitude)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,7 @@ void RunRoutine(std::shared_ptr<IRoutine> routine)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Thread wrapper implementation
|
||||
|
||||
Thread::Thread()
|
||||
{
|
||||
}
|
||||
Thread::Thread() {}
|
||||
|
||||
Thread::~Thread()
|
||||
{
|
||||
@@ -83,11 +81,20 @@ void Thread::Join()
|
||||
m_thread.join();
|
||||
}
|
||||
|
||||
IRoutine * Thread::GetRoutine() { return m_routine.get(); }
|
||||
IRoutine * Thread::GetRoutine()
|
||||
{
|
||||
return m_routine.get();
|
||||
}
|
||||
|
||||
void Sleep(size_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); }
|
||||
void Sleep(size_t ms)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
|
||||
ThreadID GetCurrentThreadID() { return std::this_thread::get_id(); }
|
||||
ThreadID GetCurrentThreadID()
|
||||
{
|
||||
return std::this_thread::get_id();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// SimpleThread implementation
|
||||
|
||||
@@ -83,16 +83,14 @@ public:
|
||||
using native_handle_type = std::thread::native_handle_type;
|
||||
|
||||
SimpleThread() noexcept {}
|
||||
SimpleThread(SimpleThread && x) noexcept
|
||||
: m_thread(std::move(x.m_thread))
|
||||
{}
|
||||
SimpleThread(SimpleThread && x) noexcept : m_thread(std::move(x.m_thread)) {}
|
||||
|
||||
template <class Fn, class... Args>
|
||||
explicit SimpleThread(Fn && fn, Args &&... args)
|
||||
: m_thread(&SimpleThread::ThreadFunc, std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...))
|
||||
: m_thread(&SimpleThread::ThreadFunc, std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...))
|
||||
{}
|
||||
|
||||
SimpleThread & operator= (SimpleThread && x) noexcept
|
||||
SimpleThread & operator=(SimpleThread && x) noexcept
|
||||
{
|
||||
m_thread = std::move(x.m_thread);
|
||||
return *this;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
ThreadChecker::ThreadChecker() : m_id(std::this_thread::get_id()) {}
|
||||
|
||||
bool ThreadChecker::CalledOnOriginalThread() const { return std::this_thread::get_id() == m_id; }
|
||||
bool ThreadChecker::CalledOnOriginalThread() const
|
||||
{
|
||||
return std::this_thread::get_id() == m_id;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ private:
|
||||
DISALLOW_COPY_AND_MOVE(ThreadChecker);
|
||||
};
|
||||
|
||||
#define DECLARE_THREAD_CHECKER(threadCheckerName) ThreadChecker threadCheckerName
|
||||
#define DECLARE_THREAD_CHECKER(threadCheckerName) ThreadChecker threadCheckerName
|
||||
#define CHECK_THREAD_CHECKER(threadCheckerName, msg) CHECK(threadCheckerName.CalledOnOriginalThread(), msg)
|
||||
#define DECLARE_AND_CHECK_THREAD_CHECKER(msg) \
|
||||
{ \
|
||||
static const ThreadChecker threadChecker; \
|
||||
CHECK(threadChecker.CalledOnOriginalThread(), (msg)); \
|
||||
}
|
||||
#define DECLARE_AND_CHECK_THREAD_CHECKER(msg) \
|
||||
{ \
|
||||
static const ThreadChecker threadChecker; \
|
||||
CHECK(threadChecker.CalledOnOriginalThread(), (msg)); \
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace base
|
||||
{
|
||||
namespace
|
||||
@@ -17,11 +16,10 @@ typedef std::function<threads::IRoutine *()> TPopRoutineFn;
|
||||
class PoolRoutine : public threads::IRoutine
|
||||
{
|
||||
public:
|
||||
PoolRoutine(const TPopRoutineFn & popFn, const ThreadPool::TFinishRoutineFn & finishFn)
|
||||
PoolRoutine(TPopRoutineFn const & popFn, ThreadPool::TFinishRoutineFn const & finishFn)
|
||||
: m_popFn(popFn)
|
||||
, m_finishFn(finishFn)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
virtual void Do()
|
||||
{
|
||||
@@ -44,12 +42,12 @@ private:
|
||||
TPopRoutineFn m_popFn;
|
||||
ThreadPool::TFinishRoutineFn m_finishFn;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
class ThreadPool::Impl
|
||||
{
|
||||
public:
|
||||
Impl(size_t size, const TFinishRoutineFn & finishFn) : m_finishFn(finishFn), m_threads(size)
|
||||
Impl(size_t size, TFinishRoutineFn const & finishFn) : m_finishFn(finishFn), m_threads(size)
|
||||
{
|
||||
ASSERT_GREATER(size, 0, ());
|
||||
for (auto & thread : m_threads)
|
||||
@@ -59,10 +57,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~Impl()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
~Impl() { Stop(); }
|
||||
|
||||
void PushBack(threads::IRoutine * routine)
|
||||
{
|
||||
@@ -76,10 +71,7 @@ public:
|
||||
m_tasks.PushFront(routine);
|
||||
}
|
||||
|
||||
threads::IRoutine * PopFront()
|
||||
{
|
||||
return m_tasks.Front(true);
|
||||
}
|
||||
threads::IRoutine * PopFront() { return m_tasks.Front(true); }
|
||||
|
||||
void Stop()
|
||||
{
|
||||
@@ -109,8 +101,7 @@ private:
|
||||
std::vector<std::unique_ptr<threads::Thread>> m_threads;
|
||||
};
|
||||
|
||||
ThreadPool::ThreadPool(size_t size, const TFinishRoutineFn & finishFn)
|
||||
: m_impl(new Impl(size, finishFn)) {}
|
||||
ThreadPool::ThreadPool(size_t size, TFinishRoutineFn const & finishFn) : m_impl(new Impl(size, finishFn)) {}
|
||||
|
||||
ThreadPool::~ThreadPool()
|
||||
{
|
||||
@@ -132,4 +123,4 @@ void ThreadPool::Stop()
|
||||
m_impl->Stop();
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace base
|
||||
class ThreadPool
|
||||
{
|
||||
public:
|
||||
typedef std::function<void (threads::IRoutine *)> TFinishRoutineFn;
|
||||
typedef std::function<void(threads::IRoutine *)> TFinishRoutineFn;
|
||||
|
||||
ThreadPool(size_t size, const TFinishRoutineFn & finishFn);
|
||||
ThreadPool(size_t size, TFinishRoutineFn const & finishFn);
|
||||
~ThreadPool();
|
||||
|
||||
// ThreadPool will not delete routine. You can delete it in TFinishRoutineFn.
|
||||
@@ -33,4 +33,4 @@ private:
|
||||
Impl * m_impl;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -63,8 +63,7 @@ public:
|
||||
auto Submit(F && func, Args &&... args) -> std::future<decltype(func(args...))>
|
||||
{
|
||||
using ResultType = decltype(func(args...));
|
||||
std::packaged_task<ResultType()> task(std::bind(std::forward<F>(func),
|
||||
std::forward<Args>(args)...));
|
||||
std::packaged_task<ResultType()> task(std::bind(std::forward<F>(func), std::forward<Args>(args)...));
|
||||
std::future<ResultType> result(task.get_future());
|
||||
{
|
||||
std::unique_lock lock(m_mutex);
|
||||
@@ -128,9 +127,7 @@ private:
|
||||
FunctionType task;
|
||||
{
|
||||
std::unique_lock lock(m_mutex);
|
||||
m_condition.wait(lock, [&] {
|
||||
return m_done || !m_queue.empty();
|
||||
});
|
||||
m_condition.wait(lock, [&] { return m_done || !m_queue.empty(); });
|
||||
|
||||
if (m_done && m_queue.empty())
|
||||
return;
|
||||
@@ -154,4 +151,4 @@ private:
|
||||
ThreadsJoiner<> m_joiner;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -52,7 +52,8 @@ TaskLoop::PushResult DelayedThreadPool::PushDelayed(Duration const & delay, Task
|
||||
template <typename T>
|
||||
TaskLoop::PushResult DelayedThreadPool::AddImmediate(T && task)
|
||||
{
|
||||
return AddTask([&]() {
|
||||
return AddTask([&]()
|
||||
{
|
||||
auto const newId = MakeNextId(m_immediateLastId, kImmediateMinId, kImmediateMaxId);
|
||||
VERIFY(m_immediate.Emplace(newId, std::forward<T>(task)), ());
|
||||
m_immediateLastId = newId;
|
||||
@@ -64,7 +65,8 @@ template <typename T>
|
||||
TaskLoop::PushResult DelayedThreadPool::AddDelayed(Duration const & delay, T && task)
|
||||
{
|
||||
auto const when = Now() + delay;
|
||||
return AddTask([&]() {
|
||||
return AddTask([&]()
|
||||
{
|
||||
auto const newId = MakeNextId(m_delayedLastId, kDelayedMinId, kDelayedMaxId);
|
||||
m_delayed.Add(newId, std::make_shared<DelayedTask>(newId, when, std::forward<T>(task)));
|
||||
m_delayedLastId = newId;
|
||||
@@ -113,8 +115,7 @@ void DelayedThreadPool::ProcessTasks()
|
||||
{
|
||||
// When there are no delayed tasks in the queue, we need to
|
||||
// wait until there is at least one immediate or delayed task.
|
||||
m_cv.wait(lk,
|
||||
[this]() { return m_shutdown || !m_immediate.IsEmpty() || !m_delayed.IsEmpty(); });
|
||||
m_cv.wait(lk, [this]() { return m_shutdown || !m_immediate.IsEmpty() || !m_delayed.IsEmpty(); });
|
||||
}
|
||||
|
||||
if (m_shutdown)
|
||||
@@ -135,8 +136,7 @@ void DelayedThreadPool::ProcessTasks()
|
||||
}
|
||||
|
||||
auto const canExecImmediate = !m_immediate.IsEmpty();
|
||||
auto const canExecDelayed =
|
||||
!m_delayed.IsEmpty() && Now() >= m_delayed.GetFirstValue()->m_when;
|
||||
auto const canExecDelayed = !m_delayed.IsEmpty() && Now() >= m_delayed.GetFirstValue()->m_when;
|
||||
|
||||
if (canExecImmediate)
|
||||
{
|
||||
@@ -152,10 +152,8 @@ void DelayedThreadPool::ProcessTasks()
|
||||
}
|
||||
|
||||
for (auto const & task : tasks)
|
||||
{
|
||||
if (task)
|
||||
task();
|
||||
}
|
||||
}
|
||||
|
||||
for (; !pendingImmediate.IsEmpty(); pendingImmediate.PopFront())
|
||||
@@ -194,13 +192,10 @@ bool DelayedThreadPool::Cancel(TaskId id)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (m_delayed.RemoveKey(id))
|
||||
{
|
||||
if (m_delayed.RemoveKey(id))
|
||||
{
|
||||
m_cv.notify_one();
|
||||
return true;
|
||||
}
|
||||
m_cv.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -221,10 +216,8 @@ void DelayedThreadPool::ShutdownAndJoin()
|
||||
{
|
||||
Shutdown(m_exit);
|
||||
for (auto & thread : m_threads)
|
||||
{
|
||||
if (thread.joinable())
|
||||
thread.join();
|
||||
}
|
||||
m_threads.clear();
|
||||
}
|
||||
|
||||
@@ -234,4 +227,4 @@ bool DelayedThreadPool::IsShutDown()
|
||||
return m_shutdown;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
@@ -90,12 +90,10 @@ private:
|
||||
struct DelayedTask
|
||||
{
|
||||
template <typename T>
|
||||
DelayedTask(TaskId id, TimePoint const & when, T && task)
|
||||
: m_id(id)
|
||||
, m_when(when)
|
||||
, m_task(std::forward<T>(task))
|
||||
{
|
||||
}
|
||||
DelayedTask(TaskId id, TimePoint const & when, T && task) : m_id(id)
|
||||
, m_when(when)
|
||||
, m_task(std::forward<T>(task))
|
||||
{}
|
||||
|
||||
bool operator<(DelayedTask const & rhs) const
|
||||
{
|
||||
@@ -120,9 +118,9 @@ private:
|
||||
using ImmediateQueue = LinkedMap<TaskId, Task>;
|
||||
|
||||
using DelayedValue = std::shared_ptr<DelayedTask>;
|
||||
class DelayedQueue : public BidirectionalMap<TaskId, DelayedValue,
|
||||
std::unordered_map, std::hash<TaskId>,
|
||||
std::multimap, DeRef<DelayedValue>>
|
||||
class DelayedQueue
|
||||
: public BidirectionalMap<TaskId, DelayedValue, std::unordered_map, std::hash<TaskId>, std::multimap,
|
||||
DeRef<DelayedValue>>
|
||||
{
|
||||
public:
|
||||
Value const & GetFirstValue() const
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
void WaitAndPop(T & value)
|
||||
{
|
||||
std::unique_lock lk(m_mutex);
|
||||
m_cond.wait(lk, [this]{ return !m_queue.empty(); });
|
||||
m_cond.wait(lk, [this] { return !m_queue.empty(); });
|
||||
value = std::move(m_queue.front());
|
||||
m_queue.pop();
|
||||
}
|
||||
@@ -52,7 +52,6 @@ public:
|
||||
value = std::move(m_queue.front());
|
||||
m_queue.pop();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Empty() const
|
||||
|
||||
@@ -16,16 +16,11 @@ public:
|
||||
void Join()
|
||||
{
|
||||
for (auto & thread : m_threads)
|
||||
{
|
||||
if (thread.joinable())
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
~ThreadsJoiner()
|
||||
{
|
||||
Join();
|
||||
}
|
||||
~ThreadsJoiner() { Join(); }
|
||||
|
||||
private:
|
||||
ThreadContainer & m_threads;
|
||||
@@ -38,7 +33,8 @@ class FunctionWrapper
|
||||
{
|
||||
public:
|
||||
template <typename F>
|
||||
FunctionWrapper(F && func) : m_impl(new ImplType<F>(std::move(func))) {}
|
||||
FunctionWrapper(F && func) : m_impl(new ImplType<F>(std::move(func)))
|
||||
{}
|
||||
|
||||
FunctionWrapper() = default;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
template <typename Fn>
|
||||
void ProcessList(Fn const & fn)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user