|
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * TWindowSlider class implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __WINDOWSLIDER_H__ |
|
26 #define __WINDOWSLIDER_H__ |
|
27 |
|
28 #include <e32std.h> |
|
29 |
|
30 class TInteger; |
|
31 /** Utility class used by our fast exponentiation routines.\n\n |
|
32 * See HAC 14.85 for an explanation of how window sliding helps speed things up. |
|
33 * @internalComponent |
|
34 */ |
|
35 class TWindowSlider |
|
36 { |
|
37 public: |
|
38 /** |
|
39 * @param aExp The exponent you are using. |
|
40 * @param aWindowSize The window size. Leave as default value for the |
|
41 * constructor to pick a window size appropriate for the given aExp |
|
42 * @internalComponent |
|
43 */ |
|
44 TWindowSlider(const TInteger& aExp, TUint aWindowSize=0); |
|
45 /** |
|
46 * Finds the next "window" as defined by HAC 14.85. The actual bitstring |
|
47 * value is in iValue and it's length in iLength. These remain valid until |
|
48 * the next call to FindNextWindow() |
|
49 */ |
|
50 void FindNextWindow(TUint aBegin); |
|
51 inline TUint WindowSize(void) {return iSize;} |
|
52 inline TUint Value(void) {return iValue;} |
|
53 inline TUint Length(void) {return iLength;} |
|
54 |
|
55 private: |
|
56 const TInteger& iExp; ///the exponent all this is being calculated on |
|
57 TUint iSize; ///The size of the sliding window |
|
58 TUint iValue; ///the value found by the most recent FindNextWindow() call |
|
59 TUint iLength;///the bit length of the iValue |
|
60 }; |
|
61 |
|
62 #endif |