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


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

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


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

示例1: mergeSort

QVector<quint8> EncryptorPrivate::mergeSort(const QVector<quint8> &array, quint32 salt, quint64 k)
{
    int length = array.size();

    if (length <= 1) {
        return array;
    }

    int middle = length / 2;
    QVector<quint8> left = array.mid(0, middle);
    QVector<quint8> right = array.mid(middle);

    left = mergeSort(left, salt, k);
    right = mergeSort(right, salt, k);

    int leftptr = 0;
    int rightptr = 0;

    QVector<quint8> sorted;
    sorted.fill(0, length);
    for (int i = 0; i < length; ++i) {
        if (rightptr == right.size() || (leftptr < left.size() && randomCompare(left[leftptr], right[rightptr], salt, k) <= 0)) {
            sorted[i] = left[leftptr++];
        } else if (leftptr == left.size() || (rightptr < right.size() && randomCompare(right[rightptr], left[leftptr], salt, k) <= 0)) {
            sorted[i] = right[rightptr++];
        }
    }
    return sorted;
}
开发者ID:puncher-pan,项目名称:libQtShadowsocks,代码行数:29,代码来源:encryptorprivate.cpp

示例2: mergesort

QVector<double> mergesort(QVector<double> &v){
    int size = v.size();
    if (size > 1) {
        QVector<double> v1 = v.mid(0, size/2);
        QVector<double> v2 = v.mid(size/2, size-(size/2));
        QVector<double> r1 = mergesort(v1);
        QVector<double> r2 = mergesort(v2);
        QVector<double> r = merge(r1, r2);
        return r;
    }
    else return v;

}
开发者ID:simonebarbieri,项目名称:Clark-Wright,代码行数:13,代码来源:utils.cpp

示例3:

QgsLineString::QgsLineString( const QVector<double> &x, const QVector<double> &y, const QVector<double> &z, const QVector<double> &m )
{
  mWkbType = QgsWkbTypes::LineString;
  int pointCount = std::min( x.size(), y.size() );
  if ( x.size() == pointCount )
  {
    mX = x;
  }
  else
  {
    mX = x.mid( 0, pointCount );
  }
  if ( y.size() == pointCount )
  {
    mY = y;
  }
  else
  {
    mY = y.mid( 0, pointCount );
  }
  if ( !z.isEmpty() && z.count() >= pointCount )
  {
    mWkbType = QgsWkbTypes::addZ( mWkbType );
    if ( z.size() == pointCount )
    {
      mZ = z;
    }
    else
    {
      mZ = z.mid( 0, pointCount );
    }
  }
  if ( !m.isEmpty() && m.count() >= pointCount )
  {
    mWkbType = QgsWkbTypes::addM( mWkbType );
    if ( m.size() == pointCount )
    {
      mM = m;
    }
    else
    {
      mM = m.mid( 0, pointCount );
    }
  }
}
开发者ID:dbaston,项目名称:QGIS,代码行数:45,代码来源:qgslinestring.cpp

示例4: ping

void ServerWidget::ping(){
    textEdit->append("\nPING");

    QStringList adressList = getAdressList();
    QVector<int> portList = getPortList();

    adressList = adressList.mid(0, nbRoles);
    portList = portList.mid(0, nbRoles);

    QMetaObject::invokeMethod(server, "setupPlayers", Qt::AutoConnection,
                              Q_ARG(QStringList, adressList),
                              Q_ARG(QVector<int>, portList));
    QMetaObject::invokeMethod(server, "ping", Qt::AutoConnection);

    // Direct calls like this would execute the function in the current thread
//    server->setupPlayers(adressList, portList);
//    server->ping();
}
开发者ID:tstandley,项目名称:DSN4,代码行数:18,代码来源:serverwidget.cpp


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