summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-07-19 12:46:29 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-25 14:13:45 +0200
commit29ee386e41971a64874c508dbb09c76438b2d841 (patch)
tree402d991f2a1508ad53fe28b7bec49f914af5b26d /svl
parent73e7cef672d7b47c7e8a2feda9a1499ea001b9cb (diff)
Convert SvStringsISortDtor from an SV_DECL_PTRARR to a o3tl::sorted_vector
Change-Id: Ie1fa9b3cc2aef83ae9a82fbc110a08b2f298daef
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/svstdarr.hxx14
-rw-r--r--svl/source/memtools/svarray.cxx47
2 files changed, 15 insertions, 46 deletions
diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx
index 302ba85bd491..66fc0fd7a24b 100644
--- a/svl/inc/svl/svstdarr.hxx
+++ b/svl/inc/svl/svstdarr.hxx
@@ -28,15 +28,25 @@
***********************************************************************/
#include "svl/svldllapi.h"
-#include <svl/svarray.hxx>
#include <deque>
#include <tools/string.hxx>
+#include <o3tl/sorted_vector.hxx>
typedef String* StringPtr;
#ifndef _SVSTDARR_STRINGSISORTDTOR_DECL
-SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvStringsISortDtor, StringPtr, 1, SVL_DLLPUBLIC )
+
+struct SVL_DLLPUBLIC CompareSvStringsISortDtor
+{
+ bool operator()( String* const& lhs, String* const& rhs ) const;
+};
+class SVL_DLLPUBLIC SvStringsISortDtor : public o3tl::sorted_vector<String*, CompareSvStringsISortDtor >
+{
+public:
+ ~SvStringsISortDtor() { DeleteAndDestroyAll(); }
+};
+
#define _SVSTDARR_STRINGSISORTDTOR_DECL
#endif
diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx
index f99e0bd8ad38..98e7f2a93495 100644
--- a/svl/source/memtools/svarray.cxx
+++ b/svl/source/memtools/svarray.cxx
@@ -18,7 +18,7 @@
*/
#include <svl/svstdarr.hxx>
-#include <tools/debug.hxx>
+#include <svl/svarray.hxx>
SV_IMPL_VARARR(SvPtrarr,VoidPtr)
@@ -28,51 +28,10 @@ sal_uInt16 SvPtrarr::GetPos( const VoidPtr& aElement ) const
return ( n >= nA ? USHRT_MAX : n );
}
-// ---------------- strings -------------------------------------
-// Array with different Seek method
-_SV_IMPL_SORTAR_ALG( SvStringsISortDtor, StringPtr )
-void SvStringsISortDtor::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
+bool CompareSvStringsISortDtor::operator()( String* const& lhs, String* const& rhs ) const
{
- if( nL )
- {
- DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
- for( sal_uInt16 n=nP; n < nP + nL; n++ )
- delete *((StringPtr*)pData+n);
- SvPtrarr::Remove( nP, nL );
- }
-}
-sal_Bool SvStringsISortDtor::Seek_Entry( const StringPtr aE, sal_uInt16* pP ) const
-{
- register sal_uInt16 nO = SvStringsISortDtor_SAR::Count(),
- nM,
- nU = 0;
- if( nO > 0 )
- {
- nO--;
- while( nU <= nO )
- {
- nM = nU + ( nO - nU ) / 2;
- StringCompare eCmp = (*((StringPtr*)pData + nM))->
- CompareIgnoreCaseToAscii( *(aE) );
- if( COMPARE_EQUAL == eCmp )
- {
- if( pP ) *pP = nM;
- return sal_True;
- }
- else if( COMPARE_LESS == eCmp )
- nU = nM + 1;
- else if( nM == 0 )
- {
- if( pP ) *pP = nU;
- return sal_False;
- }
- else
- nO = nM - 1;
- }
- }
- if( pP ) *pP = nU;
- return sal_False;
+ return lhs->CompareIgnoreCaseToAscii( *rhs ) == COMPARE_LESS;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */