diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:21:02 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:51:05 +0100 |
commit | f00967cf38ed0c2c197284391fc521825bb3c2ac (patch) | |
tree | d1505cfff1707c51a74ece3091dcc25afbc5d778 /include/tools/unqidx.hxx | |
parent | 4845155e0126571e4176819c5f27b76160146ce0 (diff) |
sal_uIntPtr/sal_uLong to Index (aka sal_uInt32) in UniqueIndex
Change-Id: I212cb3bb9d920741629fc4564bbd28b393e8fe00
Diffstat (limited to 'include/tools/unqidx.hxx')
-rw-r--r-- | include/tools/unqidx.hxx | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx index 03a30c6fe0f0..c783151c12b8 100644 --- a/include/tools/unqidx.hxx +++ b/include/tools/unqidx.hxx @@ -20,45 +20,52 @@ #define INCLUDED_TOOLS_UNQIDX_HXX #include <tools/toolsdllapi.h> -#include <tools/contnr.hxx> +#include <limits> #include <map> -#define UNIQUEINDEX_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND - class SAL_WARN_UNUSED TOOLS_DLLPUBLIC UniqueIndexImpl { +public: + typedef sal_uInt32 Index; + enum { + IndexNotFound = std::numeric_limits<Index>::max() + }; + private: - std::map<sal_uInt32, void*> maMap; - sal_uIntPtr nStartIndex; - sal_uIntPtr nUniqIndex; - sal_uIntPtr nCount; + std::map<Index, void*> maMap; + Index nStartIndex; + Index nUniqIndex; + Index nCount; public: - UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 ) + UniqueIndexImpl( Index _nStartIndex = 0 ) : maMap(), nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {} - sal_uIntPtr Insert( void* p ); + Index Insert( void* p ); // insert value with key, replacing existing entry if necessary - void* Remove( sal_uIntPtr aIndex ); - void* Get( sal_uIntPtr aIndex ) const; + void* Remove( Index aIndex ); + void* Get( Index aIndex ) const; - sal_uIntPtr GetIndexOf( void* p ) const; - sal_uIntPtr FirstIndex() const; - sal_uIntPtr LastIndex() const; - sal_uIntPtr NextIndex( sal_uIntPtr aCurrIndex ) const; + Index GetIndexOf( void* p ) const; + Index FirstIndex() const; + Index LastIndex() const; + Index NextIndex( Index aCurrIndex ) const; }; template<typename T> class UniqueIndex : private UniqueIndexImpl { public: - UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} + using UniqueIndexImpl::Index; + using UniqueIndexImpl::IndexNotFound; + + UniqueIndex<T>( Index _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} - sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); } - T* Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } - T* Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } - sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } + Index Insert(T* p) { return UniqueIndexImpl::Insert(p); } + T* Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } + T* Remove(Index idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } + Index GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } using UniqueIndexImpl::FirstIndex; using UniqueIndexImpl::LastIndex; |