12#ifndef ARCANE_CORE_GROUPINDEXTABLE_H
13#define ARCANE_CORE_GROUPINDEXTABLE_H
17#include "arcane/utils/HashTable.h"
32 friend class GroupIndexTable;
33 typedef Int32 KeyTypeValue;
34 typedef Int32 ValueType;
36 typedef KeyTraitsType::KeyTypeConstRef KeyTypeConstRef;
40 ARCCORE_HOST_DEVICE ValueType operator[](
Int32 i)
const {
return _lookup(i); }
41 ARCCORE_HOST_DEVICE
Int32 size()
const {
return m_key_buffer_span.size(); }
48 Int32 m_nb_bucket = 0;
55 return _lookupBucket(_hash(
id),
id);
57 ARCCORE_HOST_DEVICE
Int32 _hash(KeyTypeConstRef
id)
const
59 return static_cast<Int32>(KeyTraitsType::hashFunction(
id) % m_nb_bucket);
61 ARCCORE_HOST_DEVICE Integer _lookupBucket(Int32 bucket, KeyTypeConstRef
id)
const
63 for (Integer i = m_buckets_span[bucket]; i >= 0; i = m_next_buffer_span[i]) {
64 if (m_key_buffer_span[i] ==
id)
83class ARCANE_CORE_EXPORT GroupIndexTable
88 typedef Int32 KeyTypeValue;
89 typedef Int32 ValueType;
91 typedef KeyTraitsType::KeyTypeConstRef KeyTypeConstRef;
105 ValueType operator[](
Int32 i)
const {
return _lookup(i); }
107 KeyTypeValue keyLocalId(
Int32 i)
const {
return m_key_buffer[i]; }
109 Int32 size()
const {
return m_key_buffer.size(); }
113 ARCANE_ASSERT((
_initialized()), (
"GroupIndexTable not initialized"));
114 ARCANE_ASSERT((
_checkIntegrity(
false)), (
"GroupIndexTable integrity failed"));
128 ARCANE_ASSERT((
_initialized()), (
"GroupIndexTable not initialized"));
129 return m_view._hash(
id);
132 bool _hasKey(KeyTypeConstRef
id)
const;
137 ARCANE_ASSERT((
_initialized()), (
"GroupIndexTable not initialized"));
138 return m_view._lookupBucket(bucket,
id);
144 ARCANE_ASSERT((
_checkIntegrity(
false)), (
"GroupIndexTable integrity failed"));
149 bool _initialized()
const;
152 bool _checkIntegrity(
bool full =
true)
const;
__host__ __device__ Int32 _lookup(KeyTypeConstRef id) const
Search for a key in the entire table.
bool m_disable_check_integrity
Bucket array.
UniqueArray< Int32 > m_buckets
Associated next index table.
Int32 _hash(KeyTypeConstRef id) const
Hashing function.
bool _checkIntegrity(bool full=true) const
Tests the integrity of the table relative to its group.
UniqueArray< Int32 > m_next_buffer
Associated keys table.
Int32 _lookupBucket(Int32 bucket, KeyTypeConstRef id) const
Search for a key in a bucket.
Int32 _lookup(KeyTypeConstRef id) const
Search for a key in the entire table.
bool _initialized() const
Tests the initialization of the object.
HashTableBase(Integer table_size, bool use_prime)
Creates a table of size table_size.
Brief: Implementation of a mesh entity group.
View of an array of elements of type T.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.