Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unordered_{map,set}: Remove unnecessary anonymous namespace #19

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 63 additions & 65 deletions test/stdgpu/unordered_map.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,87 +20,85 @@
#include <stdgpu/platform.h>


namespace

struct dummy
{
struct dummy
{
// no data in dummy
};
// no data in dummy
};


struct vec3int16
{
vec3int16() = default;

STDGPU_HOST_DEVICE
vec3int16(const std::int16_t x,
const std::int16_t y,
const std::int16_t z)
: x(x),
y(y),
z(z)
{

}

std::int16_t x = 0;
std::int16_t y = 0;
std::int16_t z = 0;
};

STDGPU_HOST_DEVICE bool
operator==(const vec3int16& lhs,
const vec3int16& rhs)
struct vec3int16
{
vec3int16() = default;

STDGPU_HOST_DEVICE
vec3int16(const std::int16_t x,
const std::int16_t y,
const std::int16_t z)
: x(x),
y(y),
z(z)
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
&& lhs.z == rhs.z;

}

struct less
{
inline STDGPU_HOST_DEVICE bool
operator()(const vec3int16& lhs,
const vec3int16& rhs) const
{
if (lhs.x < rhs.x) return true;
if (lhs.x > rhs.x) return false;
std::int16_t x = 0;
std::int16_t y = 0;
std::int16_t z = 0;
};

if (lhs.y < rhs.y) return true;
if (lhs.y > rhs.y) return false;
inline STDGPU_HOST_DEVICE bool
operator==(const vec3int16& lhs,
const vec3int16& rhs)
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
&& lhs.z == rhs.z;
}

if (lhs.z < rhs.z) return true;
if (lhs.z > rhs.z) return false;
struct less
{
inline STDGPU_HOST_DEVICE bool
operator()(const vec3int16& lhs,
const vec3int16& rhs) const
{
if (lhs.x < rhs.x) return true;
if (lhs.x > rhs.x) return false;

return true;
}
};
if (lhs.y < rhs.y) return true;
if (lhs.y > rhs.y) return false;

if (lhs.z < rhs.z) return true;
if (lhs.z > rhs.z) return false;

struct hash
{
inline STDGPU_HOST_DEVICE std::size_t
operator()(const vec3int16& key) const
{
return (static_cast<std::size_t>(key.x) * static_cast<std::size_t>(73856093u))
^ (static_cast<std::size_t>(key.y) * static_cast<std::size_t>(19349669u))
^ (static_cast<std::size_t>(key.z) * static_cast<std::size_t>(83492791u));
}
};


inline STDGPU_HOST_DEVICE stdgpu::unordered_map<vec3int16, dummy, hash>::value_type
key_to_value(const vec3int16& key)
{
return stdgpu::unordered_map<vec3int16, dummy, hash>::value_type(key, dummy());
return true;
}
};


inline STDGPU_HOST_DEVICE vec3int16
value_to_key(const stdgpu::unordered_map<vec3int16, dummy, hash>::value_type& value)
struct hash
{
inline STDGPU_HOST_DEVICE std::size_t
operator()(const vec3int16& key) const
{
return value.first;
return (static_cast<std::size_t>(key.x) * static_cast<std::size_t>(73856093u))
^ (static_cast<std::size_t>(key.y) * static_cast<std::size_t>(19349669u))
^ (static_cast<std::size_t>(key.z) * static_cast<std::size_t>(83492791u));
}
};


inline STDGPU_HOST_DEVICE stdgpu::unordered_map<vec3int16, dummy, hash>::value_type
key_to_value(const vec3int16& key)
{
return stdgpu::unordered_map<vec3int16, dummy, hash>::value_type(key, dummy());
}


inline STDGPU_HOST_DEVICE vec3int16
value_to_key(const stdgpu::unordered_map<vec3int16, dummy, hash>::value_type& value)
{
return value.first;
}


Expand Down
116 changes: 57 additions & 59 deletions test/stdgpu/unordered_set.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,83 +20,81 @@
#include <stdgpu/platform.h>


namespace

struct vec3int16
{
struct vec3int16
vec3int16() = default;

STDGPU_HOST_DEVICE
vec3int16(const std::int16_t x,
const std::int16_t y,
const std::int16_t z)
: x(x),
y(y),
z(z)
{
vec3int16() = default;

STDGPU_HOST_DEVICE
vec3int16(const std::int16_t x,
const std::int16_t y,
const std::int16_t z)
: x(x),
y(y),
z(z)
{

}
}

std::int16_t x = 0;
std::int16_t y = 0;
std::int16_t z = 0;
};
std::int16_t x = 0;
std::int16_t y = 0;
std::int16_t z = 0;
};


STDGPU_HOST_DEVICE bool
operator==(const vec3int16& lhs,
const vec3int16& rhs)
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
&& lhs.z == rhs.z;
}
inline STDGPU_HOST_DEVICE bool
operator==(const vec3int16& lhs,
const vec3int16& rhs)
{
return lhs.x == rhs.x
&& lhs.y == rhs.y
&& lhs.z == rhs.z;
}


struct less
struct less
{
inline STDGPU_HOST_DEVICE bool
operator()(const vec3int16& lhs,
const vec3int16& rhs) const
{
inline STDGPU_HOST_DEVICE bool
operator()(const vec3int16& lhs,
const vec3int16& rhs) const
{
if (lhs.x < rhs.x) return true;
if (lhs.x > rhs.x) return false;
if (lhs.x < rhs.x) return true;
if (lhs.x > rhs.x) return false;

if (lhs.y < rhs.y) return true;
if (lhs.y > rhs.y) return false;
if (lhs.y < rhs.y) return true;
if (lhs.y > rhs.y) return false;

if (lhs.z < rhs.z) return true;
if (lhs.z > rhs.z) return false;
if (lhs.z < rhs.z) return true;
if (lhs.z > rhs.z) return false;

return true;
}
};
return true;
}
};


struct hash
{
inline STDGPU_HOST_DEVICE std::size_t
operator()(const vec3int16& key) const
{
return (static_cast<std::size_t>(key.x) * static_cast<std::size_t>(73856093u))
^ (static_cast<std::size_t>(key.y) * static_cast<std::size_t>(19349669u))
^ (static_cast<std::size_t>(key.z) * static_cast<std::size_t>(83492791u));
}
};


inline STDGPU_HOST_DEVICE vec3int16
key_to_value(const vec3int16& key)
struct hash
{
inline STDGPU_HOST_DEVICE std::size_t
operator()(const vec3int16& key) const
{
return key;
return (static_cast<std::size_t>(key.x) * static_cast<std::size_t>(73856093u))
^ (static_cast<std::size_t>(key.y) * static_cast<std::size_t>(19349669u))
^ (static_cast<std::size_t>(key.z) * static_cast<std::size_t>(83492791u));
}
};


inline STDGPU_HOST_DEVICE vec3int16
value_to_key(const vec3int16& key)
{
return key;
}
inline STDGPU_HOST_DEVICE vec3int16
key_to_value(const vec3int16& key)
{
return key;
}


inline STDGPU_HOST_DEVICE vec3int16
value_to_key(const vec3int16& key)
{
return key;
}


Expand Down