本文整理汇总了C++中std::map::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ map::swap方法的具体用法?C++ map::swap怎么用?C++ map::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::map
的用法示例。
在下文中一共展示了map::swap方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateWindowPlacements
void CALLBACK UpdateWindowPlacements(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
if(!IsUpdateScheduled)
{
KillTimer(hwnd, idEvent);
return;
}
if(PendingUpdates1.size())
printf("Updating WindowPlacements\n");
for(auto it = PendingUpdates1.begin(); it != PendingUpdates1.end(); ++it)
{
WindowPlacements[it->first] = it->second;
}
PendingUpdates1.clear();
PendingUpdates0.swap(PendingUpdates1);
if(PendingUpdates1.size())
{
printf("Scheduling update\n");
SetTimer(0, 0, ScheduleTimerValue, UpdateWindowPlacements);
}
else
{
KillTimer(hwnd, idEvent);
IsUpdateScheduled = false;
}
}
示例2: Init
typename boost::enable_if<std::is_enum<K>, bool>::type
Init(std::map<K, T>& map) const
{
std::map<K, T> tmp;
map.swap(tmp);
auto it = GetValueToNameMap(K()).begin();
auto it2 = tmp.begin();
for (; it != GetValueToNameMap(K()).end() && it2 != tmp.end(); ++it, ++it2)
{
Init(bond::mapped_at(map, it->first) = it2->second);
}
return false;
}
示例3: KeepOnlyReferencedElement
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
std::map<IndexT,Mat3>& map_Mat3)
{
std::map<IndexT,Mat3> map_infered;
for (std::map<IndexT,Mat3>::const_iterator iter = map_Mat3.begin();
iter != map_Mat3.end(); ++iter)
{
if (set_remainingIds.count(iter->first))
{
map_infered.insert(*iter);
}
}
map_Mat3.swap(map_infered);
}
示例4: while
bool ResDirMan::parseFilesMD5(const std::string &filesMD5, std::map<std::string, FileAttr> &fileMD5Map)
{
std::map<std::string, FileAttr> map;
size_t length = filesMD5.length();
size_t lineStart = filesMD5.find_first_not_of(" \t\r\n");
while (lineStart!=std::string::npos && lineStart<length)
{
size_t lineEnd = filesMD5.find_first_of("\r\n", lineStart+1);
if (lineEnd == std::string::npos)
lineEnd = length;
std::string line = filesMD5.substr(lineStart, lineEnd-lineStart);
size_t filePathEnd = line.find_first_of(" \t\r\n");
if (filePathEnd == std::string::npos)
return false;
std::string filePath = line.substr(0, filePathEnd);
size_t md5Start = line.find_first_not_of(" \t\r\n", filePathEnd+1);
if (md5Start == std::string::npos)
return false;
size_t md5End = line.find_first_of(" \t\r\n", md5Start+1);
if (md5End == std::string::npos)
return false;
std::string md5 = line.substr(md5Start, md5End-md5Start);
size_t sizeStart = line.find_first_not_of(" \t\r\n", md5End+1);
if (sizeStart == std::string::npos)
return false;
size_t sizeEnd = line.find_first_of(" \t\r\n", sizeStart+1);
if (sizeEnd == std::string::npos)
sizeEnd = line.length();
std::string strSize = line.substr(sizeStart, sizeEnd-sizeStart);
int64_t size = atoll(strSize.c_str());
FileAttr &attr = map[filePath];
attr.md5 = md5;
attr.size = size;
lineStart = filesMD5.find_first_not_of(" \t\r\n", lineEnd+1);
}
fileMD5Map.swap(map);
return true;
}
示例5: update
bool group_weights_cache_impl::update(MetabaseGroupWeightsResponse &resp) {
std::map<uint64_t, weighted_groups> local_map;
typedef std::vector<MetabaseGroupWeightsResponse::SizedGroups>::const_iterator resp_iterator;
resp_iterator e = resp.info.end();
for(resp_iterator it = resp.info.begin(); it != e; ++it) {
typedef std::vector<MetabaseGroupWeightsResponse::GroupWithWeight>::const_iterator info_iterator;
weighted_groups groups;
info_iterator wg_e = it->weighted_groups.end();
for(info_iterator wg_it = it->weighted_groups.begin(); wg_it != wg_e; ++wg_it) {
groups.add(wg_it->group_ids, wg_it->weight);
}
std::swap(local_map[it->size], groups);
}
boost::unique_lock<boost::shared_mutex> lock(shared_mutex_);
if(!local_map.empty()) {
map_.swap(local_map);
return true;
}
return false;
}
示例6: DataBlock
//.........这里部分代码省略.........
m_loadBlockInfo = m_monBlockInfo;
}
if (ndets == 0) {
separateMonitors = false; // only monitors in the main workspace. No
// detectors. Will be loaded in the main workspace
// Possible function exit point
return separateMonitors;
}
// detectors are present in the file
NXData nxData = entry.openNXData("detector_1");
NXInt data = nxData.openIntData();
m_detBlockInfo = DataBlock(data);
// We assume again that this spectrum list ID increase monotonically
m_detBlockInfo.spectraID_min = spectrum_index[0];
m_detBlockInfo.spectraID_max = spectrum_index[ndets - 1];
if (m_detBlockInfo.spectraID_max - m_detBlockInfo.spectraID_min + 1 !=
static_cast<int64_t>(m_detBlockInfo.numberOfSpectra)) {
g_log.warning() << "When trying to find the range of monitor spectra: "
"non-consequent spectra ID-s in the detectors block. "
"Unexpected situation for the loader\n";
}
m_loadBlockInfo = m_detBlockInfo;
// now we are analyzing what is actually going or can be loaded
bool removeMonitors = excludeMonitors || separateMonitors;
if (((m_detBlockInfo.numberOfPeriods != m_monBlockInfo.numberOfPeriods) ||
(m_detBlockInfo.numberOfChannels != m_monBlockInfo.numberOfChannels)) &&
nmons > 0) {
// detectors and monitors have different characteristics. Can be loaded only
// to separate workspaces.
if (!removeMonitors) {
g_log.warning() << " Performing separate loading as can not load spectra "
"and monitors in the single workspace:\n";
g_log.warning() << " Monitors data contain :"
<< m_monBlockInfo.numberOfChannels
<< " time channels and: "
<< m_monBlockInfo.numberOfPeriods << " period(s)\n";
g_log.warning() << " Spectra data contain :"
<< m_detBlockInfo.numberOfChannels
<< " time channels and: "
<< m_detBlockInfo.numberOfPeriods << " period(s)\n";
}
separateMonitors = true;
removeMonitors = true;
}
int64_t spectraID_min =
std::min(m_monBlockInfo.spectraID_min, m_detBlockInfo.spectraID_min);
int64_t spectraID_max =
std::max(m_monBlockInfo.spectraID_max, m_detBlockInfo.spectraID_max);
size_t totNumOfSpectra =
m_monBlockInfo.numberOfSpectra + m_detBlockInfo.numberOfSpectra;
if (!removeMonitors) {
m_loadBlockInfo.numberOfSpectra = totNumOfSpectra;
m_loadBlockInfo.spectraID_min = spectraID_min;
m_loadBlockInfo.spectraID_max = spectraID_max;
}
if (separateMonitors)
m_loadBlockInfo = m_detBlockInfo;
// verify integrity of the monitor and detector information
if ((totNumOfSpectra == static_cast<size_t>(n_vms_compat_spectra)) &&
(spectraID_max - spectraID_min + 1 ==
static_cast<int64_t>(n_vms_compat_spectra))) {
// all information written in the file is correct, there are no spurious
// spectra and detectors & monitors form continuous block on HDD
return separateMonitors;
}
// something is wrong and we need to analyze spectra map. Currently we can
// identify and manage the case when all monitor's spectra are written
// together with detectors
// make settings for this situation
m_detBlockInfo.numberOfSpectra -= m_monBlockInfo.numberOfSpectra;
m_loadBlockInfo.numberOfSpectra -= m_monBlockInfo.numberOfSpectra;
std::map<int64_t, std::string> remaining_monitors;
if (removeMonitors) {
for (auto it = monitors.begin(); it != monitors.end(); it++) {
if (it->first >= m_detBlockInfo.spectraID_min &&
it->first <= m_detBlockInfo.spectraID_max) { // monitors ID-s are
// included with spectra
// ID-s -- let's try not
// to load it twice.
OvelapMonitors.insert(*it);
} else {
remaining_monitors.insert(*it);
}
}
}
monitors.swap(remaining_monitors);
return separateMonitors;
}
示例7: swap
void swap(svector<F,V> &other) { m.swap(other.m); }
示例8: SwapMap
void ObjectMap::SwapMap(std::map<int, boost::shared_ptr<T> >& map, ObjectMap& rhs)
{ map.swap(rhs.Map<T>()); }
示例9: SwapMap
void ObjectMap::SwapMap(std::map<int, TemporaryPtr<T> >& map, ObjectMap& rhs)
{
map.swap(rhs.Map<T>());
}