|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "UC_STD.H" |
|
17 |
|
18 EXPORT_C void TPagedSetToken::ExternalizeL(RWriteStream &aStream) const |
|
19 { |
|
20 __ASSERT_DEBUG(iCount>=0,User::Invariant()); |
|
21 TBtreeToken::ExternalizeL(aStream); |
|
22 aStream.WriteInt32L(iCount); |
|
23 } |
|
24 |
|
25 EXPORT_C void TPagedSetToken::InternalizeL(RReadStream &aStream) |
|
26 { |
|
27 TBtreeToken::InternalizeL(aStream); |
|
28 iCount=aStream.ReadInt32L(); |
|
29 if (iCount<0) |
|
30 __LEAVE(KErrCorrupt); |
|
31 } |
|
32 |
|
33 EXPORT_C void TPagedSetToken::Clear() |
|
34 { |
|
35 TBtreeToken::Clear(); |
|
36 iCount=0; |
|
37 } |
|
38 |
|
39 EXPORT_C TPagedSetBase::TPagedSetBase(TInt anEntrySize) |
|
40 // |
|
41 // Constructor creating a new set. |
|
42 // |
|
43 : iTree(EBtreeSecure,anEntrySize,anEntrySize),iKey(anEntrySize),iCount(0) |
|
44 {} |
|
45 |
|
46 EXPORT_C TPagedSetBase::TPagedSetBase(const TPagedSetToken &aToken,TInt anEntrySize) |
|
47 // |
|
48 // Constructor reinstating an existing set. |
|
49 // |
|
50 : iTree(aToken,EBtreeSecure,anEntrySize,anEntrySize),iKey(anEntrySize),iCount(aToken.iCount) |
|
51 {} |
|
52 |
|
53 EXPORT_C void TPagedSetBase::Connect(MPagePool *aPool) |
|
54 // |
|
55 // Hook the tree up to its bits. |
|
56 // |
|
57 { |
|
58 iTree.Connect(aPool,&iKey); |
|
59 } |
|
60 |
|
61 EXPORT_C void TPagedSetBase::Set(const TPagedSetToken &aToken) |
|
62 // |
|
63 // Set to the state described by aToken. |
|
64 // |
|
65 { |
|
66 iTree.Set(aToken,EBtreeSecure); |
|
67 iCount=aToken.iCount; |
|
68 } |
|
69 |
|
70 EXPORT_C TPagedSetToken TPagedSetBase::Token() const |
|
71 // |
|
72 // Build the streaming token for the set. |
|
73 // |
|
74 { |
|
75 return TPagedSetToken(iTree.Token(),iCount); |
|
76 } |
|
77 |
|
78 EXPORT_C TInt TPagedSetBase::RepairL() |
|
79 // |
|
80 // Repair a broken set. |
|
81 // |
|
82 { |
|
83 TInt count=RepairL(); |
|
84 iCount=count; |
|
85 return count; |
|
86 } |
|
87 |
|
88 EXPORT_C void TPagedSetBase::ClearL() |
|
89 // |
|
90 // Empty the set. |
|
91 // |
|
92 { |
|
93 iTree.ClearL(); |
|
94 iCount=0; |
|
95 } |
|
96 |
|
97 EXPORT_C TBool TPagedSetBase::ContainsL(const TAny *aPtr) const |
|
98 // |
|
99 // Return whether the set contains an entry equal to the one pointed to by aPtr. |
|
100 // |
|
101 { |
|
102 TBtreePos pos; |
|
103 return iTree.FindL(pos,aPtr); |
|
104 } |
|
105 |
|
106 EXPORT_C void TPagedSetBase::InsertL(const TAny *aPtr) |
|
107 // |
|
108 // Insert an entry into the set. |
|
109 // |
|
110 { |
|
111 TBtreePos pos; |
|
112 if (!iTree.InsertL(pos,aPtr)) |
|
113 __LEAVE(KErrAlreadyExists); // a duplicate |
|
114 // |
|
115 ++iCount; |
|
116 } |
|
117 |
|
118 EXPORT_C void TPagedSetBase::DeleteL(const TAny *aPtr) |
|
119 // |
|
120 // Delete an entry from the set. |
|
121 // |
|
122 { |
|
123 if (!iTree.DeleteL(aPtr)) |
|
124 __LEAVE(KErrNotFound); |
|
125 // |
|
126 --iCount; |
|
127 } |
|
128 |
|
129 EXPORT_C void TPagedSetBase::InsertAllowDuplicatesL(const TAny *aPtr) |
|
130 // |
|
131 // Insert an entry into the set, allow duplicates. |
|
132 // |
|
133 { |
|
134 TBtreePos pos; |
|
135 __DEBUG(TBool success=)iTree.InsertL(pos,aPtr,EAllowDuplicates); |
|
136 __ASSERT_DEBUG(success,User::Invariant()); |
|
137 ++iCount; |
|
138 } |
|
139 |
|
140 EXPORT_C TBool TPagedSetIterBase::ResetL() |
|
141 { |
|
142 return iTree->ResetL(iMark); |
|
143 } |
|
144 |
|
145 EXPORT_C TBool TPagedSetIterBase::NextL() |
|
146 { |
|
147 return iTree->NextL(iMark); |
|
148 } |
|
149 |
|
150 EXPORT_C void TPagedSetIterBase::ExtractAtL(TAny* aPtr) const |
|
151 { |
|
152 iTree->ExtractAtL(iMark,aPtr); |
|
153 } |
|
154 |
|
155 EXPORT_C TBool TPagedSetBiIterBase::FirstL() |
|
156 { |
|
157 return iTree->FirstL(iPos); |
|
158 } |
|
159 |
|
160 EXPORT_C TBool TPagedSetBiIterBase::LastL() |
|
161 { |
|
162 return iTree->LastL(iPos); |
|
163 } |
|
164 |
|
165 EXPORT_C TBool TPagedSetBiIterBase::NextL() |
|
166 { |
|
167 return iTree->NextL(iPos); |
|
168 } |
|
169 |
|
170 EXPORT_C TBool TPagedSetBiIterBase::PreviousL() |
|
171 { |
|
172 return iTree->PreviousL(iPos); |
|
173 } |
|
174 |
|
175 EXPORT_C void TPagedSetBiIterBase::ExtractAtL(TAny* aPtr) const |
|
176 { |
|
177 iTree->ExtractAtL(iPos,aPtr); |
|
178 } |
|
179 |