|
1 // Copyright (c) 2005-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 the License "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 // e32/euser/us_htab.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "us_std.h" |
|
19 #include <e32hashtab.h> |
|
20 |
|
21 const TUint KDefaultIndexBits = 4; |
|
22 const TUint KMaxIndexBits = 28; |
|
23 |
|
24 extern TUint32 DefaultIntegerHash(const TAny*); |
|
25 extern TUint32 DefaultStringHash(const TUint8*, TInt); |
|
26 extern TUint32 DefaultWStringHash(const TUint16*, TInt); |
|
27 |
|
28 #define _DEBUG_HASH_TABLE |
|
29 #ifndef _DEBUG |
|
30 #undef _DEBUG_HASH_TABLE |
|
31 #endif |
|
32 |
|
33 #define __PANIC(x) Panic(x) |
|
34 |
|
35 EXPORT_C RHashTableBase::RHashTableBase(TGeneralHashFunction32 aHash, TGeneralIdentityRelation aId, TInt aElementSize, TInt aKeyOffset) |
|
36 : iHashFunc(aHash), |
|
37 iIdFunc(aId), |
|
38 iIndexBits(TUint8(KDefaultIndexBits)), |
|
39 iGeneration(EGen0), |
|
40 iPad0(0), |
|
41 iElements(0), |
|
42 iCount(0), |
|
43 iPad1(0), |
|
44 iPad2(0) |
|
45 { |
|
46 __ASSERT_ALWAYS(aHash!=NULL, __PANIC(EHashTableNoHashFunc)); |
|
47 __ASSERT_ALWAYS(aId!=NULL, __PANIC(EHashTableNoIdentityRelation)); |
|
48 __ASSERT_ALWAYS(aElementSize>0, __PANIC(EHashTableBadElementSize)); |
|
49 __ASSERT_ALWAYS(aKeyOffset==0 || TUint(aKeyOffset-4)<(TUint)Min(252,aElementSize-4), __PANIC(EHashTableBadKeyOffset)); |
|
50 iElementSize = aElementSize; |
|
51 iKeyOffset = (TUint8)aKeyOffset; // 0 means ptr at offset 4 |
|
52 iEmptyCount = 0; |
|
53 SetThresholds(); |
|
54 } |
|
55 |
|
56 void RHashTableBase::SetThresholds() |
|
57 { |
|
58 TUint32 max = 1u << iIndexBits; |
|
59 if (iIndexBits == KMaxIndexBits) |
|
60 iUpperThreshold = KMaxTUint; |
|
61 else |
|
62 iUpperThreshold = (max>>1) + (max>>2); // 3/4 of max |
|
63 if (iIndexBits == KDefaultIndexBits) |
|
64 iLowerThreshold = 0; |
|
65 else |
|
66 iLowerThreshold = max >> 2; // 1/4 of max |
|
67 |
|
68 // clean table if <1/8 of entries empty |
|
69 iCleanThreshold = max>>3; |
|
70 } |
|
71 |
|
72 EXPORT_C void RHashTableBase::Close() |
|
73 { |
|
74 User::Free(iElements); |
|
75 new (this) RHashTableBase(iHashFunc, iIdFunc, iElementSize, iKeyOffset); |
|
76 } |
|
77 |
|
78 EXPORT_C TInt RHashTableBase::Count() const |
|
79 { |
|
80 return (TInt)iCount; |
|
81 } |
|
82 |
|
83 EXPORT_C TAny* RHashTableBase::Find(const TAny* aKey, TInt aOffset) const |
|
84 { |
|
85 if (!iElements) |
|
86 return NULL; |
|
87 TUint32 hash = (*iHashFunc)(aKey); |
|
88 TUint32 ix = hash >> (32 - iIndexBits); // top bits of hash used as initial index |
|
89 hash = (hash &~ EStateMask) | iGeneration; |
|
90 TUint32 mask = (1u << iIndexBits) - 1; // iIndexBits 1's |
|
91 TUint32 step = (hash >> 1) & mask; // iIndexBits-1 LSBs of hash followed by 1 |
|
92 FOREVER |
|
93 { |
|
94 const SElement* e = ElementC(ix); |
|
95 if (e->iHash==hash && (*iIdFunc)(aKey, GetKey(e))) |
|
96 { |
|
97 if (aOffset >= 0) |
|
98 return ((TUint8*)e) + aOffset; |
|
99 return *(TAny**)((TUint8*)e - aOffset); |
|
100 } |
|
101 if (e->IsEmpty()) |
|
102 break; |
|
103 ix = (ix + step) & mask; |
|
104 } |
|
105 return NULL; |
|
106 } |
|
107 |
|
108 EXPORT_C TAny* RHashTableBase::FindL(const TAny* aKey, TInt aOffset) const |
|
109 { |
|
110 TAny* p = Find(aKey, aOffset); |
|
111 if (!p) |
|
112 User::Leave(KErrNotFound); |
|
113 return p; |
|
114 } |
|
115 |
|
116 TInt RHashTableBase::Insert(const TAny* aKey, TAny*& aElement) |
|
117 { |
|
118 TInt r = KErrNone; |
|
119 TUint32 max = 1u << iIndexBits; |
|
120 if (!iElements) |
|
121 { |
|
122 iElements = User::AllocZ(max * iElementSize); |
|
123 if (!iElements) |
|
124 return KErrNoMemory; |
|
125 iEmptyCount = max; |
|
126 } |
|
127 else if (iCount > iUpperThreshold) |
|
128 { |
|
129 r = ExpandTable(iIndexBits+1); |
|
130 if (iEmptyCount>1) |
|
131 r = KErrNone; // doesn't matter if expand fails unless there is only one empty slot left |
|
132 max = 1u << iIndexBits; |
|
133 } |
|
134 else if (iEmptyCount < iCleanThreshold) |
|
135 ReformTable(iIndexBits); |
|
136 |
|
137 TUint32 hash = (*iHashFunc)(aKey); |
|
138 TUint32 ix = hash >> (32 - iIndexBits); |
|
139 TUint32 mask = max - 1; |
|
140 hash = (hash &~ EStateMask) | iGeneration; |
|
141 TUint32 step = (hash >> 1) & mask; // iIndexBits-1 LSBs of hash followed by 1 |
|
142 SElement* e = 0; |
|
143 SElement* d = 0; |
|
144 FOREVER |
|
145 { |
|
146 e = Element(ix); |
|
147 if (e->IsEmpty()) |
|
148 break; |
|
149 if (e->IsDeleted()) |
|
150 { |
|
151 if (!d) |
|
152 d = e; |
|
153 } |
|
154 else if (e->iHash==hash && (*iIdFunc)(aKey, GetKey(e))) |
|
155 { |
|
156 aElement = e; |
|
157 return KErrNone; // duplicate so always succeed |
|
158 } |
|
159 ix = (ix + step) & mask; |
|
160 } |
|
161 if (d) |
|
162 e = d; // if we can reuse a deleted slot, always succeed |
|
163 else |
|
164 { |
|
165 if (r!=KErrNone) |
|
166 return r; // new slot needed - if we failed to expand, fail the request here |
|
167 --iEmptyCount; |
|
168 } |
|
169 e->iHash = hash; |
|
170 aElement = e; |
|
171 ++iCount; |
|
172 return KErrNone; |
|
173 } |
|
174 |
|
175 EXPORT_C TInt RHashTableBase::PtrInsert(const TAny* aKey, const TAny* aValue) |
|
176 { |
|
177 const TAny** e; |
|
178 TInt r = Insert(aKey, (TAny*&)e); |
|
179 if (r==KErrNone) |
|
180 { |
|
181 e[1] = aKey; |
|
182 if (iElementSize>=12) |
|
183 e[2] = aValue; |
|
184 } |
|
185 return r; |
|
186 } |
|
187 |
|
188 EXPORT_C void RHashTableBase::PtrInsertL(const TAny* aKey, const TAny* aValue) |
|
189 { |
|
190 const TAny** e; |
|
191 User::LeaveIfError(Insert(aKey, (TAny*&)e)); |
|
192 e[1] = aKey; |
|
193 if (iElementSize>=12) |
|
194 e[2] = aValue; |
|
195 } |
|
196 |
|
197 EXPORT_C TInt RHashTableBase::ValueInsert(const TAny* aKey, TInt aKeySize, const TAny* aValue, TInt aValueOffset, TInt aValueSize) |
|
198 { |
|
199 TUint8* e; |
|
200 TInt r = Insert(aKey, (TAny*&)e); |
|
201 if (r==KErrNone) |
|
202 { |
|
203 memcpy(e+iKeyOffset, aKey, aKeySize); |
|
204 if (aValue) |
|
205 memcpy(e+aValueOffset, aValue, aValueSize); |
|
206 } |
|
207 return r; |
|
208 } |
|
209 |
|
210 EXPORT_C void RHashTableBase::ValueInsertL(const TAny* aKey, TInt aKeySize, const TAny* aValue, TInt aValueOffset, TInt aValueSize) |
|
211 { |
|
212 TUint8* e; |
|
213 User::LeaveIfError(Insert(aKey, (TAny*&)e)); |
|
214 memcpy(e+iKeyOffset, aKey, aKeySize); |
|
215 if (aValue) |
|
216 memcpy(e+aValueOffset, aValue, aValueSize); |
|
217 } |
|
218 |
|
219 EXPORT_C TInt RHashTableBase::Remove(const TAny* aKey) |
|
220 { |
|
221 SElement* e = (SElement*)Find(aKey); |
|
222 if (!e) |
|
223 return KErrNotFound; |
|
224 e->SetDeleted(); |
|
225 if (--iCount == 0) |
|
226 { |
|
227 Close(); |
|
228 return KErrNone; |
|
229 } |
|
230 if (iCount < iLowerThreshold) |
|
231 ShrinkTable(); |
|
232 return KErrNone; |
|
233 } |
|
234 |
|
235 void RHashTableBase::ReformTable(TUint aNewIndexBits) |
|
236 { |
|
237 if (!iElements) |
|
238 return; |
|
239 TUint32 max = 1u << iIndexBits; |
|
240 TUint32 newmax = 1u << aNewIndexBits; |
|
241 TUint32 newmask = newmax - 1; |
|
242 TUint32 ix = 0; |
|
243 TUint32 newsh = 32 - aNewIndexBits; |
|
244 iGeneration ^= 1; // change generation so we know which entries have been updated |
|
245 for (; ix < max; ++ix) |
|
246 { |
|
247 SElement* e = Element(ix); |
|
248 if (e->IsEmpty()) |
|
249 continue; // skip empty entries |
|
250 if (e->IsDeleted()) |
|
251 { |
|
252 e->SetEmpty(); // mark deleted entries as empty |
|
253 continue; |
|
254 } |
|
255 if ((e->iHash & EStateMask) == iGeneration) // entry has been processed so leave it alone |
|
256 continue; |
|
257 TUint32 pos = e->iHash >> newsh; |
|
258 if (pos == ix) |
|
259 { |
|
260 e->iHash ^= 1; // entry is in first position for its hash so leave it there |
|
261 continue; |
|
262 } |
|
263 TUint32 step = (e->iHash >> 1) & newmask; |
|
264 FOREVER |
|
265 { |
|
266 SElement* d = Element(pos); |
|
267 if (d->IsEmptyOrDeleted()) |
|
268 { |
|
269 memcpy(d, e, iElementSize); |
|
270 d->iHash &= ~EStateMask; |
|
271 d->iHash |= iGeneration; // mark it as processed |
|
272 e->SetEmpty(); // remove old entry |
|
273 break; |
|
274 } |
|
275 if ((d->iHash & EStateMask) != iGeneration) |
|
276 { |
|
277 if (pos == ix) |
|
278 { |
|
279 e->iHash ^= 1; // entry is already in correct position so leave it there |
|
280 break; |
|
281 } |
|
282 if ((d->iHash >> newsh) == pos) |
|
283 { |
|
284 // candidate for replacement is in correct position so leave it and look elsewhere |
|
285 d->iHash ^= 1; |
|
286 } |
|
287 else |
|
288 { |
|
289 Mem::Swap(d, e, iElementSize); // switch entries |
|
290 d->iHash ^= 1; // mark entry as processed |
|
291 --ix; // process current position again |
|
292 break; |
|
293 } |
|
294 } |
|
295 pos = (pos + step) & newmask; |
|
296 } |
|
297 } |
|
298 iIndexBits = (TUint8)aNewIndexBits; |
|
299 iEmptyCount = newmax - iCount; |
|
300 SetThresholds(); |
|
301 #ifdef _DEBUG_HASH_TABLE |
|
302 VerifyReform(); |
|
303 #endif |
|
304 } |
|
305 |
|
306 #ifdef _DEBUG_HASH_TABLE |
|
307 void RHashTableBase::VerifyReform() |
|
308 { |
|
309 TUint32 dcount; |
|
310 ConsistencyCheck(&dcount); |
|
311 __ASSERT_ALWAYS(dcount==0, __PANIC(EHashTableDeletedEntryAfterReform)); |
|
312 } |
|
313 #endif |
|
314 |
|
315 EXPORT_C void RHashTableBase::ConsistencyCheck(TUint32* aDeleted, TUint32* aComparisons, TUint32 aChainLimit, TUint32* aChainInfo) |
|
316 { |
|
317 #ifdef _DEBUG_HASH_TABLE |
|
318 TUint32 count = 0; |
|
319 TUint32 dcount = 0; |
|
320 TUint32 ecount = 0; |
|
321 TUint32 max = 1u << iIndexBits; |
|
322 TUint32 mask = max - 1; |
|
323 TUint32 sh = 32 - iIndexBits; |
|
324 TUint32 ix = 0; |
|
325 TUint32 cmp = 0; |
|
326 if (aChainInfo) |
|
327 memclr(aChainInfo, aChainLimit*sizeof(TUint32)); |
|
328 if (iElements) |
|
329 { |
|
330 for (ix = 0; ix < max; ++ix) |
|
331 { |
|
332 SElement* e = Element(ix); |
|
333 if (e->IsEmpty()) |
|
334 { |
|
335 ++ecount; |
|
336 continue; |
|
337 } |
|
338 if (e->IsDeleted()) |
|
339 { |
|
340 ++dcount; |
|
341 continue; |
|
342 } |
|
343 ++count; |
|
344 __ASSERT_ALWAYS((e->iHash & EStateMask) == iGeneration, __PANIC(EHashTableBadGeneration)); |
|
345 TUint32 hash = (*iHashFunc)(GetKey(e)); |
|
346 hash = (hash &~ EStateMask) | iGeneration; |
|
347 __ASSERT_ALWAYS(e->iHash == hash, __PANIC(EHashTableBadHash)); |
|
348 |
|
349 TUint32 pos = hash >> sh; |
|
350 TUint32 step = (hash >> 1) & mask; |
|
351 SElement* f = 0; |
|
352 TUint32 cl = 0; |
|
353 FOREVER |
|
354 { |
|
355 f = Element(pos); |
|
356 if (f->IsEmpty()) |
|
357 { |
|
358 f = 0; |
|
359 break; |
|
360 } |
|
361 ++cl; |
|
362 if (!f->IsDeleted() && f->iHash==hash) |
|
363 { |
|
364 ++cmp; |
|
365 if (e==f || (*iIdFunc)(GetKey(e), GetKey(f))) |
|
366 break; |
|
367 } |
|
368 pos = (pos + step) & mask; |
|
369 } |
|
370 __ASSERT_ALWAYS(e==f, __PANIC(EHashTableEntryLost)); |
|
371 if (aChainInfo && cl<aChainLimit) |
|
372 ++aChainInfo[cl]; |
|
373 } |
|
374 } |
|
375 if (aDeleted) |
|
376 *aDeleted = dcount; |
|
377 if (aComparisons) |
|
378 *aComparisons = cmp; |
|
379 __ASSERT_ALWAYS(iCount==count, __PANIC(EHashTableCountWrong)); |
|
380 __ASSERT_ALWAYS(iEmptyCount==ecount, __PANIC(EHashTableEmptyCountWrong)); |
|
381 #else |
|
382 if (aDeleted) |
|
383 *aDeleted = KMaxTUint; |
|
384 if (aComparisons) |
|
385 *aComparisons = KMaxTUint; |
|
386 if (aChainInfo) |
|
387 memclr(aChainInfo, aChainLimit*sizeof(TUint32)); |
|
388 #endif |
|
389 } |
|
390 |
|
391 void RHashTableBase::ShrinkTable() |
|
392 { |
|
393 ReformTable(iIndexBits - 1); |
|
394 TUint32 max = 1u << iIndexBits; |
|
395 iElements = User::ReAlloc(iElements, max * iElementSize); |
|
396 } |
|
397 |
|
398 TInt RHashTableBase::ExpandTable(TInt aNewIndexBits) |
|
399 { |
|
400 TUint32 newmax = 1u << aNewIndexBits; |
|
401 if (!iElements) |
|
402 { |
|
403 iElements = User::AllocZ(newmax * iElementSize); |
|
404 if (!iElements) |
|
405 return KErrNoMemory; |
|
406 iIndexBits = (TUint8)aNewIndexBits; |
|
407 iEmptyCount = newmax; |
|
408 SetThresholds(); |
|
409 return KErrNone; |
|
410 } |
|
411 TUint32 max = 1u << iIndexBits; |
|
412 TAny* p = User::ReAlloc(iElements, newmax * iElementSize); |
|
413 if (!p) |
|
414 return KErrNoMemory; |
|
415 iElements = p; |
|
416 memclr(Element(max), (newmax-max)*iElementSize); |
|
417 ReformTable(aNewIndexBits); |
|
418 return KErrNone; |
|
419 } |
|
420 |
|
421 EXPORT_C TInt RHashTableBase::Reserve(TInt aCount) |
|
422 { |
|
423 __ASSERT_ALWAYS((TUint)aCount<0x40000000u, __PANIC(EHashTableBadReserveCount)); |
|
424 TInt new_ixb = iIndexBits; |
|
425 TUint grow_threshold = iUpperThreshold; |
|
426 while (TUint(aCount) > grow_threshold) |
|
427 { |
|
428 grow_threshold <<= 1; |
|
429 ++new_ixb; |
|
430 } |
|
431 // Expand the table if it isn't large enough to fit aCount elements in it |
|
432 // or if the table hasn't yet been created, create it with ExpandTable |
|
433 if (new_ixb > TInt(iIndexBits) || !iElements) |
|
434 { |
|
435 return ExpandTable(new_ixb); |
|
436 } |
|
437 return KErrNone; |
|
438 } |
|
439 |
|
440 EXPORT_C void RHashTableBase::ReserveL(TInt aCount) |
|
441 { |
|
442 User::LeaveIfError(Reserve(aCount)); |
|
443 } |
|
444 |
|
445 EXPORT_C THashTableIterBase::THashTableIterBase(const RHashTableBase& aTable) |
|
446 : iTbl(aTable), iIndex(-1), iPad1(0), iPad2(0) |
|
447 { |
|
448 } |
|
449 |
|
450 EXPORT_C void THashTableIterBase::Reset() |
|
451 { |
|
452 iIndex = -1; |
|
453 } |
|
454 |
|
455 EXPORT_C const TAny* THashTableIterBase::Next(TInt aOffset) |
|
456 { |
|
457 TInt max = 1 << iTbl.iIndexBits; |
|
458 if (!iTbl.iElements) |
|
459 return NULL; |
|
460 __ASSERT_DEBUG(iIndex>=-1 && iIndex<=max, __PANIC(EHashTableIterNextBadIndex)); |
|
461 if (iIndex < max) |
|
462 ++iIndex; |
|
463 for(; iIndex < max; ++iIndex) |
|
464 { |
|
465 const RHashTableBase::SElement* e = iTbl.ElementC(iIndex); |
|
466 if (!e->IsEmptyOrDeleted()) |
|
467 { |
|
468 if (aOffset >= 0) |
|
469 return (TUint8*)e + aOffset; |
|
470 return *(const TAny**)((TUint8*)e - aOffset); |
|
471 } |
|
472 } |
|
473 return NULL; |
|
474 } |
|
475 |
|
476 EXPORT_C const TAny* THashTableIterBase::Current(TInt aOffset) const |
|
477 { |
|
478 TInt max = 1 << iTbl.iIndexBits; |
|
479 if (!iTbl.iElements || iIndex<0 || iIndex>=max) |
|
480 return NULL; |
|
481 const RHashTableBase::SElement* e = iTbl.ElementC(iIndex); |
|
482 __ASSERT_DEBUG(!e->IsEmptyOrDeleted(), __PANIC(EHashTableIterCurrentBadIndex)); |
|
483 if (aOffset >= 0) |
|
484 return (TUint8*)e + aOffset; |
|
485 return *(const TAny**)((TUint8*)e - aOffset); |
|
486 } |
|
487 |
|
488 EXPORT_C void THashTableIterBase::RemoveCurrent() |
|
489 { |
|
490 TInt max = 1 << iTbl.iIndexBits; |
|
491 if (!iTbl.iElements || iIndex<0 || iIndex>=max) |
|
492 return; |
|
493 RHashTableBase& tbl = (RHashTableBase&)iTbl; |
|
494 RHashTableBase::SElement* e = tbl.Element(iIndex); |
|
495 __ASSERT_DEBUG(!e->IsEmptyOrDeleted(), __PANIC(EHashTableIterCurrentBadIndex)); |
|
496 |
|
497 // mark entry as deleted but don't shrink the array since that will mess up the iteration |
|
498 e->SetDeleted(); |
|
499 if (--tbl.iCount == 0) |
|
500 { |
|
501 memclr(tbl.iElements, max * tbl.iElementSize); |
|
502 tbl.iEmptyCount = max; |
|
503 tbl.iGeneration = RHashTableBase::EGen0; |
|
504 } |
|
505 } |
|
506 |
|
507 /** |
|
508 @publishedAll |
|
509 @released |
|
510 |
|
511 Calculate a 32 bit hash from an 8 bit descriptor. |
|
512 |
|
513 @param aDes The descriptor to be hashed. |
|
514 @return The calculated 32 bit hash value. |
|
515 */ |
|
516 EXPORT_C TUint32 DefaultHash::Des8(const TDesC8& aDes) |
|
517 { |
|
518 return DefaultStringHash(aDes.Ptr(), aDes.Length()); |
|
519 } |
|
520 |
|
521 |
|
522 /** |
|
523 @publishedAll |
|
524 @released |
|
525 |
|
526 Calculate a 32 bit hash from a 16 bit descriptor. |
|
527 |
|
528 @param aDes The descriptor to be hashed. |
|
529 @return The calculated 32 bit hash value. |
|
530 */ |
|
531 EXPORT_C TUint32 DefaultHash::Des16(const TDesC16& aDes) |
|
532 { |
|
533 return DefaultWStringHash(aDes.Ptr(), aDes.Size()); |
|
534 } |
|
535 |
|
536 |
|
537 /** |
|
538 @publishedAll |
|
539 @released |
|
540 |
|
541 Calculate a 32 bit hash from a TInt pointer. |
|
542 |
|
543 @param aPtr The TInt pointer to be hashed. |
|
544 @return The calculated 32 bit hash value. |
|
545 */ |
|
546 EXPORT_C TUint32 DefaultHash::IntegerPtr(TInt* const& aPtr) |
|
547 { |
|
548 return Integer((TInt)aPtr); |
|
549 } |
|
550 |
|
551 /** |
|
552 @publishedAll |
|
553 @released |
|
554 |
|
555 Calculate a 32 bit hash from a TDesC8 pointer. |
|
556 |
|
557 @param aPtr The TDesC8 pointer to be hashed. |
|
558 @return The calculated 32 bit hash value. |
|
559 */ |
|
560 EXPORT_C TUint32 DefaultHash::Des8Ptr(TDesC8* const& aPtr) |
|
561 { |
|
562 return Integer((TInt)aPtr); |
|
563 } |
|
564 |
|
565 /** |
|
566 @publishedAll |
|
567 @released |
|
568 |
|
569 Calculate a 32 bit hash from a TDesC16 pointer. |
|
570 |
|
571 @param aPtr The TDesC16 pointer to be hashed. |
|
572 @return The calculated 32 bit hash value. |
|
573 */ |
|
574 EXPORT_C TUint32 DefaultHash::Des16Ptr(TDesC16* const& aPtr) |
|
575 { |
|
576 return Integer((TInt)aPtr); |
|
577 } |
|
578 |
|
579 /** |
|
580 @publishedAll |
|
581 @released |
|
582 |
|
583 Compare two integers for equality. |
|
584 |
|
585 @param aA The first integer to be compared |
|
586 @param aB The second integer to be compared |
|
587 @return ETrue if the arguments are equal, EFalse otherwise. |
|
588 */ |
|
589 EXPORT_C TBool DefaultIdentity::Integer(const TInt& aA, const TInt& aB) |
|
590 { |
|
591 return aA == aB; |
|
592 } |
|
593 |
|
594 |
|
595 /** |
|
596 @publishedAll |
|
597 @released |
|
598 |
|
599 Compare two 8 bit descriptors for exact binary equality. |
|
600 |
|
601 @param aA The first integer to be compared |
|
602 @param aB The second integer to be compared |
|
603 @return ETrue if the arguments are identical, EFalse otherwise. |
|
604 */ |
|
605 EXPORT_C TBool DefaultIdentity::Des8(const TDesC8& aA, const TDesC8& aB) |
|
606 { |
|
607 return aA == aB; |
|
608 } |
|
609 |
|
610 |
|
611 /** |
|
612 @publishedAll |
|
613 @released |
|
614 |
|
615 Compare two 16 bit descriptors for exact binary equality. |
|
616 |
|
617 @param aA The first integer to be compared |
|
618 @param aB The second integer to be compared |
|
619 @return ETrue if the arguments are identical, EFalse otherwise. |
|
620 */ |
|
621 EXPORT_C TBool DefaultIdentity::Des16(const TDesC16& aA, const TDesC16& aB) |
|
622 { |
|
623 return aA == aB; |
|
624 } |
|
625 |
|
626 /** |
|
627 @publishedAll |
|
628 @released |
|
629 |
|
630 Compare two TInt pointers for equality. |
|
631 |
|
632 @param aA The first pointer to be compared |
|
633 @param aB The second pointer to be compared |
|
634 @return ETrue if the arguments are equal, EFalse otherwise. |
|
635 */ |
|
636 EXPORT_C TBool DefaultIdentity::IntegerPtr(TInt* const& aA,TInt* const& aB) |
|
637 { |
|
638 return aA == aB; |
|
639 } |
|
640 |
|
641 /** |
|
642 @publishedAll |
|
643 @released |
|
644 |
|
645 Compare two TDesC8 pointers for equality. |
|
646 |
|
647 @param aA The first pointer to be compared |
|
648 @param aB The second pointer to be compared |
|
649 @return ETrue if the arguments are equal, EFalse otherwise. |
|
650 */ |
|
651 EXPORT_C TBool DefaultIdentity::Des8Ptr(TDesC8* const& aA,TDesC8* const& aB) |
|
652 { |
|
653 return aA == aB; |
|
654 } |
|
655 |
|
656 /** |
|
657 @publishedAll |
|
658 @released |
|
659 |
|
660 Compare two TDesC16 pointers for equality. |
|
661 |
|
662 @param aA The first pointer to be compared |
|
663 @param aB The second pointer to be compared |
|
664 @return ETrue if the arguments are equal, EFalse otherwise. |
|
665 */ |
|
666 EXPORT_C TBool DefaultIdentity::Des16Ptr(TDesC16* const& aA,TDesC16* const& aB) |
|
667 { |
|
668 return aA == aB; |
|
669 } |