epoc32/include/mw/senpointermap.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 /*
     1 /*
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: Pointermap class declaration        
    14 * Description:    Pointermap class declaration        
    15 *
    15 *
    16 */
    16 */
       
    17 
       
    18 
       
    19 
    17 
    20 
    18 #ifndef POINTERMAP_H
    21 #ifndef POINTERMAP_H
    19 #define POINTERMAP_H
    22 #define POINTERMAP_H
    20 
    23 
    21 // INCLUDES
    24 // INCLUDES
    56         return err;
    59         return err;
    57         }
    60         }
    58 
    61 
    59     TInt Find(const K& aKey) const
    62     TInt Find(const K& aKey) const
    60         {
    63         {
    61         TInt index = KErrNotFound;
    64         TInt index( KErrNotFound );
    62         for (int i = 0; i < iKeys.Count(); i++)
    65         for (TInt i = 0; i < iKeys.Count(); i++)
    63             {
    66             {
    64             if (*iKeys[i] == aKey)
    67             if (*iKeys[i] == aKey)
    65                 {
    68                 {
    66                 index = i;
    69                 index = i;
    67                 break;
    70                 break;
    68                 }
    71                 }
    69             }
    72             }
    70         return index;
    73         return index;
    71         }
    74         }
       
    75 
       
    76     TInt FindReverse(const K& aKey) const
       
    77         {
       
    78         TInt index( KErrNotFound );
       
    79         TInt count( iKeys.Count() );
       
    80         for (TInt i = count-1; i >=0 ; i--)
       
    81             {
       
    82             if (*iKeys[i] == aKey)
       
    83                 {
       
    84                 index = i;
       
    85                 break;
       
    86                 }
       
    87             }
       
    88         return index;
       
    89         }
       
    90         
       
    91         
       
    92     TInt RemoveAt( TInt aIndex ) 
       
    93         {
       
    94         K* key = KeyAt( aIndex );
       
    95     	return RemoveByKey( *key );
       
    96     	}
    72 
    97 
    73     // @return the index of removed key-value pair, or
    98     // @return the index of removed key-value pair, or
    74     // KErrNotFound, if such key was not found
    99     // KErrNotFound, if such key was not found
    75     TInt RemoveByKey(const K& aKey)
   100     TInt RemoveByKey(const K& aKey)
    76         {
   101         {
   117         }
   142         }
   118 
   143 
   119     TInt FindValue(const V& aValue) const
   144     TInt FindValue(const V& aValue) const
   120         {
   145         {
   121         TInt index = KErrNotFound;
   146         TInt index = KErrNotFound;
   122         for (int i = 0; i < iValues.Count(); i++)
   147         for (TInt i = 0; i < iValues.Count(); i++)
   123             {
   148             {
   124             if ((iValues[i]) && (*iValues[i] == aValue))
   149             if ((iValues[i]) && (*iValues[i] == aValue))
   125                 {
   150                 {
   126                 index = i;
   151                 index = i;
   127                 break;
   152                 break;