Update contrib.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include "windowslider.h"
21 #include "../common/inlines.h"
23 TWindowSlider::TWindowSlider(const TInteger& aExp, TUint aWindowSize)
24 : iExp(aExp), iSize(aWindowSize)
28 TUint expLen = iExp.BitCount();
29 //These numbers are more or less arbitrary and can be tuned for empirical
30 //performance results if desired. It's a trade off between amount of
31 //precomputation (more if larger iSize) and number of iterations
32 //(more if smaller iSize). The current defaults were obtained
36 else if( expLen <= 24 )
38 else if( expLen <= 70 )
40 else if( expLen <= 197 )
42 else if( expLen <= 539 )
44 else if( expLen <= 1434 )
49 assert(iSize>=1 && iSize<=7);
52 void TWindowSlider::FindNextWindow(TUint aBegin)
54 assert(iExp.Bit(aBegin)); //initial bit must be 1
59 for(TInt i=aBegin; i>=0 && j<iSize; i--, j++)
61 TUint saveMask = WORD_BITS - j - 1;
62 temp |= iExp.Bit(i) << saveMask;
63 if( temp & (1 << saveMask) )
66 iValue |= temp; //last valid substring
70 iLength = aBegin - end + 1;
71 iValue >>= (WORD_BITS - iLength);