本文整理汇总了C++中EntryList::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ EntryList::erase方法的具体用法?C++ EntryList::erase怎么用?C++ EntryList::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntryList
的用法示例。
在下文中一共展示了EntryList::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stat
/**
* 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;
}
示例2: remove_entry
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);
}
}