You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
/**
|
|
* \file containers.h
|
|
* \brief CContainers
|
|
* \date 2012-04-10 13:57GMT
|
|
* \author Unknown (Unknown)
|
|
* CContainers
|
|
*/
|
|
|
|
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
|
|
// Copyright (C) 2012-2015 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#ifndef NLSOUND_CONTAINERS_H
|
|
#define NLSOUND_CONTAINERS_H
|
|
#include <nel/misc/types_nl.h>
|
|
|
|
// STL includes
|
|
|
|
// NeL includes
|
|
|
|
// Project includes
|
|
|
|
namespace NLSOUND {
|
|
class CSourceCommon;
|
|
|
|
/// Hasher functor for hashed container with pointer key.
|
|
template <class Pointer>
|
|
struct THashPtr : public std::unary_function<const Pointer &, size_t>
|
|
{
|
|
enum { bucket_size = 4, min_buckets = 8, };
|
|
size_t operator () (const Pointer &ptr) const
|
|
{
|
|
//CHashSet<uint>::hasher h;
|
|
// transtype the pointer into int then hash it
|
|
//return h.operator()(uint(uintptr_t(ptr)));
|
|
return (size_t)(uintptr_t)ptr;
|
|
}
|
|
inline bool operator() (const Pointer &ptr1, const Pointer &ptr2) const
|
|
{
|
|
// delegate the work to someone else as well?
|
|
return (uintptr_t)ptr1 < (uintptr_t)ptr2;
|
|
}
|
|
};
|
|
|
|
typedef CHashSet<CSourceCommon*, THashPtr<CSourceCommon*> > TSourceContainer;
|
|
|
|
} /* namespace NLSOUND */
|
|
|
|
#endif /* #ifndef NLSOUND_CONTAINERS_H */
|
|
|
|
/* end of file */
|