本文整理汇总了C++中ItemList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::empty方法的具体用法?C++ ItemList::empty怎么用?C++ ItemList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::empty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forEachSimulator
void SimulationBar::forEachSimulator(boost::function<void(SimulatorItem* simulator)> callback, bool doSelect)
{
MessageView* mv = MessageView::instance();
/*
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
*/
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
if(simulators.empty()){
simulators.extractChildItems(RootItem::instance());
if(simulators.empty()){
mv->notify(_("There is no simulator item."));
} else if(simulators.size() > 1){
simulators.clear();
mv->notify(_("Please select a simulator item to simulate."));
} else {
if(doSelect){
ItemTreeView::instance()->selectItem(simulators.front());
}
}
}
typedef map<WorldItem*, SimulatorItem*> WorldToSimulatorMap;
WorldToSimulatorMap worldToSimulator;
for(int i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(world){
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p == worldToSimulator.end()){
worldToSimulator[world] = simulator;
} else {
p->second = 0; // skip if multiple simulators are selected
}
}
}
for(int i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(!world){
mv->notify(format(_("%1% cannot be processed because it is not related with a world."))
% simulator->name());
} else {
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p != worldToSimulator.end()){
if(!p->second){
mv->notify(format(_("%1% cannot be processed because another simulator"
"in the same world is also selected."))
% simulator->name());
} else {
callback(simulator);
}
}
}
}
}
示例2: createChildLoot
bool MonsterType::createChildLoot(Container* parent, const LootBlock& lootBlock)
{
LootItems::const_iterator it = lootBlock.childLoot.begin();
if(it == lootBlock.childLoot.end())
return true;
ItemList items;
for(; it != lootBlock.childLoot.end() && !parent->full(); ++it)
{
items = createLoot(*it);
if(items.empty())
continue;
for(ItemList::iterator iit = items.begin(); iit != items.end(); ++iit)
{
Item* tmpItem = *iit;
if(Container* container = tmpItem->getContainer())
{
if(createChildLoot(container, *it))
parent->__internalAddThing(tmpItem);
else
delete container;
}
else
parent->__internalAddThing(tmpItem);
}
}
return !parent->empty();
}
示例3: create
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
ItemList result;
if (type == G_COLLECTION) {
for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
if(rng(0, 99) >= (*a)->probability) {
continue;
}
ItemList tmp = (*a)->create(birthday, rec);
result.insert(result.end(), tmp.begin(), tmp.end());
}
} else if (type == G_DISTRIBUTION) {
int p = rng(0, sum_prob - 1);
for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
p -= (*a)->probability;
if (p >= 0) {
continue;
}
ItemList tmp = (*a)->create(birthday, rec);
result.insert(result.end(), tmp.begin(), tmp.end());
break;
}
}
if (with_ammo && !result.empty()) {
it_gun *maybe_gun = dynamic_cast<it_gun *>(result.front().type);
if (maybe_gun != NULL) {
item ammo(default_ammo(maybe_gun->ammo), birthday);
// TODO: change the spawn lists to contain proper references to containers
ammo = ammo.in_its_container();
result.push_back(ammo);
}
}
return result;
}
示例4: apply
void KinematicFaultCheckerImpl::apply()
{
bool processed = false;
ItemList<BodyMotionItem> items = ItemTreeView::mainInstance()->selectedItems<BodyMotionItem>();
if(items.empty()){
mes.notify(_("No BodyMotionItems are selected."));
} else {
for(size_t i=0; i < items.size(); ++i){
BodyMotionItem* motionItem = items.get(i);
BodyItem* bodyItem = motionItem->findOwnerItem<BodyItem>();
if(!bodyItem){
mes.notify(str(fmt(_("%1% is not owned by any BodyItem. Check skiped.")) % motionItem->name()));
} else {
mes.putln();
mes.notify(str(fmt(_("Applying the Kinematic Fault Checker to %1% ..."))
% motionItem->headItem()->name()));
dynamic_bitset<> linkSelection;
if(selectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
} else if(nonSelectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
linkSelection.flip();
} else {
linkSelection.resize(bodyItem->body()->numLinks(), true);
}
double beginningTime = 0.0;
double endingTime = motionItem->motion()->getTimeLength();
std::numeric_limits<double>::max();
if(onlyTimeBarRangeCheck.isChecked()){
TimeBar* timeBar = TimeBar::instance();
beginningTime = timeBar->minTime();
endingTime = timeBar->maxTime();
}
int n = checkFaults(bodyItem, motionItem, mes.cout(),
positionCheck.isChecked(),
velocityCheck.isChecked(),
collisionCheck.isChecked(),
linkSelection,
beginningTime, endingTime);
if(n > 0){
if(n == 1){
mes.notify(_("A fault has been detected."));
} else {
mes.notify(str(fmt(_("%1% faults have been detected.")) % n));
}
} else {
mes.notify(_("No faults have been detected."));
}
processed = true;
}
}
}
}
示例5: dropLoot
void MonsterType::dropLoot(Container* corpse)
{
ItemList items;
for(LootItems::const_iterator it = lootItems.begin(); it != lootItems.end() && !corpse->full(); ++it)
{
items = createLoot(*it);
if(items.empty())
continue;
for(ItemList::iterator iit = items.begin(); iit != items.end(); ++iit)
{
Item* tmpItem = *iit;
if(Container* container = tmpItem->getContainer())
{
if(createChildLoot(container, *it))
corpse->__internalAddThing(tmpItem);
else
delete container;
}
else
corpse->__internalAddThing(tmpItem);
}
}
corpse->__startDecaying();
uint32_t ownerId = corpse->getCorpseOwner();
if(!ownerId)
return;
Player* owner = g_game.getPlayerByGuid(ownerId);
if(!owner)
return;
LootMessage_t message = lootMessage;
if(message == LOOTMSG_IGNORE)
message = (LootMessage_t)g_config.getNumber(ConfigManager::LOOT_MESSAGE);
if(message < LOOTMSG_PLAYER)
return;
std::stringstream ss;
ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription() << ".";
if(owner->getParty() && message > LOOTMSG_PLAYER)
owner->getParty()->broadcastMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
else if(message == LOOTMSG_PLAYER || message == LOOTMSG_BOTH)
owner->sendTextMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
}
示例6: bind
void MultiAffine3SeqGraphView::onItemSelectionChanged(const ItemList<MultiAffine3SeqItem>& items)
{
if(items.empty()){
return;
}
if(itemInfos.size() == items.size()){
bool unchanged = true;
int i=0;
for(list<ItemInfo>::iterator it = itemInfos.begin(); it != itemInfos.end(); ++it){
if(it->item != items[i++]){
unchanged = false;
break;
}
}
if(unchanged){
return;
}
}
itemInfos.clear();
for(size_t i=0; i < items.size(); ++i){
BodyItemPtr bodyItem = items[i]->findOwnerItem<BodyItem>();
if(bodyItem){
itemInfos.push_back(ItemInfo());
list<ItemInfo>::iterator it = --itemInfos.end();
it->item = items[i];
it->seq = it->item->seq();
it->bodyItem = bodyItem;
it->connections.add(it->item->sigUpdated().connect(
bind(&MultiAffine3SeqGraphView::onDataItemUpdated, this, it)));
it->connections.add(it->item->sigDetachedFromRoot().connect(
bind(&MultiAffine3SeqGraphView::onDataItemDetachedFromRoot, this, it)));
}
}
updateBodyItems();
setupGraphWidget();
}
示例7: onItemSelectionChanged
void GraphViewBaseImpl::onItemSelectionChanged(const ItemList<>& allItems)
{
ItemList<> items = self->extractTargetItems(allItems);
if(items.empty()){
return;
}
if(itemInfos.size() == items.size()){
bool unchanged = true;
int i=0;
for(list<ItemInfo>::iterator it = itemInfos.begin(); it != itemInfos.end(); ++it){
if(it->item != items[i++]){
unchanged = false;
break;
}
}
if(unchanged){
return;
}
}
itemInfos.clear();
for(size_t i=0; i < items.size(); ++i){
itemInfos.push_back(ItemInfo(this));
list<ItemInfo>::iterator it = --itemInfos.end();
it->item = items[i];
ConnectionSet& connections = itemToConnectionSetMap[it->item.get()];
connections.add(it->item->sigUpdated().connect(
boost::bind(&GraphViewBaseImpl::onItemUpdated, this, it)));
connections.add(it->item->sigDetachedFromRoot().connect(
boost::bind(&GraphViewBaseImpl::onItemDetachedFromRoot, this, it)));
}
updatePartList();
}
示例8: create
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
ItemList result;
if (type == G_COLLECTION) {
for( const auto &elem : items ) {
if( rng( 0, 99 ) >= ( elem )->probability ) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
}
} else if (type == G_DISTRIBUTION) {
int p = rng(0, sum_prob - 1);
for( const auto &elem : items ) {
p -= ( elem )->probability;
if (p >= 0) {
continue;
}
ItemList tmp = ( elem )->create( birthday, rec );
result.insert(result.end(), tmp.begin(), tmp.end());
break;
}
}
if (with_ammo && !result.empty()) {
const auto t = result.front().type;
if( t->gun ) {
const std::string ammoid = default_ammo( t->gun->ammo );
if ( !ammoid.empty() ) {
item ammo( ammoid, birthday );
// TODO: change the spawn lists to contain proper references to containers
ammo = ammo.in_its_container();
result.push_back( ammo );
}
}
}
return result;
}
示例9: onItemCheckToggled
void GSMediaViewImpl::onItemCheckToggled(Item* item, bool isChecked)
{
if(TRACE_FUNCTIONS){
cout << "GSMediaViewImpl::onItemCheckToggled()" << endl;
}
MediaItem* mediaItem = dynamic_cast<MediaItem*>(item);
if(mediaItem){
ItemList<MediaItem> checkedItems = ItemTreeView::mainInstance()->checkedItems<MediaItem>();
MediaItemPtr targetItem;
if(!checkedItems.empty()){
targetItem = checkedItems.front();
}
if(targetItem != currentMediaItem){
if(currentMediaItem){
stopPlayback();
}
currentMediaItem = targetItem;
if(!currentMediaItem || currentMediaItem->mediaURI().empty()){
g_object_set(G_OBJECT(playbin), "uri", "", NULL);
timeBarConnections.disconnect();
} else {
GstPad* pad = gst_element_get_static_pad(GST_ELEMENT(videoSink), "sink");
gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER,
(GstPadProbeCallback)videoPadBufferProbeCallback, this, NULL);
gst_object_unref(pad);
if(self->winId()){
activateCurrentMediaItem();
}
}
}
}
}
示例10: loadPlugins
void WidgetDataBase::loadPlugins()
{
typedef QMap<QString, int> NameIndexMap;
typedef QList<QDesignerWidgetDataBaseItemInterface*> ItemList;
typedef QMap<QString, QDesignerWidgetDataBaseItemInterface*> NameItemMap;
typedef QSet<QString> NameSet;
// 1) create a map of existing custom classes
NameIndexMap existingCustomClasses;
NameSet nonCustomClasses;
const int count = m_items.size();
for (int i = 0; i < count; i++) {
const QDesignerWidgetDataBaseItemInterface* item = m_items[i];
if (item->isCustom() && !item->isPromoted())
existingCustomClasses.insert(item->name(), i);
else
nonCustomClasses.insert(item->name());
}
// 2) create a list plugins
ItemList pluginList;
const QDesignerPluginManager *pm = m_core->pluginManager();
foreach(QDesignerCustomWidgetInterface* c, pm->registeredCustomWidgets())
pluginList += createCustomWidgetItem(c, pm->customWidgetData(c));
// 3) replace custom classes or add new ones, remove them from existingCustomClasses,
// leaving behind deleted items
unsigned replacedPlugins = 0;
unsigned addedPlugins = 0;
unsigned removedPlugins = 0;
if (!pluginList.empty()) {
ItemList::const_iterator cend = pluginList.constEnd();
for (ItemList::const_iterator it = pluginList.constBegin();it != cend; ++it ) {
QDesignerWidgetDataBaseItemInterface* pluginItem = *it;
const QString pluginName = pluginItem->name();
NameIndexMap::iterator existingIt = existingCustomClasses.find(pluginName);
if (existingIt == existingCustomClasses.end()) {
// Add new class.
if (nonCustomClasses.contains(pluginName)) {
designerWarning(tr("A custom widget plugin whose class name (%1) matches that of an existing class has been found.").arg(pluginName));
} else {
append(pluginItem);
addedPlugins++;
}
} else {
// replace existing info
const int existingIndex = existingIt.value();
delete m_items[existingIndex];
m_items[existingIndex] = pluginItem;
existingCustomClasses.erase(existingIt);
replacedPlugins++;
}
}
}
// 4) remove classes that have not been matched. The stored indexes become invalid while deleting.
if (!existingCustomClasses.empty()) {
NameIndexMap::const_iterator cend = existingCustomClasses.constEnd();
for (NameIndexMap::const_iterator it = existingCustomClasses.constBegin();it != cend; ++it ) {
const int index = indexOfClassName(it.key());
if (index != -1) {
remove(index);
removedPlugins++;
}
}
}
if (debugWidgetDataBase)
qDebug() << "WidgetDataBase::loadPlugins(): " << addedPlugins << " added, " << replacedPlugins << " replaced, " << removedPlugins << "deleted.";
}
示例11: GetCursorId
gcc_pure
FlarmId GetCursorId() const {
return items.empty()
? FlarmId::Undefined()
: items[GetList().GetCursorIndex()].id;
}
示例12: initialize
bool BodyUnit::initialize(BodyItemPtr bodyItem)
{
if(TRACE_FUNCTIONS){
cout << "BodyUnit::initialize()" << endl;
}
if(bodyItem->body()->isStaticModel()){
return false;
}
frame = 0;
body = bodyItem->body()->duplicate();
baseLink = 0;
ItemList<BodyMotionItem> motionItems = bodyItem->getSubItems<BodyMotionItem>();
if(!motionItems.empty()){
BodyMotionItemPtr motionItem;
// prefer the first checked item
for(size_t i=0; i < motionItems.size(); ++i){
if(ItemTreeView::mainInstance()->isItemChecked(motionItems[i])){
motionItem = motionItems[i];
break;
}
}
if(!motionItem){
motionItem = motionItems[0];
}
frameRate = motionItem->motion()->frameRate();
qseqRef = motionItem->jointPosSeq();
if(qseqResult){
qseqResultBuf.reset(new MultiValueSeq(qseqResult->numParts(), 0, frameRate));
}
if(motionItem->hasRelativeZmpSeqItem()){
zmpSeq = motionItem->relativeZmpSeq();
}
rootResultItem = motionItem->linkPosSeqItem();
rootResultBuf.reset(new MultiAffine3Seq(1, 0, frameRate));
rootResult = motionItem->linkPosSeq();
rootResult->setFrameRate(frameRate);
rootResult->setDimension(1, 1);
}
const YamlMapping& info = *bodyItem->body()->info();
const YamlSequence& footLinkInfos = *info.findSequence("footLinks");
if(footLinkInfos.isValid()){
for(int i=0; i < footLinkInfos.size(); ++i){
const YamlMapping& footLinkInfo = *footLinkInfos[i].toMapping();
Link* link = body->link(footLinkInfo["link"].toString());
Vector3 soleCenter;
if(link && read(footLinkInfo, "soleCenter", soleCenter)){
footLinks.push_back(link);
footLinkOriginHeights.push_back(-soleCenter[2]);
}
}
}
if(!footLinks.empty()){
if(zmpSeq){
setBaseLinkByZmp(0);
} else {
if(bodyItem->currentBaseLink()){
int currentBaseLinkIndex = bodyItem->currentBaseLink()->index;
for(size_t i=0; i < footLinks.size(); ++i){
Link* footLink = footLinks[i];
if(footLink->index == currentBaseLinkIndex){
setBaseLink(footLink, footLinkOriginHeights[i]);
}
}
} else{
setBaseLink(footLinks[0], footLinkOriginHeights[0]);
}
}
}
if(!baseLink){
if(bodyItem->currentBaseLink()){
baseLink = body->link(bodyItem->currentBaseLink()->index);
} else {
baseLink = body->rootLink();
}
fkTraverse.find(baseLink, true, true);
}
if(rootResult){
Link* rootLink = body->rootLink();
Affine3& initialPos = rootResult->at(0, 0);
initialPos.translation() = rootLink->p;
initialPos.linear() = rootLink->R;
}
return (qseqRef != 0);
}