1/* FILE:		hashmap.h
2 *  DATE MODIFIED:	31-Aug-07
3 *  DESCRIPTION:	Part of the  SREC graph compiler project source files.
4 *
5 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
6 *                                                                           *
7 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
8 *  you may not use this file except in compliance with the License.         *
9 *                                                                           *
10 *  You may obtain a copy of the License at                                  *
11 *      http://www.apache.org/licenses/LICENSE-2.0                           *
12 *                                                                           *
13 *  Unless required by applicable law or agreed to in writing, software      *
14 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
15 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
16 *  See the License for the specific language governing permissions and      *
17 *  limitations under the License.                                           *
18 *                                                                           *
19 *---------------------------------------------------------------------------*/
20
21#ifndef __hashmap_h__
22#define __hashmap_h__
23
24#include <iostream>
25#include <map>
26#include <vector>
27
28
29template <typename T1, typename T2>
30class HashMap
31{
32public:
33    //typedef T1	MapValue;
34    HashMap();
35    void setName(std::string s);
36    bool insert( T1 const & index, T2 const & value);
37    bool remove( T1 const & index);
38    bool isEmpty();
39    bool clear();
40    bool getFirst( T1 *index, T2 *value );
41    bool getNext( T1 *index, T2 *value );
42    bool getValue( T1 const & index, T2 *value);	//returns value
43    bool getIndex( T2 const & value, T1 *index );	//returns index
44    void print();
45    void writeFile( std::string fileName );
46
47    typename std::map<T1,T2>::iterator begin();
48    typename std::map<T1,T2>::iterator end();
49
50    int size();
51
52private:
53    std::string m_Name;
54    std::map<T1, T2> m_Map;
55    typename std::map<T1,T2>::iterator m_pPos;
56
57    unsigned int m_NextAutoIndex;
58};
59
60
61#endif // __hashmap_h__
62