1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/Inc2/D32Map.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,86 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// RMap template class declaration.
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __D32MAP_H__
1.22 +#define __D32MAP_H__
1.23 +
1.24 +#include "D32Assert.h"
1.25 +
1.26 +/**
1.27 +(KEY, DATA) template pair class used by RMap template class.
1.28 +@internalComponent
1.29 +*/
1.30 +template <class KEY, class DATA>
1.31 +struct TPair
1.32 + {
1.33 + TPair(const KEY& aKey, const DATA& aData);
1.34 + TPair(const KEY& aKey);
1.35 + TPair();
1.36 + KEY iKey;
1.37 + DATA iData;
1.38 + };
1.39 +
1.40 +//Forward declaration
1.41 +template <class KEY, class DATA> class RMap;
1.42 +
1.43 +/**
1.44 +TMapIterator class. It describes an object which can be used as a
1.45 +forward read-only iterator for sequence of type RMap.
1.46 +@internalComponent
1.47 +*/
1.48 +template <class KEY, class DATA>
1.49 +class TMapIterator
1.50 + {
1.51 +public:
1.52 + TMapIterator(const RMap<KEY, DATA>& aMap);
1.53 + void Reset();
1.54 + TBool Next(TPair<KEY, DATA>& aPair) const;
1.55 +private:
1.56 + const RMap<KEY, DATA>& iMap;
1.57 + mutable TInt iIndex;
1.58 + };
1.59 +
1.60 +/**
1.61 +RMap template class describes an object that controls an ordered sequence of entries.
1.62 +Each entry has a key of type KEY and an associated with it data of type DATA.
1.63 +No entries with duplicated keys are allowed.
1.64 +The algorithm for determining the order of two entries is provided by a TLinearOrder
1.65 +object, supplied by the client of RMap during RMap instance construction.
1.66 +@internalComponent
1.67 +*/
1.68 +template <class KEY, class DATA>
1.69 +class RMap
1.70 + {
1.71 + friend class TMapIterator<KEY, DATA>;
1.72 +public:
1.73 + RMap(const TLinearOrder< TPair<KEY, DATA> >& aOrder);
1.74 + void Close();
1.75 + TInt Insert(const KEY& aKey, const DATA& aData);
1.76 + void Remove(const KEY& aKey);
1.77 + const DATA& operator[](const KEY& aKey) const;
1.78 + TInt Find(const KEY& aKey, DATA& aData) const;
1.79 + TInt Count() const;
1.80 +
1.81 +private:
1.82 + TLinearOrder< TPair<KEY, DATA> > iOrder;
1.83 + RArray< TPair<KEY, DATA> > iCol;
1.84 +
1.85 + };
1.86 +
1.87 +#include "D32Map.inl"
1.88 +
1.89 +#endif//__D32MAP_H__