|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "mcedictionary.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CMceDictionaryItem::CMceDictionaryItem |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CMceDictionaryItem::CMceDictionaryItem( TInt aKey ):iKey( aKey ) |
|
29 { |
|
30 } |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMceDictionaryItem::Key |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 TInt CMceDictionaryItem::Key() |
|
37 { |
|
38 return iKey; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMceDictionary::~CMceDictionary |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CMceDictionary::~CMceDictionary() |
|
46 { |
|
47 iPairs.ResetAndDestroy(); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMceDictionary::Pair |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMceDictionaryItem* CMceDictionary::Pair( TInt aKey ) const |
|
55 { |
|
56 CMceDictionaryItem* pair = NULL; |
|
57 for ( TInt i = 0; !pair && i < iPairs.Count(); i++ ) |
|
58 { |
|
59 pair = iPairs[ i ]; |
|
60 if ( pair->Key() == aKey ) |
|
61 { |
|
62 // NOP |
|
63 } |
|
64 else |
|
65 { |
|
66 pair = NULL; |
|
67 } |
|
68 } |
|
69 return pair; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMceDictionary::AddL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CMceDictionary::AddL( CMceDictionaryItem* aPair ) |
|
77 { |
|
78 iPairs.AppendL( aPair ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMceDictionary::Delete |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CMceDictionary::Delete( TInt aKey ) |
|
86 { |
|
87 TBool found = EFalse; |
|
88 for ( TInt i = 0; !found && i < iPairs.Count(); i++ ) |
|
89 { |
|
90 CMceDictionaryItem* pair = iPairs[ i ]; |
|
91 if ( pair->Key() == aKey ) |
|
92 { |
|
93 iPairs.Remove( i ); |
|
94 delete pair; |
|
95 found = ETrue; |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 // End of file |