|
1 /* |
|
2 * Copyright (c) 2002-2005 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 "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: Local iterator base class. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <EPos_LandmarksErrors.h> |
|
21 #include "EPos_CPosLmLocalIterator.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CPosLmLocalIterator::CPosLmLocalIterator() : |
|
29 CPosLmItemIterator() |
|
30 { |
|
31 } |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CPosLmLocalIterator::~CPosLmLocalIterator() |
|
37 { |
|
38 iIdArray.Close(); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 TPosLmItemId CPosLmLocalIterator::NextL() |
|
45 { |
|
46 if (iCurrent >= iIdArray.Count()) |
|
47 { |
|
48 return KPosLmNullItemId; |
|
49 } |
|
50 |
|
51 return iIdArray[iCurrent++]; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CPosLmLocalIterator::Reset() |
|
58 { |
|
59 iCurrent = 0; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 TUint CPosLmLocalIterator::NumOfItemsL() |
|
66 { |
|
67 return iIdArray.Count(); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CPosLmLocalIterator::GetItemIdsL( |
|
74 RArray<TPosLmItemId>& aIdArray, |
|
75 TInt aStartIndex, |
|
76 TInt aNumOfItems) |
|
77 { |
|
78 if (aStartIndex < 0 || aStartIndex >= iIdArray.Count() || |
|
79 aStartIndex + aNumOfItems > iIdArray.Count()) |
|
80 { |
|
81 Panic(KPosLandmarksClientPanic, |
|
82 EPosSpecifiedIntervalLiesOutsideIteratedSet); |
|
83 } |
|
84 |
|
85 aIdArray.Reset(); |
|
86 aIdArray.ReserveL( aNumOfItems ); // to avoid heap fragmentation |
|
87 for (TInt i = aStartIndex; i < aStartIndex + aNumOfItems; i++) |
|
88 { |
|
89 aIdArray.Append( iIdArray[i] ); |
|
90 } |
|
91 } |
|
92 |