bool Profile::hasInEntryList(EntryList &list, QString value) { for (EntryList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it) if ((*it).name == value) return true; return false; }
/** * This method performs the search and displays * the result to the screen. */ void Kiten::searchAndDisplay( const DictQuery &query ) { /* keep the user informed of what we are doing */ _statusBar->showMessage( i18n( "Searching..." ) ); /* This gorgeous incantation is all that's necessary to fill a DictQuery with a query and an Entrylist with all of the results form all of the requested dictionaries */ EntryList *results = _dictionaryManager.doSearch( query ); /* if there are no results */ if ( results->size() == 0 ) //TODO: check here if the user actually prefers this { //create a modifiable copy of the original query DictQuery newQuery( query ); bool tryAgain = false; do { //by default we don't try again tryAgain = false; //but if the matchtype is changed we try again if ( newQuery.getMatchType() == DictQuery::Exact ) { newQuery.setMatchType( DictQuery::Beginning ); tryAgain = true; } else if ( newQuery.getMatchType() == DictQuery::Beginning ) { newQuery.setMatchType( DictQuery::Anywhere ); tryAgain = true; } //try another search if ( tryAgain ) { delete results; results = _dictionaryManager.doSearch( newQuery ); //results means all is ok; don't try again if ( results->size() > 0 ) { tryAgain = false; } } } while ( tryAgain ); } /* synchronize the history (and store this pointer there) */ addHistory( results ); /* Add the current search to our drop down list */ _inputManager->setSearchQuery( results->getQuery() ); /* suppose it's about time to show the users the results. */ displayResults( results ); }
SnapshotEntrySeqMap BuddyCoreSnapshotI::getFriends(const ::MyUtil::IntSeq& ids, const Ice::Current& current) { SnapshotEntrySeqMap result; ServiceI& service = ServiceI::instance(); for (IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) { EntryListHolderPtr owner = service.findObject<EntryListHolderPtr>( CATEGORY_ENTRY, *it); if (!owner) { continue; } EntryList ownerList = owner->getAll(); SnapshotEntrySeq ownerSnap; for (EntryList::iterator ownerIt = ownerList.begin(); ownerIt != ownerList.end(); ++ownerIt) { int ownerToId = ownerIt->to; uint32_t ownerDesc = ownerIt->desc; //MCE_INFO("Owner:"<<*it <<" Buddy:"<<ownerToId << " Desc:"<<ownerDesc); if (ownerDesc!=DESC_FRIEND) { continue; } SnapshotEntry entryOwner; entryOwner.toId = ownerToId; entryOwner.desc = BuddyDescHelper::translateDesc(ownerDesc); ownerSnap.push_back(entryOwner); } result[*it] = ownerSnap; } return result; }
void Parser::parseExpressionList(SymbolTableEntry* prevEntry){ EntryList expList = *(new EntryList()); //expList.push_back(prevEntry); expList.push_back(parseExpression()); parseExpressionListPrime(expList); m_code->generateCall(prevEntry, expList); }
void print() { std::map<int, double> totals; std::cerr << "Timings: " << std::endl; // print out all the entries. //std::sort(root_entries.begin(), root_entries.end(), cmp()); printEntries(std::cerr, root_entries, " ", -1.0); for (EntryList::const_iterator it = entries.begin(); it != entries.end(); ++it) { totals[(*it).id] += (*it).time; } std::cerr << std::endl; std::cerr << "Totals: " << std::endl; std::vector<std::pair<int, double> > sorted_totals; sorted_totals.reserve(totals.size()); for (std::map<int,double>::iterator it = totals.begin(); it != totals.end(); ++it) { sorted_totals.push_back(*it); } std::sort(sorted_totals.begin(), sorted_totals.end(), cmp()); for (std::vector<std::pair<int,double> >::iterator it = sorted_totals.begin(); it != sorted_totals.end(); ++it) { std::cerr << " "; std::string str = names[it->first]; if (str.empty()) { std::cerr << "(" << it->first << ")"; } else { std::cerr << str; } std::cerr << " - " << it->second << "s " << std::endl; } }
void Code::generateCall(SymbolTableEntry* entry, EntryList& eList) { EntryList::iterator it; for(it = eList.begin(); it != eList.end(); it++) generate(cd_APARAM,NULL,NULL,*it); generate(cd_CALL,entry,NULL,NULL); }
/* This function processes the command passed in. in: command in/out: list and listSize */ void processCommand(char command, EntryList& list) { TaskList entry; char courseName[iMAX_CHAR]; char a_cAssignmentDescription[iMAX_CHAR]; char a_cDueDate[iMAX_CHAR]; switch (command) { case 'a': readInEntry(entry); list.addEntry(entry); // this has access to TaskList functions break; case 'l': cout << endl; list.printAll(); cout << endl << endl; break; case 's': readInName(courseName); list.searchEntry(courseName, entry); break; case 'r': readInName(courseName); list.searchDeleteEntry(courseName, entry); break; default: cout << endl << "Illegal Command!" << endl; break; } }
virtual void append_result(CaliperMetadataDB& db, EntryList& list) { if (m_count > 0) { list.push_back(Entry(m_config->get_avg_attribute(db), m_sum.to_double() / m_count)); list.push_back(Entry(m_config->get_min_attribute(db), m_min)); list.push_back(Entry(m_config->get_max_attribute(db), m_max)); } }
bool insert( Entry& e , vec_type& v ) { if ( entries.find( e.ID() ) != entries.end() ) { return false; } for ( typename vec_type::size_type ii=0; ii<v.size(); ++ii ) { table[ii].insert( EDE( e , v[ii]) ); } entries.insert( e.ID() ); return true; }
/** * Examine the DictQuery and farm out the search to the specialized dict * managers. Note that a global search limit will probably be implemented * either here or in the DictFile implementations... probably both * * @param query the query, see DictQuery documentation */ EntryList *DictionaryManager::doSearch( const DictQuery &query ) const { EntryList *ret = new EntryList(); #if 0 if( query.getMeaning() == "(libkiten)" ) { ret->append( new debug_entry( "Summary of libkiten data" ) ); foreach( const QString &dict, listDictionaries() ) { ret->append( new debug_entry( dict ) ); }
void MamdaOrderBookPriceLevel::MamdaOrderBookPriceLevelImpl::clearEntries ( EntryList& entries) { EntryList::iterator itr = entries.begin(); EntryList::iterator end = entries.end(); for (; itr != end; itr++) { delete *itr; } entries.clear(); }
/** * Change the maximum size of the cache. If the new size is larger * than the old size, then the oldest entries in the cache are * removed. * * A size of 0 means unlimited. */ void setMaxSize(unsigned int maxSize) { boost::unique_lock<boost::mutex> l(lock); if (maxSize != 0) { int toRemove = cache.size() - maxSize; for (int i = 0; i < toRemove; i++) { string filename(entries.back()->filename); entries.pop_back(); cache.erase(filename); } } this->maxSize = maxSize; }
NameIterationTester::EntryList NameIterationTester::getNamesFromIterator (CNameIterator& iter) { EntryList res; valtype name; CNameData data; while (iter.next (name, data)) res.push_back (std::make_pair (name, data)); return res; }
Profile::EntryList Profile::list(List type) { EntryList parentList; if (m_parent) parentList = m_parent->list(type); EntryList list = parentList; for (EntryList::iterator it = list.begin(); it != list.end(); ++it) (*it).derived = true; QStringList &personalList = listByType(type); for (QStringList::const_iterator it = personalList.begin(); it != personalList.end(); ++it) list.append(Entry(*it, false)); return list; }
void ConfigSection::remove_entry(const char* key) { E_ASSERT(key != NULL); int klen = strlen(key); unsigned int hh = do_hash(key, klen); EntryListIter it = entry_list.begin(); for(; it != entry_list.end(); ++it) { ConfigEntry* e = *it; if(hh == e->hash && strncmp(e->key, key, e->keylen) == 0) entry_list.erase(it); } }
DB_Error DataBaseSqlite::AddUser(shared_ptr<User> user) { DB_Error ret = CreateTable("User"); if (ret == DB_OK) { EntryList entries = m_pTableComponent->GetTableFormat("User"); PDEBUG ("entry size: %lu\n", entries.size()); if (!entries.empty()) { string sql(INSERT_TABLE); sql += string("User") + VALUE + LPARENT; EntryList::iterator iter = entries.begin(); EntryList::iterator end = entries.end(); for (; iter != end;) { sql += "@" + iter->name; if (++iter != end) { sql += ", "; } } sql += string(RPARENT) + SEMI; SqliteCommand cmd(this, sql); // Ugly hard code!! PDEBUG ("Begin binding\n"); ret = cmd.Bind("@name", user->name()); ret = ret ? ret : cmd.Bind("@uuid", user->uuid()); int64 date = 0; if (user->has_reg_date()) { ret = user->reg_date(); } ret = ret ? ret : cmd.Bind("@reg_date", date); date = 0; if (user->has_last_login()) { date = user->last_login(); } ret = ret ? ret : cmd.Bind("@last_login", date); // Bind others ... ret = ret ? ret : cmd.Execute(); // Execute .... } } return ret; }
void print( std::ostream& o = std::cout ) const { o << "ED LOOKUP TABLE\n"; for ( typename EDTable::size_type ii=0; ii<table.size(); ++ii ) { o << "\tDIMENSION: " << ii << '\n'; for ( typename DimensionEntries::const_iterator jj=table[ii].begin() ; jj!=table[ii].end(); ++jj ) { (jj)->print(o); } } o << "\tCURRENT ENTRIES:\n"; for ( typename EntryList::const_iterator ii=entries.begin(); ii!=entries.end(); ++ii ) { o << *ii << '\n'; } }
ConfigEntry* ConfigSection::find_entry(const char* key) { E_ASSERT(key != NULL); int klen = strlen(key); unsigned int hh = do_hash(key, klen); EntryListIter it = entry_list.begin(), it_end = entry_list.end(); for (; it != it_end; ++it) { ConfigEntry* e = *it; if (hh == e->hash && strncmp(e->key, key, e->keylen) == 0) return e; } return NULL; }
void BuddyRelationLogic::addBuddyRelationData(Ice::Int id, const BuddyRelationDataPtr& data) { EntryList list; ostringstream info; for (RelationEntryList::iterator en = data->list.begin(); en != data->list.end(); ++en) { Entry entry(en->id, BuddyDescHelper::translateInt(en->desc)); list.push_back(entry); info << "<" << en->id << "/" << BuddyDescHelper::translateInt(en->desc) << "> "; } MCE_DEBUG("BuddyRelationLogic::addBuddyRelationData, id "<< id << " relations " << info.str()); sort(list.begin(), list.end(), less_entry()); EntryListHolderPtr holder = new EntryListHolder(id, list); writeObject(id, holder); }
/** * @copydoc CGIBase::GetValues(const std::string &name) const */ const EntryList GetValues(const std::string &name) const { EntryList list; qentobj_t *obj; for (obj = preq_->first; obj; obj = obj->next) { if ((!name.empty()) && (name != static_cast<std::string>(obj->name))) { continue; } list.insert( make_pair(static_cast<std::string>(obj->name), static_cast<std::string>(static_cast<String>(obj->data)))); } return list; }
bool YumemiArchive_Base::DeserializeList(std::istream &is, uint32_t list_count, uint32_t filesize, EntryList &list) { for(uint16_t i = 0; i < list_count; ++i) { Entry entry; uint16_t magic; char padding[8]; is.read((char *)&magic, 2); if(is.fail()) return false; is.read((char *)&entry.key, 1); if(is.fail()) return false; is.read(entry.name, 13); if(is.fail()) return false; is.read((char *)&entry.compsize, 2); if(is.fail()) return false; is.read((char *)&entry.origsize, 2); if(is.fail()) return false; is.read((char *)&entry.offset, 4); if(is.fail()) return false; is.read(padding, 8); if(is.fail()) return false; if(magic == 0) break; if(magic != 0x9595 && magic != 0xF388) return false; if(entry.offset >= filesize) return false; if((uint32_t)filesize - entry.offset < entry.compsize) return false; if(!ValidateName(entry.name)) return false; list.push_back(entry); } return true; }
/* * Add new key/value, but first check * do we alread have and key, so if * we do, just update value */ void ConfigSection::add_entry(const char* key, const char* value) { E_ASSERT(key != NULL); E_ASSERT(value != NULL); ConfigEntry* e = find_entry(key); if (!e) { e = new ConfigEntry; e->keylen = strlen(key); e->valuelen = strlen(value); e->key = strdup(key); e->value = strdup(value); // hash the key e->hash = do_hash(e->key, e->keylen); E_ASSERT(e->key != NULL); E_ASSERT(e->value != NULL); #ifdef CONFIG_INTERNAL printf("Adding: |%s| = |%s| hash = %i section = %s\n", e->key, e->value, e->hash, sname); #endif entry_list.push_back(e); } else { #ifdef CONFIG_INTERNAL printf("!!! found duplicate for %s\n", e->key); #endif free(e->value); e->valuelen = strlen(value); e->value = strdup(value); E_ASSERT(e->value != NULL); } }
virtual void append_result(CaliperMetadataDB& db, EntryList& list) { uint64_t count = m_count.load(); if (count > 0) list.push_back(Entry(m_config->attribute(db), Variant(CALI_TYPE_UINT, &count, sizeof(uint64_t)))); }
/* * Add new key/value, but first check * do we alread have and key, so if * we do, just update value */ void ConfigSection::add_entry(const char* key, const char* value) { E_ASSERT(key != NULL); E_ASSERT(value != NULL); ConfigEntry* e = find_entry(key); if (!e) { e = new ConfigEntry; e->keylen = strlen(key); e->valuelen = strlen(value); e->key = strdup(key); e->value = strdup(value); e->hash = do_hash(e->key, e->keylen); E_ASSERT(e->key != NULL); E_ASSERT(e->value != NULL); entry_list.push_back(e); } else { free(e->value); e->valuelen = strlen(value); e->value = strdup(value); E_ASSERT(e->value != NULL); } }
// compare this to Table::list_entries(), which uses the underlying map. // Class keeps an explicit list of entries so it can deliver entries // in _order of declaration_. No doubt there is more than one way to // do this void Class::list_entries(EntryList &el, int flags) { if ((flags & DO_PARENT) && base_class() != NULL) base_class()->list_entries(el,flags); EntryList::iterator eli; for(eli = m_entries.begin(); eli != m_entries.end(); ++eli) if (check_entry(*eli,flags)) el.push_back(*eli); }
void Parser::parseExpressionListPrime(EntryList& expList){ if(isNext(tc_COMMA)){ match(tc_COMMA); expList.push_back(parseExpression()); parseExpressionListPrime(expList); } }
bool BuddyCoreSnapshotI::loadIncreament() { multimap<int, SnapshotEntrySeqMap> incs; { IceUtil::Mutex::Lock lock(_increamentsMutex); if (_increaments.empty()) { MCE_DEBUG("Increaments is empty."); return false; } incs.swap(_increaments); } int usersize4log = 0; for (multimap<int, SnapshotEntrySeqMap>::iterator it = incs.begin(); it != incs.end(); ++it) { SnapshotEntrySeqMap smaps = it -> second; usersize4log += smaps.size(); for (SnapshotEntrySeqMap::iterator smapsIt = smaps.begin(); smapsIt != smaps.end(); ++smapsIt) { int userId = smapsIt -> first; EntryList el; for (SnapshotEntrySeq::iterator sentryIt = smapsIt->second.begin(); sentryIt != smapsIt->second.end(); ++sentryIt) { SnapshotEntry entry = *sentryIt; switch (entry.desc) { case Friend: el.push_back(Entry(entry.toId, DESC_FRIEND)); break; case Apply: el.push_back(Entry(entry.toId, DESC_APPLY)); break; case Block: el.push_back(Entry(entry.toId, DESC_BLOCK)); break; default: continue; break; } } ServiceI::instance().addObject(new EntryListHolder(userId, el), CATEGORY_ENTRY, userId); MCE_DEBUG("loadIncreament for id="<<userId<<" done"); } } MCE_INFO("loadIncreament for "<<usersize4log<<" users in "<<incs.size() <<" batches. done."); return true; }
/** * Stats the given file. If <tt>throttleRate</tt> seconds have passed since * the last time stat() was called on this file, then the file will be * re-stat()ted, otherwise the cached stat information will be returned. * * @param filename The file to stat. * @param stat A pointer to a stat struct; the retrieved stat information * will be stored here. * @param throttleRate Tells this CachedFileStat that the file may only * be statted at most every <tt>throttleRate</tt> seconds. * @return 0 if the stat() call succeeded or if the cached stat information was used; * -1 if something went wrong while statting the file. In the latter * case, <tt>errno</tt> will be populated with an appropriate error code. * @throws SystemException Something went wrong while retrieving the * system time. stat() errors will <em>not</em> result in * SystemException being thrown. * @throws boost::thread_interrupted */ int stat(const string &filename, struct stat *buf, unsigned int throttleRate = 0) { boost::unique_lock<boost::mutex> l(lock); EntryMap::iterator it(cache.find(filename)); EntryPtr entry; int ret; if (it == cache.end()) { // Filename not in cache. // If cache is full, remove the least recently used // cache entry. if (maxSize != 0 && cache.size() == maxSize) { EntryList::iterator listEnd(entries.end()); listEnd--; string filename((*listEnd)->filename); entries.pop_back(); cache.erase(filename); } // Add to cache as most recently used. entry = EntryPtr(new Entry(filename)); entries.push_front(entry); cache[filename] = entries.begin(); } else { // Cache hit. entry = *it->second; // Mark this cache item as most recently used. entries.erase(it->second); entries.push_front(entry); cache[filename] = entries.begin(); } ret = entry->refresh(throttleRate); *buf = entry->info; return ret; }
void FillTask::handle() { ObjectResultPtr result = new ObjectResult(); for ( std::map<long, Ice::ObjectPtr>::const_iterator it = _buddyData->data.begin(); it!= _buddyData->data.end(); ++it ){ BuddyRelationDataPtr data = BuddyRelationDataPtr::dynamicCast(it->second); EntryList list; list.reserve(data->list.size()); for(RelationEntryList::iterator en = data->list.begin(); en != data->list.end(); ++en) { Entry entry(en->id, BuddyDescHelper::translateInt(en->desc)); list.push_back(entry); } sort(list.begin(), list.end(), less_entry()); EntryListHolderPtr holder = new EntryListHolder(it->first, list); result->data[it->first] = holder; } _logic->writeObjects(result); }
int CustomerData::findEntry(const EntryList& entries, const std::string& stock) { for(int i = 0; i < entries.size(); ++i) { if (entries[i].first == stock) return entries[i].second; } return -1; }