Commit 1962ae87 authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

well_defined_hash

parent a225d4bd
......@@ -4197,6 +4197,21 @@ namespace fmwkng {
std::size_t mod_;
};
#pragma endregion
#pragma region hash
class well_defined_hash {
public:
using result_type = std::uint64_t;
result_type operator()(std::string_view s)
{
result_type h = 0;
for (auto c : s)
{
h = (h << 9) ^ (h >> 55) ^ std::uint8_t(c);
}
return h;
}
};
#pragma endregion
}
#endif
......@@ -160,7 +160,7 @@ namespace macromain {
using tag_category = fmwkng::result_tag_category;
static auto name() { return "output_hash"; }
static auto code_name() { return "macromain::output_hash"; }
using value_type = std::size_t;
using value_type = fmwkng::well_defined_hash::result_type;
};
struct root_config {
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(6098797632107618844U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17197085183543559838U),
}
},
{
......@@ -22,7 +22,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(400),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(5626602103339740094U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(13220193331699835243U),
}
},
{
......@@ -32,7 +32,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17091110401245677638U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(4410665444513865852U),
}
},
{
......@@ -42,7 +42,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(400),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(3793603356625390693U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(16473863340873376882U),
}
},
{
......@@ -52,7 +52,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(6098797632107618844U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17197085183543559838U),
}
},
{
......@@ -62,7 +62,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17091110401245677638U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(4410665444513865852U),
}
},
{
......@@ -72,7 +72,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(6098797632107618844U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17197085183543559838U),
}
},
{
......@@ -83,7 +83,7 @@ namespace macromain {
std::make_unique<fmwkng::impl::config_element<macromain::lines,fmwkng::impl::element_sense::OPEN>>(1600),
},
{
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(6098797632107618844U),
std::make_unique<fmwkng::impl::element_t<macromain::output_hash,fmwkng::impl::element_sense::CLOSE>>(17197085183543559838U),
}
},
};
......
......@@ -60,7 +60,7 @@ namespace macromain {
macrosol::macroprocessor< macrosol::policy_scalar> mp;
mg.rewind();
mg.advance(count<lines>(ctx5));
std::size_t h = 0;
fmwkng::well_defined_hash::result_type h = 0;
std::string output;
for (;;)
{
......@@ -70,7 +70,7 @@ namespace macromain {
output.clear();
auto rv2 = mp.process(*rv, output);
if (rv2)
h += std::hash<std::string>()(output);
h += fmwkng::well_defined_hash()(output);
}
if (stop_for_results(ctx5))
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment