xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
hash_code.hpp
Go to the documentation of this file.
1
4
#pragma once
5
#include "
collections/generic/helpers/hasher.hpp
"
6
#include "
object.hpp
"
7
9
namespace
xtd
{
26
class
hash_code
:
public
xtd::object
{
27
public
:
29
32
hash_code
() =
default
;
34
36
42
template
<
typename
type_t>
43
auto
add
(
const
type_t& value)
noexcept
->
hash_code
& {
44
hash_code_ = hash_combine(hash_code_,
xtd::collections::generic::helpers::hasher<type_t>
{}(value));
45
return
*
this
;
46
}
47
51
[[nodiscard]]
auto
equals
(
const
xtd::object
&
other
)
const
noexcept
->
bool
override
;
52
55
[[nodiscard]]
auto
get_hash_code
() const noexcept ->
xtd
::
usize
override;
56
60
[[nodiscard]] auto
to_hash_code
() const noexcept ->
xtd
::
usize
;
62
64
69
template<typename ...args_t>
70
[[nodiscard]] static auto
combine
(args_t... values) noexcept ->
xtd
::
usize
{
return
combine_iterator(generate_uniqueness_seed(), values...);}
72
73
private
:
74
template
<
typename
type_t,
typename
...args_t>
75
[[nodiscard]]
static
auto
combine_iterator(
xtd::usize
seed,
const
type_t& value, args_t... values)
noexcept
->
xtd::usize
{
return
combine_iterator(hash_combine(seed,
xtd::collections::generic::helpers::hasher<type_t>
{}(value)), values...);}
76
[[nodiscard]]
static
auto
combine_iterator(
xtd::usize
seed)
noexcept
->
xtd::usize
;
77
[[nodiscard]]
static
auto
hash_combine(
xtd::usize
seed,
xtd::usize
value)
noexcept
->
xtd::usize
;
78
[[nodiscard]]
static
auto
generate_uniqueness_seed() noexcept -> xtd::
usize
;
79
80
xtd::
usize
hash_code_ = generate_uniqueness_seed();
81
};
82
}
xtd::hash_code::combine
static auto combine(args_t... values) noexcept -> xtd::usize
Combines values into a hash code.
Definition
hash_code.hpp:70
xtd::hash_code::to_hash_code
auto to_hash_code() const noexcept -> xtd::usize
Calculates the final hash code after consecutive xtd::hash_code::add invocations.
xtd::hash_code::add
auto add(const type_t &value) noexcept -> hash_code &
Adds a single value to the hash code.
Definition
hash_code.hpp:43
xtd::hash_code::equals
auto equals(const xtd::object &other) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
xtd::hash_code::hash_code
hash_code()=default
Create a new instance of the class hash_code.
xtd::hash_code::get_hash_code
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
xtd::object
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition
object.hpp:45
xtd::usize
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition
usize.hpp:22
xtd::platform_id::other
@ other
The operating system is other.
Definition
platform_id.hpp:60
hasher.hpp
Contains xtd::collections::generic::helpers::hasher struct.
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
object.hpp
Contains xtd::object class.
xtd::collections::generic::helpers::hasher
Implements a function object for hashing data.
Definition
hasher.hpp:40
Generated on
for xtd by
Gammasoft
. All rights reserved.