sl@0
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Hexadecimal trees - inline functions
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef HEXTREE_INL
|
sl@0
|
18 |
#define HEXTREE_INL
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
Constructor. It constructs an associative array with no key-value pairs.
|
sl@0
|
22 |
|
sl@0
|
23 |
@param aHeap A pointer to the heap to be used by the associative array
|
sl@0
|
24 |
implementation to allocate memory for internal data structures. This
|
sl@0
|
25 |
heap can be shared between several processes.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
template<class T>
|
sl@0
|
28 |
inline RHexTree<T>::RHexTree(RHeap* aHeap)
|
sl@0
|
29 |
: RHexTreeBase(aHeap)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Adds a key-value pair to this associative array.
|
sl@0
|
35 |
|
sl@0
|
36 |
@param aKey The 32-bit key to add to this associative array.
|
sl@0
|
37 |
@param aValue A pointer to the value to associate with aKey. It must have been
|
sl@0
|
38 |
allocated on the same heap as the one used by the associative array
|
sl@0
|
39 |
implementation to allocate memory for internal data structures. Ownership
|
sl@0
|
40 |
is transferred to this associative array.
|
sl@0
|
41 |
@return KErrNone if the key-value pair was added successfully. KErrNoMemory if
|
sl@0
|
42 |
there was not enough memory in the heap for internal data structures.
|
sl@0
|
43 |
KErrAlreadyExists if an attempt was made to add a duplicate key.
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
template<class T>
|
sl@0
|
46 |
inline TInt RHexTree<T>::SetAt(TUint aKey, T* aValue)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
return RHexTreeBase::SetAt(aKey, aValue);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
Looks up a given key in this associative array and returns a pointer to the
|
sl@0
|
53 |
corresponding value.
|
sl@0
|
54 |
|
sl@0
|
55 |
@param aKey The 32-bit key to look up.
|
sl@0
|
56 |
@return A pointer to the corresponding value in this associative array, if the
|
sl@0
|
57 |
given key was found. The value may not be modified via this pointer.
|
sl@0
|
58 |
NULL if the given key was not found.
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
template<class T>
|
sl@0
|
61 |
inline const T* RHexTree<T>::At(TUint aKey) const
|
sl@0
|
62 |
{
|
sl@0
|
63 |
return static_cast<T*>(RHexTreeBase::At(aKey));
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Looks up a given key in this associative array and returns a pointer to the
|
sl@0
|
68 |
corresponding value. Note that if values are modified after being added to an
|
sl@0
|
69 |
associative array, then the user is responsible for synchronisation when
|
sl@0
|
70 |
concurrent access is needed.
|
sl@0
|
71 |
|
sl@0
|
72 |
@param aKey The 32-bit key to look up.
|
sl@0
|
73 |
@return A pointer to the corresponding value in this associative array, if the
|
sl@0
|
74 |
given key was found. The value may be modified via this pointer.
|
sl@0
|
75 |
NULL if the given key was not found.
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
template<class T>
|
sl@0
|
78 |
inline T* RHexTree<T>::At(TUint aKey)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
return static_cast<T*>(RHexTreeBase::At(aKey));
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
#endif // HEXTREE_INL
|