Skip to content

Commit

Permalink
Merge pull request arcaneframework#1629 from arcaneframework/dev/gg-r…
Browse files Browse the repository at this point in the history
…emove-base-class-of-iteminternalmap

Remove base class of 'ItemInternalMap'
  • Loading branch information
grospelliergilles authored Sep 12, 2024
2 parents 428c7f8 + d4962b7 commit 4d067e0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 35 deletions.
11 changes: 4 additions & 7 deletions arcane/src/arcane/mesh/ItemInternalMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Arcane::mesh

ItemInternalMap::
ItemInternalMap()
: BaseClass(5000,false)
: m_impl(5000, false)
{
}

Expand All @@ -57,13 +57,12 @@ notifyUniqueIdsChanged()
});
}

BaseClass& c = *this;
ENUMERATE_ITEM_INTERNAL_MAP_DATA2(nbid, c)
ENUMERATE_ITEM_INTERNAL_MAP_DATA2(nbid, m_impl)
{
nbid->setKey(nbid->value()->uniqueId().asInt64());
}

this->rehash();
m_impl.rehash();
}

/*---------------------------------------------------------------------------*/
Expand All @@ -73,9 +72,7 @@ void ItemInternalMap::
_changeLocalIds(ArrayView<ItemInternal*> items_internal,
ConstArrayView<Int32> old_to_new_local_ids)
{
BaseClass& c = *this;

ENUMERATE_ITEM_INTERNAL_MAP_DATA2(nbid, c)
ENUMERATE_ITEM_INTERNAL_MAP_DATA2(nbid, m_impl)
{
ItemInternal* item = nbid->value();
Int32 current_local_id = item->localId();
Expand Down
105 changes: 77 additions & 28 deletions arcane/src/arcane/mesh/ItemInternalMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,76 @@ namespace Arcane::mesh
* sont obsolètes et ne doivent pas être utilisées.
*/
class ItemInternalMap
: private HashTableMapT<Int64, ItemInternal*>
{
// Pour accès aux méthodes qui utilisent ItemInternal.
friend class DynamicMeshKindInfos;

private:

using BaseClass = HashTableMapT<Int64, ItemInternal*>;
using BaseData = BaseClass::Data;
using Impl = HashTableMapT<Int64, ItemInternal*>;
using BaseData = Impl::Data;

public:

using Data ARCANE_DEPRECATED_REASON("Y2024: Data type is internal to Arcane") = BaseClass::Data;
using Data ARCANE_DEPRECATED_REASON("Y2024: Data type is internal to Arcane") = Impl::Data;

public:

using BaseClass::add;
using BaseClass::clear;
using BaseClass::count;
using BaseClass::remove;
using BaseClass::hasKey;
using BaseClass::resize;
using ValueType = ItemInternal*;

public:

ItemInternalMap();

public:

/*!
* \brief Ajoute la valeur \a v correspondant à la clé \a key
*
* Si une valeur correspondant à \a id existe déjà, elle est remplacée.
*
* \retval true si la clé est ajoutée
* \retval false si la clé existe déjà et est remplacée
*/
bool add(Int64 key, ItemInternal* v)
{
return m_impl.add(key, v);
}

//! Supprime tous les éléments de la table
void clear()
{
return m_impl.clear();
}

//! Nombre d'éléments de la table
Int32 count() const
{
return m_impl.count();
}

/*!
* \brief Supprime la valeur associée à la clé \a key
*
* Lève une exception s'il n'y a pas de valeurs associées à la clé
*/
void remove(Int64 key)
{
m_impl.remove(key);
}

//! \a true si une valeur avec la clé \a id est présente
bool hasKey(Int64 key)
{
return m_impl.hasKey(key);
}

//! Redimensionne la table de hachage
void resize(Int32 new_size, bool use_prime = false)
{
m_impl.resize(new_size, use_prime);
}

/*!
* \brief Notifie que les numéros uniques des entités ont changés.
*
Expand All @@ -99,7 +140,7 @@ class ItemInternalMap
template <class Lambda> void
eachItem(const Lambda& lambda)
{
ConstArrayView<BaseData*> b = BaseClass::buckets();
ConstArrayView<BaseData*> b = m_impl.buckets();
for (Int32 k = 0, n = b.size(); k < n; ++k) {
BaseData* nbid = b[k];
for (; nbid; nbid = nbid->next()) {
Expand All @@ -108,20 +149,23 @@ class ItemInternalMap
}
}
//! Nombre de buckets
Int32 nbBucket() const { return BaseClass::buckets().size(); }
Int32 nbBucket() const
{
return m_impl.buckets().size();
}

public:

//! Retourne l'entité associée à \a key si trouvé ou l'entité nulle sinon
impl::ItemBase tryFind(Int64 key) const
{
const BaseData* d = BaseClass::lookup(key);
const BaseData* d = m_impl.lookup(key);
return (d ? impl::ItemBase(d->value()) : impl::ItemBase{});
}
//! Retourne le localId() associé à \a key si trouvé ou NULL_ITEM_LOCAL_ID sinon aucun
Int32 tryFindLocalId(Int64 key) const
{
const BaseData* d = BaseClass::lookup(key);
const BaseData* d = m_impl.lookup(key);
return (d ? d->value()->localId() : NULL_ITEM_LOCAL_ID);
}

Expand All @@ -132,7 +176,7 @@ class ItemInternalMap
*/
impl::ItemBase findItem(Int64 uid) const
{
return impl::ItemBase(BaseClass::lookupValue(uid));
return impl::ItemBase(m_impl.lookupValue(uid));
}

/*!
Expand All @@ -142,55 +186,60 @@ class ItemInternalMap
*/
Int32 findLocalId(Int64 uid) const
{
return BaseClass::lookupValue(uid)->localId();
return m_impl.lookupValue(uid)->localId();
}

private:

public:

ARCANE_DEPRECATED_REASON("Y2024: This method is internal to Arcane")
Data* lookup(Int64 key)
{
return BaseClass::lookup(key);
return m_impl.lookup(key);
}

ARCANE_DEPRECATED_REASON("Y2024: This method is internal to Arcane")
const Data* lookup(Int64 key) const
{
return BaseClass::lookup(key);
return m_impl.lookup(key);
}

ARCANE_DEPRECATED_REASON("Y2024: This method is internal to Arcane")
ConstArrayView<BaseData*> buckets() const { return BaseClass::buckets(); }
ConstArrayView<BaseData*> buckets() const
{
return m_impl.buckets();
}

ARCANE_DEPRECATED_REASON("This method is internal to Arcane")
BaseData* lookupAdd(Int64 id, ItemInternal* value, bool& is_add)
{
return BaseClass::lookupAdd(id, value, is_add);
return m_impl.lookupAdd(id, value, is_add);
}

ARCANE_DEPRECATED_REASON("Y2024: This method is internal to Arcane")
BaseData* lookupAdd(Int64 uid)
{
return BaseClass::lookupAdd(uid);
return m_impl.lookupAdd(uid);
}

ARCANE_DEPRECATED_REASON("Y2024: Use findItem() instead")
ItemInternal* lookupValue(Int64 uid) const
{
return BaseClass::lookupValue(uid);
return m_impl.lookupValue(uid);
}

ARCANE_DEPRECATED_REASON("Y2024: Use findItem() instead")
ItemInternal* operator[](Int64 uid) const
{
return BaseClass::lookupValue(uid);
return m_impl.lookupValue(uid);
}

private:

// Les 3 méthodes suivantes sont uniquement pour la
Impl m_impl;

private:

// Les trois méthodes suivantes sont uniquement pour la
// classe DynamicMeshKindInfos.

//! Change la valeurs des localId()
Expand All @@ -199,14 +248,14 @@ class ItemInternalMap

BaseData* _lookupAdd(Int64 id, ItemInternal* value, bool& is_add)
{
return BaseClass::lookupAdd(id, value, is_add);
return m_impl.lookupAdd(id, value, is_add);
}


//! Retourne l'entité associée à \a key si trouvé ou nullptr sinon
ItemInternal* _tryFindItemInternal(Int64 key) const
{
const BaseData* d = BaseClass::lookup(key);
const BaseData* d = m_impl.lookup(key);
return (d ? d->value() : nullptr);
}
};
Expand Down

0 comments on commit 4d067e0

Please sign in to comment.