os/persistentdata/persistentstorage/dbms/Inc2/D32Map.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-2009 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
// RMap template class declaration.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __D32MAP_H__
sl@0
    19
#define __D32MAP_H__
sl@0
    20
sl@0
    21
#include "D32Assert.h"
sl@0
    22
sl@0
    23
/**
sl@0
    24
(KEY, DATA) template pair class used by RMap template class.
sl@0
    25
@internalComponent
sl@0
    26
*/
sl@0
    27
template <class KEY, class DATA> 
sl@0
    28
struct TPair
sl@0
    29
	{
sl@0
    30
	TPair(const KEY& aKey, const DATA& aData);
sl@0
    31
	TPair(const KEY& aKey);
sl@0
    32
	TPair();
sl@0
    33
	KEY		iKey;
sl@0
    34
	DATA	iData;
sl@0
    35
	};
sl@0
    36
sl@0
    37
//Forward declaration
sl@0
    38
template <class KEY, class DATA> class RMap;
sl@0
    39
sl@0
    40
/**
sl@0
    41
TMapIterator class. It describes an object which can be used as a 
sl@0
    42
forward read-only iterator for sequence of type RMap.
sl@0
    43
@internalComponent
sl@0
    44
*/
sl@0
    45
template <class KEY, class DATA> 
sl@0
    46
class TMapIterator
sl@0
    47
	{
sl@0
    48
public:
sl@0
    49
	TMapIterator(const RMap<KEY, DATA>& aMap);
sl@0
    50
	void Reset();
sl@0
    51
	TBool Next(TPair<KEY, DATA>& aPair) const;
sl@0
    52
private:
sl@0
    53
	const RMap<KEY, DATA>&	iMap;
sl@0
    54
	mutable TInt			iIndex;
sl@0
    55
	};
sl@0
    56
sl@0
    57
/**
sl@0
    58
RMap template class describes an object that controls an ordered sequence of entries.
sl@0
    59
Each entry has a key of type KEY and an associated with it data of type DATA.
sl@0
    60
No entries with duplicated keys are allowed.
sl@0
    61
The algorithm for determining the order of two entries is provided by a TLinearOrder
sl@0
    62
object, supplied by the client of RMap during RMap instance construction.
sl@0
    63
@internalComponent
sl@0
    64
*/
sl@0
    65
template <class KEY, class DATA> 
sl@0
    66
class RMap
sl@0
    67
	{
sl@0
    68
	friend class TMapIterator<KEY, DATA>;
sl@0
    69
public:
sl@0
    70
	RMap(const TLinearOrder< TPair<KEY, DATA> >& aOrder);
sl@0
    71
	void Close();
sl@0
    72
	TInt Insert(const KEY& aKey, const DATA& aData);
sl@0
    73
	void Remove(const KEY& aKey);
sl@0
    74
	const DATA& operator[](const KEY& aKey) const;
sl@0
    75
	TInt Find(const KEY& aKey, DATA& aData) const;
sl@0
    76
	TInt Count() const;
sl@0
    77
sl@0
    78
private:
sl@0
    79
	TLinearOrder< TPair<KEY, DATA> >	iOrder;
sl@0
    80
	RArray< TPair<KEY, DATA> >			iCol;
sl@0
    81
sl@0
    82
	};
sl@0
    83
sl@0
    84
#include "D32Map.inl"
sl@0
    85
sl@0
    86
#endif//__D32MAP_H__