B
Billy Patton
I've had a lot of help, but I need a little more.
Here's a snippett of code:
template <typename K,typename V>
class HashTable : private std::map<K, V>
{
private:
public:
bool Keys(K& key, bool firstp = false) const
{
static typename std::map<K,V>::iterator map_iter;
if (firstp) map_iter = this->begin(); <<<<<<<<<<<<LINE #81
if (map_iter == this->end()) return false;
key = map_iter->first;
++map_iter;
return true;
}
I need to call this method until it has hit all the keys. Thst's why I declare
map_iter as static.
HashTable<int,std::string> h;
int i;
bool first=true;
while (h.Keys(i,first))
{
first = false;
do_something_with_i();
}
Here's my actual test code:
void t_HashTable(void)
{
ENTER
HashTable<int,std::string> h;
pass(0 EQ h.EntryCount() , "verify hash is empty");
pass(true EQ h.Put(1,"a") , "put a into 1");
pass(1 EQ h.EntryCount() , "verify hash hasn 1 entry");
pass(h.Value(1) EQ "a" , "Verify value of 1 is a");
int i;
pass(h.Keys(i,true) , "Get first key"); <<<<<<< LINE# 142
pass(i EQ 1 , "Verify only key is 1");
LEAVE
}
Here's my compiler message:
x.cxx: In member function `bool HashTable<K, V>::Keys(K&, bool) const [with K =
int, V = std::string]':
x.cxx:142: instantiated from here
x.cxx:81: error: no match for 'operator=' in 'map_iter = ((const std::map<int,
_Alloc = std::allocator<std:air<const int, std::string> >]()'
/apps/gcc/3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/bits/stl_tree.h:152:
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)
Here's a snippett of code:
template <typename K,typename V>
class HashTable : private std::map<K, V>
{
private:
public:
bool Keys(K& key, bool firstp = false) const
{
static typename std::map<K,V>::iterator map_iter;
if (firstp) map_iter = this->begin(); <<<<<<<<<<<<LINE #81
if (map_iter == this->end()) return false;
key = map_iter->first;
++map_iter;
return true;
}
I need to call this method until it has hit all the keys. Thst's why I declare
map_iter as static.
HashTable<int,std::string> h;
int i;
bool first=true;
while (h.Keys(i,first))
{
first = false;
do_something_with_i();
}
Here's my actual test code:
void t_HashTable(void)
{
ENTER
HashTable<int,std::string> h;
pass(0 EQ h.EntryCount() , "verify hash is empty");
pass(true EQ h.Put(1,"a") , "put a into 1");
pass(1 EQ h.EntryCount() , "verify hash hasn 1 entry");
pass(h.Value(1) EQ "a" , "Verify value of 1 is a");
int i;
pass(h.Keys(i,true) , "Get first key"); <<<<<<< LINE# 142
pass(i EQ 1 , "Verify only key is 1");
LEAVE
}
Here's my compiler message:
x.cxx: In member function `bool HashTable<K, V>::Keys(K&, bool) const [with K =
int, V = std::string]':
x.cxx:142: instantiated from here
x.cxx:81: error: no match for 'operator=' in 'map_iter = ((const std::map<int,
_Alloc>::begin [with _Key = int, _Tp = std::string, _Compare = std::less<int>,*)((const HashTable<int, std::string>*)this))->std::map<_Key, _Tp, _Compare,
_Alloc = std::allocator<std:air<const int, std::string> >]()'
/apps/gcc/3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/bits/stl_tree.h:152:
std::_Rb_tree_iterator<std:air<const int, std::string> >&)note: candidates are: std::_Rb_tree_iterator said:& std::_Rb_tree_iterator<std:air<const int, std::string> >:perator=(const
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)