📄 e32hashtab.h
字号:
Free all memory used by this set.
Returns the set to the same state it had following construction.
*/
inline void Close()
{ RHashTableBase::Close(); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A pointer to the copy of the specified object in the set, if it
exists. The object may not be modified via this pointer.
NULL if the specified object is not a member of this set.
*/
inline const T* Find(const T& aKey) const
{ return (const T*)RHashTableBase::Find(&aKey, _FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A reference to the copy of the specified object in the set, if it
exists. The object may not be modified via this reference.
@leave KErrNotFound if the specified object is not a member of this set.
*/
inline const T& FindL(const T& aKey) const
{ return *(const T*)RHashTableBase::FindL(&aKey, _FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A pointer to the copy of the specified object in the set, if it
exists. The object may be modified via this pointer. Care should
be taken not to modify any parts of the object which are used by
either the hash function or the identity relation for this set.
If this is done the set may become inconsistent, resulting in
malfunctions and/or panics at a later time.
NULL if the specified object is not a member of this set.
*/
inline T* Find(const T& aKey)
{ return (T*)RHashTableBase::Find(&aKey, _FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A reference to the copy of the specified object in the set, if it
exists. The object may be modified via this reference. Care should
be taken not to modify any parts of the object which are used by
either the hash function or the identity relation for this set.
If this is done the set may become inconsistent, resulting in
malfunctions and/or panics at a later time.
@leave KErrNotFound if the specified object is not a member of this set.
*/
inline T& FindL(const T& aKey)
{ return *(T*)RHashTableBase::FindL(&aKey, _FOFF(SFullElement,iT)); }
/**
Insert an element into the set.
If the specified object is not currently a member of the set, a copy of the
object is added to the set and KErrNone is returned.
If the specified object is currently a member of the set, the existing copy
of the object is replaced by the provided object and KErrNone is
returned.
In both cases the object is copied bitwise into the set.
@param aKey The object of type T to add to the set.
@return KErrNone if the object was added successfully.
KErrNoMemory if memory could not be allocated to store
the copy of aKey.
*/
inline TInt Insert(const T& aKey)
{ return RHashTableBase::ValueInsert(&aKey, sizeof(T), 0, 0, 0); }
/**
Insert an element into the set.
If the specified object is not currently a member of the set, a copy of the
object is added to the set and KErrNone is returned.
If the specified object is currently a member of the set, the existing copy
of the object is replaced by the provided object and KErrNone is
returned.
In both cases the object is copied bitwise into the set.
@param aKey The object of type T to add to the set.
@leave KErrNoMemory if memory could not be allocated to store
the copy of aKey.
*/
inline void InsertL(const T& aKey)
{ RHashTableBase::ValueInsertL(&aKey, sizeof(T), 0, 0, 0); }
/**
Remove an element from the set.
@param aKey The object to be removed.
@return KErrNone if the object was removed successfully.
KErrNotFound if the object was not present in the set.
*/
inline TInt Remove(const T& aKey)
{ return RHashTableBase::Remove(&aKey); }
/**
Query the number of elements in the set.
@return The number of elements currently in the set.
*/
inline TInt Count() const
{ return RHashTableBase::Count(); }
/**
Expand the set to accommodate a specified number of elements.
If the set already has enough space for the specified number of elements, no
action is taken. Any elements already in the set are retained.
@param aCount The number of elements for which space should be allocated.
@return KErrNone if the operation completed successfully.
@return KErrNoMemory if sufficient memory could not be allocated.
*/
inline TInt Reserve(TInt aCount)
{ return RHashTableBase::Reserve(aCount); }
/**
Expand the set to accommodate a specified number of elements.
If the set already has enough space for the specified number of elements, no
action is taken. Any elements already in the set are retained.
@param aCount The number of elements for which space should be allocated.
@leave KErrNoMemory if sufficient memory could not be allocated.
*/
inline void ReserveL(TInt aCount)
{ RHashTableBase::ReserveL(aCount); }
};
/**
@publishedAll
@released
A templated class which allows iteration over the elements of a RHashSet<T>
class.
The set being iterated over may not be modified while an iteration is in progress
or the iteration operations may malfunction or panic.
@see RHashSet<T>
*/
template <class T>
class THashSetIter : public THashTableIterBase
{
private:
struct SFullElement /**< @internalComponent */
{
TUint32 iHash;
T iT;
};
public:
/**
Construct an iterator over the specified set.
The iterator starts at conceptual position one before the beginning of the list
being iterated.
@param aSet The set to be iterated over.
*/
inline THashSetIter(const RHashSet<T>& aSet)
: THashTableIterBase(aSet)
{}
/**
Reset the iterator to its initial state.
@param aSet The set to be iterated over.
*/
inline void Reset()
{ THashTableIterBase::Reset(); }
/**
Return the current position of the iterator.
@return A pointer to the set member corresponding to the current position of the
iterator.
NULL if the iterator has just been constructed or reset, or if it has
previously reached the end of an iteration.
*/
inline const T* Current() const
{ return (const T*)THashTableIterBase::Current(_FOFF(SFullElement,iT)); }
/**
Steps the iterator to the next position.
@return A pointer to the set member corresponding to the next position of the
iterator.
NULL if the iterator has exhausted all the available set elements.
*/
inline const T* Next()
{ return (const T*)THashTableIterBase::Next(_FOFF(SFullElement,iT)); }
/**
Removes the element at the current iterator position from the hash table.
If the iterator does not currently point to a valid element, no action is taken.
Note that the iterator position is not altered so it no longer points to a valid
element following the Remove(). It is illegal to call Current() on the iterator
after calling Remove() - the only legal operations are Reset() and Next().
*/
inline void RemoveCurrent()
{ THashTableIterBase::RemoveCurrent(); }
};
template <class T> class TPtrHashSetIter;
/**
@publishedAll
@released
A templated class which implements an unordered extensional set of objects of
type T using a probe-sequence hash table. The objects are not copied into the set
when they are added; rather the set stores pointers to the contained objects.
*/
template <class T>
class RPtrHashSet : public RHashTableBase
{
private:
friend class TPtrHashSetIter<T>;
struct SFullElement /**< @internalComponent */
{
TUint32 iHash;
T* iT;
};
public:
/**
Construct a set of objects of type T using a specified hash function and identity relation.
The set is initially empty.
@param aHash The hash function used to hash the objects of type T.
@param aIdentity The identity relation used to determine if two objects of type T
should be considered identical.
*/
inline RPtrHashSet(const THashFunction32<T>& aHash, const TIdentityRelation<T>& aIdentity)
: RHashTableBase(aHash, aIdentity, sizeof(SFullElement), 0)
{}
/**
Construct a set of objects of type T using a default hash function and identity relation.
The set is initially empty.
*/
inline RPtrHashSet()
: RHashTableBase(Defaults<T,EDefaultSpecifier_Normal>::Hash(), Defaults<T,EDefaultSpecifier_Normal>::Id(), sizeof(SFullElement), 0)
{}
/**
Free all memory used by this set.
Returns the set to the same state it had following construction.
*/
inline void Close()
{ RHashTableBase::Close(); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A pointer to the specified object, if it is in the set.
The object may not be modified via this pointer.
NULL if the specified object is not a member of this set.
*/
inline const T* Find(const T& aKey) const
{ return (const T*)RHashTableBase::Find(&aKey, -_FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A reference to the specified object, if it is in the set.
The object may not be modified via this reference.
@leave KErrNotFound if the specified object is not a member of this set.
*/
inline const T& FindL(const T& aKey) const
{ return *(const T*)RHashTableBase::FindL(&aKey, -_FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A pointer to the specified object, if it is in the set.
The object may be modified via this pointer. Care should
be taken not to modify any parts of the object which are used by
either the hash function or the identity relation for this set.
If this is done the set may become inconsistent, resulting in
malfunctions and/or panics at a later time.
NULL if the specified object is not a member of this set.
*/
inline T* Find(const T& aKey)
{ return (T*)RHashTableBase::Find(&aKey, -_FOFF(SFullElement,iT)); }
/**
Locate a specified element in the set.
@param aKey The object of type T to search for.
@return A reference to the specified object, if it is in the set.
The object may be modified via this reference. Care should
be taken not to modify any parts of the object which are used by
either the hash function or the identity relation for this set.
If this is done the set may become inconsistent, resulting in
malfunctions and/or panics at a later time.
@leave KErrNotFound if the specified object is not a member of this set.
*/
inline T& FindL(const T& aKey)
{ return *(T*)RHashTableBase::FindL(&aKey, -_FOFF(SFullElement,iT)); }
/**
Insert an element into the set.
If the specified object is not currently a member of the set, a pointer to the
object is added to the set and KErrNone is returned.
If the specified object is currently a member of the set, the existing pointer
to the object is replaced by the provided pointer and KErrNone is
returned.
In both cases only a pointer to the object is stored - the object is never copied.
@param aKey A pointer to the object of type T to add to the set.
@return KErrNone if the object was added successfully.
KErrNoMemory if memory could not be allocated to store
the pointer to the new object.
*/
inline TInt Insert(const T* aKey)
{ return RHashTableBase::PtrInsert(aKey, 0); }
/**
Insert an element into the set.
If the specified object is not currently a member of the set, a pointer to the
object is added to the set and KErrNone is returned.
If the specified object is currently a member of the set, the existing pointer
to the object is replaced by the provided pointer and KErrNone is
returned.
In both cases only a pointer to the object is stored - the object is never copied.
@param aKey A pointer to the object of type T to add to the set.
@leave KErrNoMemory if memory could not be allocated to store the pointer to the new object.
*/
inline void InsertL(const T* aKey)
{ RHashTableBase::PtrInsertL(aKey, 0); }
/**
Remove an element from the set.
@param aKey A pointer to the object to be removed.
@return KErrNone if the object was removed successfully.
KErrNotFound if the object was not present in the set.
*/
inline TInt Remove(const T* aKey)
{ return RHashTableBase::Remove(aKey); }
/**
Query the number of elements in the set.
@return The number of elements currently in the set.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -