本文整理汇总了C++中hash_set类的典型用法代码示例。如果您正苦于以下问题:C++ hash_set类的具体用法?C++ hash_set怎么用?C++ hash_set使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了hash_set类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculaCertos
// Alínea D
int Aposta::calculaCertos(const hash_set<int> &sorteio) const{
hash_set<int>::iterator it;
int c =0;
for (it=numeros.begin(); it!=numeros.end(); it++)
if (sorteio.find(*it)!=sorteio.end()) c++;
return c;
}
示例2: updateHelper
static void updateHelper (SLE::ref entry,
hash_set< uint256 >& seen,
OrderBookDB::IssueToOrderBook& destMap,
OrderBookDB::IssueToOrderBook& sourceMap,
hash_set< Issue >& XDVBooks,
int& books)
{
if (entry->getType () == ltDIR_NODE &&
entry->isFieldPresent (sfExchangeRate) &&
entry->getFieldH256 (sfRootIndex) == entry->getIndex())
{
Book book;
book.in.currency.copyFrom (entry->getFieldH160 (sfTakerPaysCurrency));
book.in.account.copyFrom (entry->getFieldH160 (sfTakerPaysIssuer));
book.out.account.copyFrom (entry->getFieldH160 (sfTakerGetsIssuer));
book.out.currency.copyFrom (entry->getFieldH160 (sfTakerGetsCurrency));
uint256 index = getBookBase (book);
if (seen.insert (index).second)
{
auto orderBook = std::make_shared<OrderBook> (index, book);
sourceMap[book.in].push_back (orderBook);
destMap[book.out].push_back (orderBook);
if (isXDV(book.out))
XDVBooks.insert(book.in);
++books;
}
}
}
示例3: print
void print(hash_set &S) {
iterator_t p = S.begin();
while(p!=S.end()) {
cout << S.retrieve(p) << " ";
p = S.next(p);
}
cout << endl;
}
示例4: srand
void LinearSNNClassifier::checkgradRowSparse(const vector<Example>& examples, mat& Wd, const mat& gradWd, const string& mark, int iter,
const hash_set<int>& sparseRowIndexes, const mat& ft) {
//Random randWdRowcheck = new Random(iter + "Row".hashCode() + hash));
int charseed = mark.length();
for (int i = 0; i < mark.length(); i++) {
charseed = (int) (mark[i]) * 5 + charseed;
}
srand(iter + charseed);
std::vector<int> idRows, idCols;
idRows.clear();
idCols.clear();
if (sparseRowIndexes.empty()) {
for (int i = 0; i < Wd.n_rows; ++i)
idRows.push_back(i);
} else {
hash_set<int>::iterator it;
for (it = sparseRowIndexes.begin(); it != sparseRowIndexes.end(); ++it)
idRows.push_back(*it);
}
for (int idx = 0; idx < Wd.n_cols; idx++)
idCols.push_back(idx);
random_shuffle(idRows.begin(), idRows.end());
random_shuffle(idCols.begin(), idCols.end());
int check_i = idRows[0], check_j = idCols[0];
double orginValue = Wd(check_i, check_j);
Wd(check_i, check_j) = orginValue + 0.001;
double lossAdd = 0.0;
for (int i = 0; i < examples.size(); i++) {
Example oneExam = examples[i];
lossAdd += computeScore(oneExam);
}
Wd(check_i, check_j) = orginValue - 0.001;
double lossPlus = 0.0;
for (int i = 0; i < examples.size(); i++) {
Example oneExam = examples[i];
lossPlus += computeScore(oneExam);
}
double mockGrad = (lossAdd - lossPlus) / (0.002 * ft(check_i, check_j));
mockGrad = mockGrad / examples.size();
double computeGrad = gradWd(check_i, check_j);
printf("Iteration %d, Checking gradient for %s[%d][%d]:\t", iter, mark.c_str(), check_i, check_j);
printf("mock grad = %.18f, computed grad = %.18f\n", mockGrad, computeGrad);
Wd(check_i, check_j) = orginValue;
}
示例5: main
int main(){
for(int i=0;i<100;i++){
tab.insert(2*i + 1);
}
for(hash_set<int>::iterator iter = tab.begin();
iter!=tab.end();
iter++){
cout<<(*iter)<<" ";
}
cout<<endl;
return 0;
}
示例6: trim_entropy_filter
int trim_entropy_filter(vector<string>* keep_words, hash_set<string>& cad_words_set, WordInfoMap& wordinfo_map)
{
keep_words->reserve(cad_words_set.size());
for (hash_set<string>::iterator it = cad_words_set.begin(); it != cad_words_set.end(); ++it) {
WordInfoMap::iterator it_map = wordinfo_map.find(*it);
if (it_map == wordinfo_map.end()) {
fprintf(stderr, "WARNING, word[%s] in cad_word, not in word_info", it->c_str());
continue;
}
if (it_map->first.size() <= WORD_LEN - 4 && it_map->second.calc_is_keep()) {
keep_words->push_back(*it);
}
}
return 0;
}
示例7: markReachableFunctionsExternallyAccessible
void TDDataStructures::markReachableFunctionsExternallyAccessible(DSNode *N,
hash_set<DSNode*> &Visited) {
if (!N || Visited.count(N)) return;
Visited.insert(N);
for (unsigned i = 0, e = N->getNumLinks(); i != e; ++i) {
DSNodeHandle &NH = N->getLink(i);
if (DSNode *NN = NH.getNode()) {
std::vector<const Function*> Functions;
NN->addFullFunctionList(Functions);
ArgsRemainIncomplete.insert(Functions.begin(), Functions.end());
markReachableFunctionsExternallyAccessible(NN, Visited);
}
}
}
示例8: ReadNum
void ReadNum(ifstream &input,hash_set<long> &myset)
{
long num;
while(!input.fail()){
input>>num;
myset.insert(num);
}
}
示例9: static_string
static_string () {
if (!s_static_string_set) {
s_static_string_set = VNEW hash_set<string>;
}
string value ( "" );
const string &v = s_static_string_set->insert ( value );
m_str = v.c_str();
}
示例10: static_string
static_string ( const char *str ) {
euint32 hash_value = calc_hashnr ( str, _strlen ( str ) );
xhn::hash_set<string>::bucket& b = s_static_string_set.get_bucket(hash_value);
{
SpinLock::Instance inst = b.m_lock.Lock();
xhn::list<xhn::string>::iterator iter = b.begin();
xhn::list<xhn::string>::iterator end = b.begin();
for (; iter != end; iter++) {
if (*iter == str) {
m_str = (*iter).c_str();
return;
}
}
}
string value ( str );
const string &v = s_static_string_set.insert ( value );
m_str = v.c_str();
}
示例11: ComputePostOrder
void TDDataStructures::ComputePostOrder(const Function* F,
hash_set<DSGraph*> &Visited,
std::vector<DSGraph*> &PostOrder) {
if (F->isDeclaration()) return;
DSGraph* G = getOrFetchDSGraph(F);
if (Visited.count(G)) return;
Visited.insert(G);
// Recursively traverse all of the callee graphs.
for (DSGraph::fc_iterator CI = G->fc_begin(), CE = G->fc_end(); CI != CE; ++CI){
Instruction *CallI = CI->getCallSite().getInstruction();
for (calleeTy::iterator I = callee.begin(CallI),
E = callee.end(CallI); I != E; ++I)
ComputePostOrder(*I, Visited, PostOrder);
}
PostOrder.push_back(G);
}
示例12: containsArrayOps
bool containsArrayOps(const ASTNode& n, hash_set<int> & visited)
{
if (n.GetIndexWidth() > 0)
return true;
if (n.Degree() ==0)
return false;
if (visited.find(n.GetNodeNum()) != visited.end())
return false;
visited.insert(n.GetNodeNum());
for (int i =0; i < n.Degree();i++)
if (containsArrayOps(n[i],visited))
return true;
return false;
}
示例13: ComputeNodesReachableFrom
/// ComputeNodesReacahbleFrom - Compute the set of nodes in the specified
/// inverse graph that are reachable from N. This is a simple depth first
/// search.
///
static void ComputeNodesReachableFrom(DSNode *N,
std::set<std::pair<DSNode*,DSNode*> > &InverseGraph,
hash_set<const DSNode*> &Reachable) {
if (!Reachable.insert(N).second) return; // Already visited!
std::set<std::pair<DSNode*,DSNode*> >::iterator I =
InverseGraph.lower_bound(std::make_pair(N, (DSNode*)0));
for (; I != InverseGraph.end() && I->first == N; ++I)
ComputeNodesReachableFrom(I->second, InverseGraph, Reachable);
}
示例14: numberOfReadsLessThan
// counts the number of reads. Shortcut when we get to the limit.
void numberOfReadsLessThan(const ASTNode& n, hash_set<int>& visited, int& soFar,
const int limit)
{
if (n.isAtom())
return;
if (visited.find(n.GetNodeNum()) != visited.end())
return;
if (n.GetKind() == READ)
soFar++;
if (soFar > limit)
return;
visited.insert(n.GetNodeNum());
for (size_t i = 0; i < n.Degree(); i++)
numberOfReadsLessThan(n[i], visited, soFar, limit);
}
示例15: fun
int fun(){
ut i, t;
Node one = {0}, next;
tab.clear();
for(i=0;i<SIZ;i++){
cin>>t;
if(t){
one.m |= (1<<i);
one.s++;
}
}
priority_queue<Node, vector<Node>, Node::cmp> q;
q.push(one);
while(!q.empty()){
one=q.top(); q.pop();
if(one.m == 0)
break;
for(i=0;i<SIZ;i++){
next = one;
next.o |= (1<<i);
set(next,i);
if(tab.find(next.m) == tab.end()){
q.push(next);
tab.insert(next.m);
}
}
}
output(one.o);
return 0;
}