stl_hashmap.h 1.0 KB
Newer Older
W
wangguibao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/***************************************************************************
 * 
 * Copyright (c) 2008 Baidu.com, Inc. All Rights Reserved
 * $Id: stl_hashmap.h,v 1.1 2008/09/03 06:47:49 xiaowei Exp $ 
 * 
 **************************************************************************/
 
 
 
/**
 * @file stl_hashmap.h
 * @author xiaowei(com@baidu.com)
 * @date 2008/08/26 15:12:10
 * @version $Revision: 1.1 $ 
 * @brief 
 *  
 **/


#ifndef  __STL_HASHMAP_H_
#define  __STL_HASHMAP_H_


#include <hash_map.h>

template <typename key_t, typename value_t>
class xhashmap
{
public:
	hash_map<key_t, value_t> _map;
	int set(const key_t &key, const value_t &val) {
		_map.insert(std::make_pair(key, val));
		return 0;
	}
	int get(const key_t &key, value_t *val) {
		typename hash_map<key_t, value_t>::iterator iter = _map.find(key);
		if (iter == _map.end()) return -1;
		if (val != 0) *val = iter->second;
		return 0;
	}
	int erase(const key_t &key) {
		_map.erase(key);
		return 0;
	}
};


#endif  //__STL_HASHMAP_H_

/* vim: set ts=4 sw=4 sts=4 tw=100 */