本文整理汇总了C++中HT类的典型用法代码示例。如果您正苦于以下问题:C++ HT类的具体用法?C++ HT怎么用?C++ HT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
inline static
void set(HT &ht,K const& key,V const &v=V())
{
std::pair<typename HT::iterator,bool> r=ht.insert(value_type(key,v));
if (!r.second)
const_cast<V&>(r.first->second)=v;
}
示例2: getInfSeq
//***********************************************************************
void getInfSeq(const HT& T, char name)
{
if (!T.empty()) {
cout << name << " = <";
int s = T.size();
for (int i = 0; i < s; ++i) {
for (HT::const_iterator it = T.cbegin(); it != T.cend(); ++it)
if (it->second == i) {
cout << it->first << ' ';
break;
}
}
cout << "\b>" << endl;
}
else
cout << name << " - Пустая последовательность!"<<endl;
}
示例3: mapOr
void mapOr(const HT& leftExp, const HT& rightExp, HT& result)
{
result.clear();
vector<int> vl(leftExp.size()), vr(rightExp.size()), vm;
transform(leftExp.begin(), leftExp.end(), vl.begin(), keySel);
transform(rightExp.begin(), rightExp.end(), vr.begin(), keySel);
sort(vl.begin(), vl.end());
sort(vr.begin(), vr.end());
set_union(vl.cbegin(), vl.cend(), vr.cbegin(), vr.cend(), inserter(vm, vm.begin()));
int i=0;
for (auto it = vm.cbegin(); it != vm.cend(); ++it, ++i)
result.insert(HT::value_type((*it), i));
}
示例4: testHashTableFullCoverage
bool testHashTableFullCoverage(const HT &hashTable,
const hyrise::storage::atable_ptr_t &table,
const field_list_t &columns) {
bool result = true;
for (pos_t row = 0; row < table->size(); ++row) {
pos_list_t positions = hashTable.get(table, columns, row);
if (positions.empty()) {
result = false;
break;
}
}
return result;
}
示例5: fileSet
//***********************************************************************
int fileSet(HT& T, char name='a')
{
T.clear();
FILE* file;
int size, t;
char n[6] = " .txt";
n[0] = name;
if (!(file = fopen(n, "r")))
return 1; //Файла не существует
fseek(file, 0, SEEK_END);
if (!ftell(file))
return 2; //Файл пустой
rewind(file);
fscanf(file, "%d", &size);
for (int i = 0; i<size; ++i)
{
fgetc(file);
fscanf(file, "%d", &t);
T.insert(HT::value_type(t, i));
}
fclose(file);
return 0;
}
示例6: main
int main(){
HT myTable;
cout<<"Inserting..."<<endl;
myTable.insert(2,"mike");
myTable.insert(12,"kalgecin");
myTable.insert(52,"michael");
//cout<<"1"<<endl;
myTable.insert(59,"yasin");
//cout<<2<<endl;
myTable.insert(51,"frank");
//cout<<3<<endl;
cout<<"Done inserting"<<endl;
try{
cout<<"kalgecin is "<<myTable.find("kalgecin")<<endl;
cout<<"69 is "<<myTable.find(59)<<endl;
}catch(string s){
cout<<s<<endl;
}
return 0;
}
示例7: concat
//***********************************************************************
void concat(HT& leftExp, const HT &rightExp)
{
if (!rightExp.empty()) {
int newPos = leftExp.size();
int s = rightExp.size();
for (int i = 0; i < s; ++i) {
for (HT::const_iterator it = rightExp.cbegin(); it != rightExp.cend(); ++it)
if (it->second == i) {
leftExp.insert(HT::value_type((*it).first, newPos++));
break;
}
}
}
}
示例8: excl
//***********************************************************************
int excl(HT& leftExp, const HT& rightExp)
{
int stPos = -1, curPos = -1, step = 0;
if (!rightExp.empty() && !leftExp.empty()) {
if (leftExp.size() < rightExp.size())
return 1;
int sizeL = leftExp.size();
int sizeR = rightExp.size();
for (int i = 0; i < sizeL && (curPos - stPos + 1) != sizeR; ++i) {
for (HT::const_iterator itL = leftExp.cbegin(); itL != leftExp.cend(); ++itL)
if (itL->second == i) {
if (stPos == -1) {
HT::const_iterator itR = rightExp.cbegin();
for (; itR != rightExp.cend() && itR->second != 0; ++itR);
if (itR->first == itL->first)
curPos = stPos = itL->second;
}
else
for (HT::const_iterator itR = rightExp.cbegin(); itR != rightExp.cend(); ++itR)
if (itR->first == itL->first) {
if (itL->second > curPos && itL->second - curPos == 1) {
curPos = itL->second;
}
}
if ((curPos - stPos +1) == sizeR)
break;
if (curPos != itL->second)
stPos = -1;
}
}
if(stPos!=-1)
erase(leftExp, stPos, stPos + rightExp.size()-1);
else return 1;
}
return 0;
}
示例9:
cache_set( InputIterator first, InputIterator last,
size_type n, const hasher& h,
const key_equal& k )
: m_ht( 2 * n, h, k )
{
m_ht.insert( first, last );
}
示例10: empty
/** Test for empty.
* @return true if the cache_set does not contains items.
*/
bool empty() const { return m_ht.empty(); }
示例11: max_size
/** Get the maximum size of the set.
* This corresponds to the maximum number of item that the set can
* contain.
* @return the maximum number of elements
*/
size_type max_size() const { return m_ht.max_size(); }
示例12: bucket_count
/** Get the number of allocated buckets.
* This corresponds to the max_size() value.
* @return the number of buckets
* @see max_size
*/
size_type bucket_count() const { return m_ht.bucket_count(); }
示例13: swap
/** Swap the content of two cache_set.
*
* @param other another cache_set
*/
void swap( cache_set& other ) { m_ht.swap( other.m_ht ); }
示例14: size
/** Get the size of the cache_set.
* The size represent the number of non-empty elements that can be
* found in the container.
* @return the number of elements in the set
*/
size_type size() const { return m_ht.size(); }
示例15: end
/// Get a const iterator to the end of the table
const_iterator end() const { return m_ht.end(); }