本文整理汇总了C++中Objects::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Objects::find方法的具体用法?C++ Objects::find怎么用?C++ Objects::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
/** \brief
Force the pointer for the object in store to be a specific pointer.
This can be useful for singleton values.
These usually must be removed from the store explicitly.
\pre No object with this value is already in the store.
*/
void set (std::shared_ptr <Value const> pointer) {
// The value must not be in the store yet.
assert (objects_.find (*pointer,
boost::hash <Value>(), EqualToWeakPtr()) == objects_.end());
objects_.insert (std::move (pointer));
}
示例2: newElement
// Rvalue reference.
std::shared_ptr <Value const> get (Value && value) {
auto existing = objects_.find (value,
boost::hash <Value>(), EqualToWeakPtr());
if (existing != objects_.end())
return existing->get();
// The value is not in the store yet; insert it.
auto sole = SoleType::construct (*this, std::move (value));
Pointer newElement (sole);
objects_.insert (std::move (newElement));
return sole;
}
示例3: remap
bool remap(ID source,ID target) // change ID from source to target
{
// source->target
// target->new id
if(!contains(source))
return false; // remap failed
// find object
Objects::iterator it=objects.find(source);
// get pointer
Object *object=it->second;//objects[source];
// remove
objects.erase(it);
if(contains(target)) // if <target> is valid object -> remap it to new ID
remap(target,generator->generate(getTarget(objects[target])));
objects[target]=object;
// set new ID
object->localID=target;
object->back=objects.find(target);
return true;
}
示例4: add
// called in Stored constructor
// assignes new unique ID and back iterator
virtual ID add(Target * object)
{
assert(generator);
if(!valid(object->id()))
object->localID=generator->generate(object);
else if(contains(object->id()))
{
assert(false);
}
objects.insert(std::make_pair(object->id(),object));
Objects::iterator it=objects.find(object->id());
object->back=it;
onAdd(object); // raise onAdd event.
return object->id();
}
示例5: contains
bool contains(ID id)
{
return objects.find(id)!=objects.end();
}
示例6: destroy
void destroy(ID id)
{
Objects::iterator it=objects.find(id);
if(it!=objects.end())
delete it->second;
}