在哈希表中插入一个struct对象
Inserting an object of struct into a hash table C++
我目前正在做一个涉及哈希表的项目。我已经在一个文本文件中读取到符号结构的向量,我现在必须插入这些结构(对象,真的)到哈希表。我得到了一个特定的插入函数来使用,然而,我似乎不能让它工作。我已经包括了下面的插入函数以及我的Driver.cpp文件,其中包含在文件中读取到结构体向量和我试图将其插入哈希表。
我将感谢任何帮助/反馈,我在哪里做错了。
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <string>
#include <time.h>
#include <unistd.h>
#include "SeparateChaining.h"
using namespace std;
struct Symbol
{
int type;
string name;
};
size_t hash(const string & key); //declaration of hashing function
int main()
{
/************ VARS ***************/
string line;
int line_count;
int table_size;
int increment;
/************ Vector of Symbols ***************/
vector<Symbol> symbols;
/************ HashTable of Symbols ***************/
HashTable<Symbol> hashtable; //precomputed to have 101 elements --> probably will change this to accomodate table size.
cout << "Opening file..." << endl;
usleep(2000000);
ifstream file;
file.open("symbols.txt");
if(!file)
{
cout << "System failed to open file.";
}
else
{
cout << "File successfully opened" << endl;
}
cout << "Please enter the table size for the Hash Table. (NOTE: It MUST be a prime number.)" << endl;
cin >> table_size;
for(Symbol temp; file >> temp.name >> temp.type;)
{
symbols.push_back(temp);
increment++;
}
//Just to test and see if its loading it correctly...
for(int i = 0; i < symbols.size(); i++)
{
cout << symbols[i].name << endl;
cout << symbols[i].type << endl;
}
for(int j = 0; j < symbols.size(); j++)
{
hashtable.insert(symbols); // Messing up here !!!!!!!!!!!!!
}
//cout << ::hash("hi") << endl;
}
size_t hash( const string & key )
{
size_t hashVal = 0;
for( char ch : key )
hashVal = 37 * hashVal + ch;
return hashVal;
}
在separatechaing .h:
中插入函数bool insert( const HashedObj & x )
{
auto & whichList = theLists[ myhash( x ) ];
if( find( begin( whichList ), end( whichList ), x ) != end( whichList) )
return false;
whichList.push_back( x );
// Rehash; see Section 5.5
if( ++currentSize > theLists.size( ) )
rehash( );
return true;
}
bool insert( HashedObj && x )
{
auto & whichList = theLists[ myhash( x ) ];
if( find( begin( whichList ), end( whichList ), x ) != end( whichList ) )
return false;
whichList.push_back( std::move( x ) );
// Rehash; see Section 5.5
if( ++currentSize > theLists.size( ) )
rehash( );
return true;
}
hashtable.insert(symbols):
Driver.cpp: In function 'int main()':
Driver.cpp:65:27: error: no matching function for call to 'HashTable<Symbol>::insert(std::vector<Symbol>&)'
Driver.cpp:65:27: note: candidates are:
In file included from Driver.cpp:8:0:
SeparateChaining.h:44:10: note: bool HashTable<HashedObj>::insert(const HashedObj&) [with HashedObj = Symbol]
SeparateChaining.h:44:10: note: no known conversion for argument 1 from 'std::vector<Symbol>' to 'const Symbol&'
SeparateChaining.h:58:10: note: bool HashTable<HashedObj>::insert(HashedObj&&) [with HashedObj = Symbol]
SeparateChaining.h:58:10: note: no known conversion for argument 1 from 'std::vector<Symbol>' to 'Symbol&&'
使用hashtable.insert(symbols[j])对vector进行自增操作时出错:
In file included from /opt/local/include/gcc47/c++/bits/basic_string.h:3032:0,
from /opt/local/include/gcc47/c++/string:54,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/functional_hash.h: In instantiation of 'struct std::hash<Symbol>':
SeparateChaining.h:107:32: required from 'size_t HashTable<HashedObj>::myhash(const HashedObj&) const [with HashedObj = Symbol; size_t = long unsigned int]'
SeparateChaining.h:46:50: required from 'bool HashTable<HashedObj>::insert(const HashedObj&) [with HashedObj = Symbol]'
Driver.cpp:65:30: required from here
/opt/local/include/gcc47/c++/bits/functional_hash.h:60:7: error: static assertion failed: std::hash is not specialized for this type
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h: In instantiation of '_InputIterator std::__find(_InputIterator, _InputIterator, const _Tp&, std::input_iterator_tag) [with _InputIterator = std::_List_iterator<Symbol>; _Tp = Symbol]':
/opt/local/include/gcc47/c++/bits/stl_algo.h:4466:45: required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = std::_List_iterator<Symbol>; _Tp = Symbol]'
SeparateChaining.h:47:9: required from 'bool HashTable<HashedObj>::insert(const HashedObj&) [with HashedObj = Symbol]'
Driver.cpp:65:30: required from here
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: error: no match for 'operator==' in '__first.std::_List_iterator<_Tp>::operator*<Symbol>() == __val'
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: candidates are:
In file included from /opt/local/include/gcc47/c++/bits/stl_algo.h:68:0,
from /opt/local/include/gcc47/c++/algorithm:63,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/functional:2382:5: note: template<class _Res, class ... _Args> bool std::operator==(std::nullptr_t, const std::function<_Res(_ArgTypes ...)>&)
/opt/local/include/gcc47/c++/functional:2382:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: cannot convert '__first.std::_List_iterator<_Tp>::operator*<Symbol>()' (type 'Symbol') to type 'std::nullptr_t'
In file included from /opt/local/include/gcc47/c++/bits/stl_algo.h:68:0,
from /opt/local/include/gcc47/c++/algorithm:63,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/functional:2376:5: note: template<class _Res, class ... _Args> bool std::operator==(const std::function<_Res(_ArgTypes ...)>&, std::nullptr_t)
/opt/local/include/gcc47/c++/functional:2376:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::function<_Res(_ArgTypes ...)>'
In file included from /opt/local/include/gcc47/c++/functional:56:0,
from /opt/local/include/gcc47/c++/bits/stl_algo.h:68,
from /opt/local/include/gcc47/c++/algorithm:63,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/tuple:797:5: note: template<class ... _TElements, class ... _UElements> bool std::operator==(const std::tuple<_Elements ...>&, const std::tuple<_Elements ...>&)
/opt/local/include/gcc47/c++/tuple:797:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::tuple<_Elements ...>'
In file included from /opt/local/include/gcc47/c++/random:51:0,
from /opt/local/include/gcc47/c++/bits/stl_algo.h:67,
from /opt/local/include/gcc47/c++/algorithm:63,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/random.tcc:1713:5: note: template<class _RealType1> bool std::operator==(const std::normal_distribution<_RealType>&, const std::normal_distribution<_RealType>&)
/opt/local/include/gcc47/c++/bits/random.tcc:1713:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::normal_distribution<_RealType>'
In file included from /opt/local/include/gcc47/c++/list:64:0,
from SeparateChaining.h:6,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_list.h:1574:5: note: template<class _Tp, class _Alloc> bool std::operator==(const std::list<_Tp, _Alloc>&, const std::list<_Tp, _Alloc>&)
/opt/local/include/gcc47/c++/bits/stl_list.h:1574:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::list<_Tp, _Alloc>'
In file included from /opt/local/include/gcc47/c++/list:64:0,
from SeparateChaining.h:6,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_list.h:277:5: note: template<class _Val> bool std::operator==(const std::_List_iterator<_Tp>&, const std::_List_const_iterator<_Val>&)
/opt/local/include/gcc47/c++/bits/stl_list.h:277:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::_List_iterator<_Tp>'
In file included from /opt/local/include/gcc47/c++/vector:65:0,
from Driver.cpp:4:
/opt/local/include/gcc47/c++/bits/stl_vector.h:1370:5: note: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
/opt/local/include/gcc47/c++/bits/stl_vector.h:1370:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::vector<_Tp, _Alloc>'
In file included from /opt/local/include/gcc47/c++/bits/locale_facets.h:50:0,
from /opt/local/include/gcc47/c++/bits/basic_ios.h:39,
from /opt/local/include/gcc47/c++/ios:45,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/streambuf_iterator.h:206:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
/opt/local/include/gcc47/c++/bits/streambuf_iterator.h:206:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
In file included from /opt/local/include/gcc47/c++/string:54:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/basic_string.h:2516:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/opt/local/include/gcc47/c++/bits/basic_string.h:2516:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
In file included from /opt/local/include/gcc47/c++/string:54:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/basic_string.h:2504:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/opt/local/include/gcc47/c++/bits/basic_string.h:2504:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: mismatched types 'const _CharT*' and 'Symbol'
In file included from /opt/local/include/gcc47/c++/string:54:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/basic_string.h:2490:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
/opt/local/include/gcc47/c++/bits/basic_string.h:2490:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::basic_string<_CharT>'
In file included from /opt/local/include/gcc47/c++/string:54:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/basic_string.h:2483:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/opt/local/include/gcc47/c++/bits/basic_string.h:2483:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
In file included from /opt/local/include/gcc47/c++/string:43:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/allocator.h:124:5: note: template<class _Tp> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_CharT>&)
/opt/local/include/gcc47/c++/bits/allocator.h:124:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::allocator<_CharT>'
In file included from /opt/local/include/gcc47/c++/string:43:0,
from /opt/local/include/gcc47/c++/bits/locale_classes.h:42,
from /opt/local/include/gcc47/c++/bits/ios_base.h:43,
from /opt/local/include/gcc47/c++/ios:43,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/allocator.h:119:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_T2>&)
/opt/local/include/gcc47/c++/bits/allocator.h:119:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::allocator<_CharT>'
In file included from /opt/local/include/gcc47/c++/bits/stl_algobase.h:68:0,
from /opt/local/include/gcc47/c++/bits/char_traits.h:41,
from /opt/local/include/gcc47/c++/ios:41,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/stl_iterator.h:1039:5: note: template<class _Iterator> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
/opt/local/include/gcc47/c++/bits/stl_iterator.h:1039:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::move_iterator<_Iterator>'
In file included from /opt/local/include/gcc47/c++/bits/stl_algobase.h:68:0,
from /opt/local/include/gcc47/c++/bits/char_traits.h:41,
from /opt/local/include/gcc47/c++/ios:41,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/stl_iterator.h:1033:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
/opt/local/include/gcc47/c++/bits/stl_iterator.h:1033:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::move_iterator<_Iterator>'
In file included from /opt/local/include/gcc47/c++/bits/stl_algobase.h:68:0,
from /opt/local/include/gcc47/c++/bits/char_traits.h:41,
from /opt/local/include/gcc47/c++/ios:41,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/stl_iterator.h:343:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
/opt/local/include/gcc47/c++/bits/stl_iterator.h:343:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::reverse_iterator<_Iterator>'
In file included from /opt/local/include/gcc47/c++/bits/stl_algobase.h:68:0,
from /opt/local/include/gcc47/c++/bits/char_traits.h:41,
from /opt/local/include/gcc47/c++/ios:41,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/stl_iterator.h:293:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/opt/local/include/gcc47/c++/bits/stl_iterator.h:293:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::reverse_iterator<_Iterator>'
In file included from /opt/local/include/gcc47/c++/bits/stl_algobase.h:65:0,
from /opt/local/include/gcc47/c++/bits/char_traits.h:41,
from /opt/local/include/gcc47/c++/ios:41,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/stl_pair.h:206:5: note: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/opt/local/include/gcc47/c++/bits/stl_pair.h:206:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::pair<_T1, _T2>'
In file included from /opt/local/include/gcc47/c++/iosfwd:42:0,
from /opt/local/include/gcc47/c++/ios:39,
from /opt/local/include/gcc47/c++/ostream:40,
from /opt/local/include/gcc47/c++/iostream:40,
from Driver.cpp:1:
/opt/local/include/gcc47/c++/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
/opt/local/include/gcc47/c++/bits/postypes.h:218:5: note: template argument deduction/substitution failed:
In file included from /opt/local/include/gcc47/c++/algorithm:63:0,
from SeparateChaining.h:8,
from Driver.cpp:8:
/opt/local/include/gcc47/c++/bits/stl_algo.h:135:7: note: 'Symbol' is not derived from 'const std::fpos<_StateT>'
Try
hashtable.insert(symbols[j]);
同样,您不使用increment
, line_count
或table_size
,您只需设置它们。
解释:您试图插入整个向量,而不是它的元素,因此数据类型不匹配。通过使用数组表示法,您可以获取想要插入的实际元素。
为什么你甚至使用向量而不是直接插入你的符号到哈希表?
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 运行同一解决方案的另一个项目的项目
- 挂起和取消挂起一个文件DLL
- 用C++中的一个变量定义一个常量
- 函数向量_指针有不同的原型,我可以构建一个吗
- 在c++中用vector填充一个简单的动态数组
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 得到错误"left of '.toString' must have class/struct/union",即使 toString 应该有一个合适的对象
- 是否有一个专有名称,例如struct的
- 指向struct的指针,包含指向对象的指针,我想调用一个函数
- 为 std::vector <struct>创建一个 getter 函数
- 初始化struct向量的向量的好方法(每个向量都有一个初始值)
- 为什么我的struct只存储最后一个字符串,而不是每一个
- 创建一个Struct,然后通过引用传递一个带有这些Struct的vector
- 为什么我的struct stat有一个st_mtim而不是st_mtime字段?
- 对std::pair和struct:的数组进行排序,哪一个更快
- 是否可以有一个std::vector of struct和一个fexible数组成员
- 在哈希表中插入一个struct对象