本文整理汇总了C++中boost::unordered_set::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::insert方法的具体用法?C++ unordered_set::insert怎么用?C++ unordered_set::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_set
的用法示例。
在下文中一共展示了unordered_set::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateHelper
static void updateHelper (SLE::ref entry,
boost::unordered_set< uint256 >& seen,
boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> >& destMap,
boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> >& sourceMap,
boost::unordered_set< currencyIssuer_t >& XRPBooks,
int& books)
{
if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) &&
(entry->getFieldH256 (sfRootIndex) == entry->getIndex()))
{
const uint160& ci = entry->getFieldH160 (sfTakerPaysCurrency);
const uint160& co = entry->getFieldH160 (sfTakerGetsCurrency);
const uint160& ii = entry->getFieldH160 (sfTakerPaysIssuer);
const uint160& io = entry->getFieldH160 (sfTakerGetsIssuer);
uint256 index = Ledger::getBookBase (ci, ii, co, io);
if (seen.insert (index).second)
{
// VFALCO TODO Reduce the clunkiness of these parameter wrappers
OrderBook::pointer book = boost::make_shared<OrderBook> (boost::cref (index),
boost::cref (ci), boost::cref (co), boost::cref (ii), boost::cref (io));
sourceMap[currencyIssuer_ct (ci, ii)].push_back (book);
destMap[currencyIssuer_ct (co, io)].push_back (book);
if (co.isZero())
XRPBooks.insert(currencyIssuer_ct (ci, ii));
++books;
}
}
}
示例2: AddReferencedMaterials
void MixMaterial::AddReferencedMaterials(boost::unordered_set<const Material *> &referencedMats) const {
Material::AddReferencedMaterials(referencedMats);
referencedMats.insert(matA);
matA->AddReferencedMaterials(referencedMats);
referencedMats.insert(matB);
matB->AddReferencedMaterials(referencedMats);
}
示例3: Xeromyces_ReadScript
void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
{
// Check for a 'file' parameter
CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8());
// If there is a file specified, open and execute it
if (!file.empty())
{
Paths.insert(file);
try
{
m_ScriptInterface->LoadGlobalScriptFile(file);
}
catch (PSERROR_Scripting& e)
{
LOGERROR("GUI: Error executing script %s: %s", utf8_from_wstring(file), e.what());
}
}
// If it has a directory attribute, read all JS files in that directory
CStrW directory(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("directory")).FromUTF8());
if (!directory.empty())
{
VfsPaths pathnames;
vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames);
for (const VfsPath& path : pathnames)
{
// Only load new files (so when the insert succeeds)
if (Paths.insert(path).second)
try
{
m_ScriptInterface->LoadGlobalScriptFile(path);
}
catch (PSERROR_Scripting& e)
{
LOGERROR("GUI: Error executing script %s: %s", path.string8(), e.what());
}
}
}
// Execute inline scripts
try
{
CStr code(Element.GetText());
if (!code.empty())
m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());
}
catch (PSERROR_Scripting& e)
{
LOGERROR("GUI: Error executing inline script: %s", e.what());
}
}
示例4: registerDeferredObservers
inline void ObservableSettings::registerDeferredObservers(boost::unordered_set<Observer*>& observers) {
if (updatesDeferred())
{
QL_TRACE("adding " << observers.size() << " observers to the deferred list");
deferredObservers_.insert(observers.begin(), observers.end());
}
}
示例5: Xeromyces_ReadScript
void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
{
// Check for a 'file' parameter
CStrW file (Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ).FromUTF8());
// If there is a file specified, open and execute it
if (! file.empty())
{
Paths.insert(file);
try
{
m_ScriptInterface->LoadGlobalScriptFile(file);
}
catch (PSERROR_Scripting& e)
{
LOGERROR(L"GUI: Error executing script %ls: %hs", file.c_str(), e.what());
}
}
// Execute inline scripts
try
{
CStr code (Element.GetText());
if (! code.empty())
m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());
}
catch (PSERROR_Scripting& e)
{
LOGERROR(L"GUI: Error executing inline script: %hs", e.what());
}
}
示例6: collect_vnodes
void VNode::collect_vnodes(boost::unordered_set<Node*>& nodes,uint& total)
{
total++;
boost::unordered_set<Node*>::iterator it = nodes.find(this);
if(it==nodes.end())
nodes.insert(this);
}
示例7: getAllTiles
void CPrivilagedInfoCallback::getAllTiles (boost::unordered_set<int3, ShashInt3> &tiles, int Player/*=-1*/, int level, int surface ) const
{
if(Player >= GameConstants::PLAYER_LIMIT)
{
tlog1 << "Illegal call to getAllTiles !\n";
return;
}
bool water = surface == 0 || surface == 2,
land = surface == 0 || surface == 1;
std::vector<int> floors;
if(level == -1)
{
for(int b = 0; b < (gs->map->twoLevel ? 2 : 1); ++b)
{
floors.push_back(b);
}
}
else
floors.push_back(level);
for (std::vector<int>::const_iterator i = floors.begin(); i!= floors.end(); i++)
{
register int zd = *i;
for (int xd = 0; xd < gs->map->width; xd++)
{
for (int yd = 0; yd < gs->map->height; yd++)
{
if ((getTile (int3 (xd,yd,zd))->terType == 8 && water)
|| (getTile (int3 (xd,yd,zd))->terType != 8 && land))
tiles.insert(int3(xd,yd,zd));
}
}
}
}
示例8: getTilesInRange
void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, int player/*=-1*/, int mode/*=0*/ ) const
{
if(player >= GameConstants::PLAYER_LIMIT)
{
tlog1 << "Illegal call to getTilesInRange!\n";
return;
}
if (radious == -1) //reveal entire map
getAllTiles (tiles, player, -1, 0);
else
{
const TeamState * team = gs->getPlayerTeam(player);
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
{
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
{
double distance = pos.dist2d(int3(xd,yd,pos.z)) - 0.5;
if(distance <= radious)
{
if(player < 0
|| (mode == 1 && team->fogOfWarMap[xd][yd][pos.z]==0)
|| (mode == -1 && team->fogOfWarMap[xd][yd][pos.z]==1)
)
tiles.insert(int3(xd,yd,pos.z));
}
}
}
}
}
示例9: LoadXmlFile
/**
* @callgraph
*/
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths)
{
Paths.insert(Filename);
CXeromyces XeroFile;
if (XeroFile.Load(g_VFS, Filename, "gui") != PSRETURN_OK)
return;
XMBElement node = XeroFile.GetRoot();
CStr root_name(XeroFile.GetElementString(node.GetNodeName()));
try
{
if (root_name == "objects")
{
Xeromyces_ReadRootObjects(node, &XeroFile, Paths);
// Re-cache all values so these gets cached too.
//UpdateResolution();
}
else if (root_name == "sprites")
Xeromyces_ReadRootSprites(node, &XeroFile);
else if (root_name == "styles")
Xeromyces_ReadRootStyles(node, &XeroFile);
else if (root_name == "setup")
Xeromyces_ReadRootSetup(node, &XeroFile);
else
debug_warn(L"CGUI::LoadXmlFile error");
}
catch (PSERROR_GUI& e)
{
LOGERROR("Errors loading GUI file %s (%u)", Filename.string8(), e.getCode());
return;
}
}
示例10: make_pair
inline std::pair<boost::unordered_set<boost::shared_ptr<Observable> >::iterator, bool>
Observer::registerWith(const boost::shared_ptr<Observable>& h) {
if (h) {
h->registerObserver(this);
return observables_.insert(h);
}
return std::make_pair(observables_.end(), false);
}
示例11: dfs
void cluster_machine::dfs(const size_t curr, boost::unordered_set<size_t> &vis)
{
vis.insert(curr);
for (size_t e = first_[curr]; e != -1; e = next_[e]) {
if ( vis.find(v_[e]) == vis.end() )
dfs(v_[e], vis);
}
}
示例12:
PNS_NODE::PNS_NODE()
{
// printf("MakeNode [%p, total = %d]\n", this, allocNodes.size());
m_root = this;
m_parent = NULL;
m_maxClearance = 800000; // fixme: depends on how thick traces are.
m_index = new PNS_INDEX;
allocNodes.insert( this );
}
示例13: sanity_checks
void sanity_checks() {
ASSERT_TRUE(cm.begin() == cm.end());
for (size_t i = 0;i < NINS; ++i) {
um.insert(17 * i);
}
graphlab::thread_group thrgroup;
for (size_t i = 0; i < 10; ++i) {
thrgroup.launch(boost::bind(parallel_inserter,
i * NINS/10,
(i + 1) * NINS / 10));
}
thrgroup.join();
std::cout << "Size: " << cm.size() << std::endl;
std::cout << "Capacity: " << cm.capacity() << std::endl;
std::cout << "Load Factor: " << cm.load_factor() << std::endl;
for (size_t i = 0;i < NINS; ++i) {
if (cm.get_sync(17 * i).first == false) {
std::cout << cm.count(17 * i) << "\n";
std::cout << "Failure on: " << 17 * i << std::endl;
assert(cm.get_sync(17 * i).first == true);
}
assert(um.count(17 * i) == 1);
}
assert(cm.size() == NINS);
assert(um.size() == NINS);
for (size_t i = 0;i < NINS; i+=2) {
um.erase(17*i);
}
for (size_t i = 0; i < 10; ++i) {
thrgroup.launch(boost::bind(parallel_erase,
i * NINS/10,
(i + 1) * NINS / 10));
}
thrgroup.join();
for (size_t i = 0;i < NINS; i+=2) {
assert(cm.get_sync(17*i).first == (bool)(i % 2));
assert(um.count(17*i) == i % 2);
}
assert(cm.size() == NINS / 2);
assert(um.size() == NINS / 2);
}
示例14: LoadXmlFile
/**
* @callgraph
*/
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths)
{
Paths.insert(Filename);
CXeromyces XeroFile;
if (XeroFile.Load(g_VFS, Filename) != PSRETURN_OK)
// Fail silently
return;
XMBElement node = XeroFile.GetRoot();
// Check root element's (node) name so we know what kind of
// data we'll be expecting
CStr root_name (XeroFile.GetElementString(node.GetNodeName()));
try
{
if (root_name == "objects")
{
Xeromyces_ReadRootObjects(node, &XeroFile, Paths);
// Re-cache all values so these gets cached too.
//UpdateResolution();
}
else
if (root_name == "sprites")
{
Xeromyces_ReadRootSprites(node, &XeroFile);
}
else
if (root_name == "styles")
{
Xeromyces_ReadRootStyles(node, &XeroFile);
}
else
if (root_name == "setup")
{
Xeromyces_ReadRootSetup(node, &XeroFile);
}
else
{
debug_warn(L"CGUI::LoadXmlFile error");
// TODO Gee: Output in log
}
}
catch (PSERROR_GUI& e)
{
LOGERROR(L"Errors loading GUI file %ls (%u)", Filename.string().c_str(), e.getCode());
return;
}
}
示例15: deserialize
static void deserialize(storage_type& s, boost::unordered_set<T>& o)
{
o = boost::unordered_set<T>();
uint32_t sz;
s.deserialize(sz);
for (int32_t k = 0; k < sz; k++)
{
T key;
s.deserialize(key);
o.insert(key);
}
}