本文整理汇总了C++中rcpp::IntegerVector::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ IntegerVector::sort方法的具体用法?C++ IntegerVector::sort怎么用?C++ IntegerVector::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcpp::IntegerVector
的用法示例。
在下文中一共展示了IntegerVector::sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_body_gz
// [[Rcpp::export]]
Rcpp::CharacterMatrix read_body_gz(std::string x,
Rcpp::NumericVector stats,
int nrows = -1,
int skip = 0,
Rcpp::IntegerVector cols = 0,
int convertNA = 1,
int verbose = 1) {
// NA matrix for unexpected results.
Rcpp::StringMatrix na_matrix(1,1);
na_matrix(0,0) = NA_STRING;
/*
* Manage cols vector.
* The first eight (1-based) columns are mandatory.
* We can ensure they are there by adding them,
* sorting and removing adjacent non-identical values.
*/
// for( int i=9; i >= 1; i-- ){
for( int i=8; i >= 1; i-- ){
cols.push_front(i);
}
cols.sort();
// Remove duplicate values using a set.
std::set<int> s( cols.begin(), cols.end() );
cols.assign( s.begin(), s.end() );
cols = cols - 1; // R is 1-based, C is 0-based.
// Initialize matrix for body data.
// old: Rcpp::CharacterMatrix gt(stats[2], stats[3]);
int row_num = 0;
if( ( nrows == -1 ) & ( skip == 0 ) ){
nrows = stats[2];
} else if ( ( nrows != -1 ) & ( skip == 0 ) ){
// nrows = nrows;
} else if ( ( nrows == -1 ) & ( skip > 0) ){
nrows = stats[2] - skip;
} else if ( ( nrows != -1 ) & ( skip > 0) ){
// nrows = nrows;
} else {
Rcpp::Rcerr << "failed to calculate return matrix geometry.";
return na_matrix;
}
Rcpp::CharacterMatrix gt( nrows, cols.size() );
// if ( nrows > -1 & skip == 0 ){
// row_num = nrows;
// } else if ( nrows == -1 & skip > 0 ){
// row_num = stats[2] - skip;
// } else {
// row_num = stats[2];
// }
// Rcpp::CharacterMatrix gt( row_num, cols.size() );
row_num = 0;
if( verbose == 1 ){
Rcpp::Rcout << "Character matrix gt created.\n";
Rcpp::Rcout << "Character matrix gt rows: "; Rcpp::Rcout << gt.rows();
Rcpp::Rcout << "\n";
Rcpp::Rcout << "Character matrix gt cols: "; Rcpp::Rcout << gt.cols();
Rcpp::Rcout << "\n";
Rcpp::Rcout << "skip: "; Rcpp::Rcout << skip;
Rcpp::Rcout << "\n";
Rcpp::Rcout << "nrows: "; Rcpp::Rcout << nrows;
Rcpp::Rcout << "\n";
Rcpp::Rcout << "row_num: "; Rcpp::Rcout << row_num;
Rcpp::Rcout << "\n";
Rcpp::Rcout << "\n";
}
// Create filehandle and open.
gzFile file;
file = gzopen (x.c_str(), "r");
if (! file) {
Rcpp::Rcerr << "gzopen of " << x << " failed: " << strerror (errno) << ".\n";
return na_matrix;
}
// Because the last line may be incomplete,
// We'll typically omit it from processing and
// concatenate it to the first line.
// But first we'll have to initialize it.
std::string lastline = "";
// String vector to store the header (^#CHROM...).
std::vector<std::string> header_vec;
// variant counter.
int var_num = 0;
//.........这里部分代码省略.........