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