当前位置: 首页>>代码示例>>C++>>正文


C++ QVector::erase方法代码示例

本文整理汇总了C++中QVector::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::erase方法的具体用法?C++ QVector::erase怎么用?C++ QVector::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVector的用法示例。


在下文中一共展示了QVector::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pred

/*! First all intersections are calculated. Then duplicates are removed.
    If only points on the line are required, all points that are outside
    the lnX[A,B] are removed. If bParallel is true, parallel segmets are
    checked for overlap and overlap points are included in the solution.
    
    \retval VecVertex container of intersection points. 
 */
QVector<Point2D> Polygon2D::GetIntersection(
   const Line2D& lnX, //!< line that intersects the polygon
   bool bOnLineOnly,  //!< if true, only points between A and B inclusive are counted.
   bool bParallel     //!< check parallel lines for overlap
) const
{
   // results are stored here
   QVector<Point2D> vecInt;

   // for each segment
   for(unsigned int i=0; i<GetCount(); i++) {
      Line2D ln = GetLine(i);
      Q_ASSERT(ln.IsValid());
      Point2D ptInt;
      // Check overlaps, if they are wanted
      if(bParallel && ln.IsParallel(lnX)) {
         Line2D lnO = ln.GetOverlap(lnX);
         if(lnO.IsValid()) {
            vecInt.push_back(lnO.GetA());
            vecInt.push_back(lnO.GetB());
         }
      }

      // check intersections
      if(ln.GetIntersection(lnX, ptInt) & Line2D::intFirst){
         vecInt.push_back(ptInt);
      }
   }

   // Sort the points in the vector. Same point may appear several
   // times.
   Point2DSortLineLess pred(lnX);
   std::sort(vecInt.begin(),vecInt.end(),pred);
   // remove duplicates, if any
   QVector<Point2D>::iterator f = std::unique(vecInt.begin(),vecInt.end());
   vecInt.erase(f,vecInt.end());

   // remove all points that are not inside the line
   if(bOnLineOnly) {
      QVector<Point2D>::iterator i=vecInt.begin();
      while(i!=vecInt.end()) {
         if(!(lnX.GetPosition(*i) & Line2D::posInsideEnd))
            i = vecInt.erase(i);
         else
            i++;
      }
   }

   return vecInt;
}
开发者ID:jpoirier,项目名称:x-gauges,代码行数:57,代码来源:Polygon2D.cpp

示例2: findNextWords

static inline void findNextWords ( QVector<uint64_t> & src, const QVector<uint64_t> & needle )
{
	for ( int s1 = 0; s1 < src.size(); s1++ )
	{
		bool found = false;
		uint64_t target_offset = src[s1] + 1;
		
		DEBUG_SEARCH (("Offset loop: offset at %u is %u, target %u", (unsigned int) s1,
					   (unsigned int) src[s1], (unsigned int) target_offset));
		
		// Search in the offsets list in attempt to find next word
		for ( int s2 = 0; s2 < needle.size(); s2++ )
		{
			if ( needle[s2] == target_offset )
			{
				found = true;
				break;
			}
		}

		if ( !found )
		{
			// Remove this offset, we don't need it anymore
			DEBUG_SEARCH (("Offset loop failed: offset %u not found", (unsigned int) target_offset));
			src.erase ( src.begin() + s1 );
			s1--;
		}
		else
		{
			DEBUG_SEARCH (("Offset loop succeed: offset %u found", (unsigned int) target_offset));
			src[s1]++;
		}
	}
}
开发者ID:Axure,项目名称:okular,代码行数:34,代码来源:libchmfile_search.cpp

示例3:

QVector< Dwarf_Half > DwarfDie::attributes() const
{
    Dwarf_Attribute* attrList;
    Dwarf_Signed attrCount;
    auto res = dwarf_attrlist(m_die, &attrList, &attrCount, nullptr);
    if (res != DW_DLV_OK)
        return {};

    QVector<Dwarf_Half> attrs;
    attrs.reserve(attrCount);
    for (int i = 0; i < attrCount; ++i) {
        Dwarf_Half attrType;
        res = dwarf_whatattr(attrList[i], &attrType, nullptr);
        if (res != DW_DLV_OK)
            continue;
        attrs.push_back(attrType);
    }

    dwarf_dealloc(dwarfHandle(), attrList, DW_DLA_LIST);

    if (const auto die = inheritedFrom()) {
        auto inheritedAttrs = die->attributes();
        // remove attributes that must not be inherited
        inheritedAttrs.erase(
            std::remove_if(inheritedAttrs.begin(), inheritedAttrs.end(), [](Dwarf_Half at) {
                return at == DW_AT_declaration || at == DW_AT_sibling;
            }), inheritedAttrs.end());

        attrs += inheritedAttrs;
        std::sort(attrs.begin(), attrs.end());
        attrs.erase(std::unique(attrs.begin(), attrs.end()), attrs.end());
    }

    return attrs;
}
开发者ID:KDE,项目名称:elf-dissector,代码行数:35,代码来源:dwarfdie.cpp

示例4: in

QVector<QString> *lc::ReceiptsHandler::GetParticipantsDataFromPaymentFile() {
    // Create the vector to store the single lines of the file
    QVector<QString> *participantsData = new QVector<QString>;

    // Open the payment file for reading and create a QTextStream
    paymentFile.open( QIODevice::ReadOnly | QIODevice::Text );
    QTextStream in( &paymentFile );
    in.setCodec( "ISO 8859-1" );

    // Read the file line by line and store them in the vector
    while ( true ) {
        QString line = in.readLine();
        if ( line.isNull() ) {
            break;
        }
        participantsData->append( line );
    }

    // Remove the first line, since it is not needed
    participantsData->erase( participantsData->begin() );

    // Close the file afterwards
    paymentFile.close();

    return participantsData;
}
开发者ID:markuspg,项目名称:Labcontrol,代码行数:26,代码来源:receipts_handler.cpp

示例5: selekcja

void SelekcjaTurniejowa::selekcja(Populacja *populacja)
{
    std::cout<<"============SELEKCJA TURNIEJOWA=============="<<std::endl;


    QVector<Osobnik*> tmp;

    for(int i=0; i<populacja->proporcja;++i)
    {
        for(int j=0; j<5; ++j)
        {
            int x=qrand()%populacja->populacja.size();
            tmp.push_back(populacja->populacja[x]);
        }

        qSort(tmp.begin(),tmp.end(),osobnikSelect);
        tmp.erase(tmp.begin(),tmp.end());

        populacja->wynikSelekcji[i]->kopiujOsobnika(tmp[0]);
    }



    std::cout<<"============STOP SELEKCJA TURNIEJOWA=============="<<std::endl;
}
开发者ID:pierok,项目名称:StarWarsTD,代码行数:25,代码来源:selekcja.cpp

示例6: nodePruneAction_impl

// Returns true if this node is to be deleted.
static bool nodePruneAction_impl(
        Process::MessageNode& node,
        const Id<Process::ProcessModel>& proc,
        QVector<Process::ProcessStateData>& vec,
        const QVector<Process::ProcessStateData>& other_vec)
{
    int vec_size = vec.size();
    if(vec_size > 1)
    {
        // We just remove the element
        // corresponding to this process.
        auto it = find_if(vec,
                      [&] (const auto& data) {
            return data.process == proc;
        });

        if(it != vec.end())
        {
            vec.erase(it);
        }
    }
    else if(vec_size == 1)
    {
        // We may be able to remove the whole node
        if(vec.front().process == proc)
            vec.clear();

        // If false, nothing is removed.
        return vec.isEmpty()
            && other_vec.isEmpty()
            && !node.values.userValue;
    }

    return false;
}
开发者ID:himito,项目名称:i-score,代码行数:36,代码来源:MessageItemModelAlgorithms.cpp

示例7:

void AbstractResourcesBackend::Filters::filterJustInCase(QVector<AbstractResource *>& input) const
{
    for(auto it = input.begin(); it != input.end();) {
        if (shouldFilter(*it))
            ++it;
        else
            it = input.erase(it);
    }
}
开发者ID:KDE,项目名称:discover,代码行数:9,代码来源:AbstractResourcesBackend.cpp

示例8: Handle

Handle(Standard_Type) Subassembly::lookupType ( QVector<uint>& id_path ) const
{
  if ( subassembly_->id() == id_path[0] ) {
    id_path.erase( id_path.begin() );
    return subassembly_->lookupType( id_path );
  }

  return Handle(Standard_Type)();
}
开发者ID:mcirsta,项目名称:lignumCAD,代码行数:9,代码来源:subassembly.cpp

示例9: removeFromFileContainer

static bool removeFromFileContainer(QVector<FileContainer> &fileContainers, const Document &document)
{
    auto position = std::remove(fileContainers.begin(), fileContainers.end(), document);

    bool entryIsRemoved = position != fileContainers.end();

    fileContainers.erase(position, fileContainers.end());

    return entryIsRemoved;
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:10,代码来源:clangdocuments.cpp

示例10: lookupShape

TopoDS_Shape Subassembly::lookupShape ( QVector<uint>& id_path ) const
{
  TopoDS_Shape shape;

  if ( subassembly_->id() == id_path[0] ) {
    id_path.erase( id_path.begin() );
    shape = subassembly_->lookupShape( id_path );
    shape.Location( location_ * shape.Location() );
  }

  return shape;
}
开发者ID:mcirsta,项目名称:lignumCAD,代码行数:12,代码来源:subassembly.cpp

示例11: lookupShape

TopoDS_Shape Assembly::lookupShape ( QVector<uint>& id_path ) const
{
  QMap<uint,Figure*>::const_iterator figure = figures_.find( id_path[0] );

  if ( figure != figures_.end() ) {
    id_path.erase( id_path.begin() );
    if ( !id_path.empty() )
      return figure.value()->lookupShape( id_path );
  }

  return TopoDS_Shape();	// Really an error...
}
开发者ID:mcirsta,项目名称:lignumCAD,代码行数:12,代码来源:assembly.cpp

示例12: idPath

QString Subassembly::idPath ( QVector<uint> id_path ) const
{
  if ( subassembly_->id() != id_path[0] )
    return QString::null;	// Really an error...

  id_path.erase( id_path.begin() );

  if ( id_path.empty() )
    return subassembly_->name() + '.' + subassembly_->type();

  return subassembly_->name() + '.' + subassembly_->type() + '/' +
    subassembly_->idPath( id_path );
}
开发者ID:mcirsta,项目名称:lignumCAD,代码行数:13,代码来源:subassembly.cpp

示例13: selectableObjects

QVector<selectableObject *> RubberBand::selectedObjects() const
{
	QVector<selectableObject *> so = selectableObjects();
	for( QVector<selectableObject *>::iterator it = so.begin();
							it != so.end(); )
	{
		if( ( *it )->isSelected() == false )
		{
			it = so.erase( it );
		}
		else
		{
			++it;
		}
	}
	return( so );
}
开发者ID:DanielAeolusLaude,项目名称:lmms,代码行数:17,代码来源:Rubberband.cpp

示例14: idPath

QString Assembly::idPath ( QVector<uint> id_path ) const
{
  // The argument path must not have zero length, i.e., it must
  // refer to a figure (the Model has already taken care of
  // including *this* page in the path string).
  QMap<uint,Figure*>::const_iterator f = figures_.find( id_path[0] );

  if ( f == figures_.end() )
    return QString::null;	// Really an error...

  id_path.erase( id_path.begin() );

  if ( id_path.empty() )
    return f.value()->name() + '.' +  f.value()->type();

  return f.value()->name() + '.' +  f.value()->type() + '/' +
    f.value()->idPath( id_path );
}
开发者ID:mcirsta,项目名称:lignumCAD,代码行数:18,代码来源:assembly.cpp

示例15: TypeIs

QVector<UpdateInfo> UpdatesInfo::updatesInfo( int type,  int compatLevel ) const
{
    QVector<UpdateInfo> list;
    if ( compatLevel == -1 ) {
        if ( type == AllUpdate ) {
            return d->updateInfoList;
        }
        std::remove_copy_if( d->updateInfoList.begin(), d->updateInfoList.end(), std::back_inserter( list ), std::not1( TypeIs( type ) ) );
                }
                else {
        // first remove all wrong types
        std::remove_copy_if( d->updateInfoList.begin(), d->updateInfoList.end(), std::back_inserter( list ), std::not1( TypeIs( type ) ) );

        // the remove all wrong compat levels
        list.erase( 
            std::remove_if( list.begin(), list.end(), CompatLevelIsNot( compatLevel ) ), 
            list.end() );
    }
    return list;
}
开发者ID:KDAB,项目名称:KDTools,代码行数:20,代码来源:kdupdaterupdatesinfo.cpp


注:本文中的QVector::erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。