sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * TWindowSlider class implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __WINDOWSLIDER_H__ sl@0: #define __WINDOWSLIDER_H__ sl@0: sl@0: #include sl@0: sl@0: class TInteger; sl@0: /** Utility class used by our fast exponentiation routines.\n\n sl@0: * See HAC 14.85 for an explanation of how window sliding helps speed things up. sl@0: * @internalComponent sl@0: */ sl@0: class TWindowSlider sl@0: { sl@0: public: sl@0: /** sl@0: * @param aExp The exponent you are using. sl@0: * @param aWindowSize The window size. Leave as default value for the sl@0: * constructor to pick a window size appropriate for the given aExp sl@0: * @internalComponent sl@0: */ sl@0: TWindowSlider(const TInteger& aExp, TUint aWindowSize=0); sl@0: /** sl@0: * Finds the next "window" as defined by HAC 14.85. The actual bitstring sl@0: * value is in iValue and it's length in iLength. These remain valid until sl@0: * the next call to FindNextWindow() sl@0: */ sl@0: void FindNextWindow(TUint aBegin); sl@0: inline TUint WindowSize(void) {return iSize;} sl@0: inline TUint Value(void) {return iValue;} sl@0: inline TUint Length(void) {return iLength;} sl@0: sl@0: private: sl@0: const TInteger& iExp; ///the exponent all this is being calculated on sl@0: TUint iSize; ///The size of the sliding window sl@0: TUint iValue; ///the value found by the most recent FindNextWindow() call sl@0: TUint iLength;///the bit length of the iValue sl@0: }; sl@0: sl@0: #endif