本文整理汇总了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;
}
示例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]++;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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)();
}
示例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;
}
示例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;
}
示例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...
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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;
}