phonebookui/Phonebook/Engine/inc/CPbkUidMap.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *      Map of UIDs.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __CPbkUidMap_H__
       
    20 #define __CPbkUidMap_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 /**
       
    28  * Map of UIDs.
       
    29  */
       
    30 NONSHARABLE_CLASS(CPbkUidMap) : 
       
    31         public CBase
       
    32     {
       
    33     public: // Interface
       
    34         /**
       
    35          * Constructor.
       
    36          */
       
    37         CPbkUidMap();
       
    38 
       
    39         /**
       
    40          * Destructor.
       
    41          */
       
    42         ~CPbkUidMap();
       
    43 
       
    44         /**
       
    45          * Inserts aUid into this map. UIDs already in the map are ignored.
       
    46          */
       
    47         void InsertL(const TUid& aUid);
       
    48 
       
    49         /**
       
    50          * Returns the number of unique UIDs in this map.
       
    51          */
       
    52         TInt Count() const;
       
    53 
       
    54         /**
       
    55          * Returns the unique index assigned for aUid by this map or 
       
    56          * KErrNotFound if aUid is not present on the map. Indexes are
       
    57          * changed if InsertL is used to insert a new UID into this map.
       
    58          */
       
    59         TInt IndexOf(const TUid& aUid) const;
       
    60 
       
    61     private:  // Data
       
    62         /// Own: sorted array of UIDs
       
    63         RArray<TInt> iUids;
       
    64     };
       
    65 
       
    66 
       
    67 // INLINE FUNCTIONS
       
    68 
       
    69 inline CPbkUidMap::CPbkUidMap()
       
    70     {
       
    71     }
       
    72 
       
    73 inline CPbkUidMap::~CPbkUidMap()
       
    74     {
       
    75     iUids.Close();
       
    76     }
       
    77 
       
    78 inline TInt CPbkUidMap::Count() const
       
    79     {
       
    80     return iUids.Count();
       
    81     }
       
    82 
       
    83 inline void CPbkUidMap::InsertL(const TUid& aUid)
       
    84     {
       
    85     TInt index;
       
    86     if (iUids.FindInOrder(aUid.iUid,index) == KErrNotFound)
       
    87         {
       
    88         User::LeaveIfError(iUids.Insert(aUid.iUid,index));
       
    89         }
       
    90     }
       
    91 
       
    92 inline TInt CPbkUidMap::IndexOf(const TUid& aUid) const
       
    93     {
       
    94     return iUids.FindInOrder(aUid.iUid);
       
    95     }
       
    96 
       
    97 #endif // __CPbkUidMap_H__
       
    98 
       
    99 // End of File