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


C++ CharacterVector类代码示例

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


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

示例1: get_first_reencode_pos

R_xlen_t get_first_reencode_pos(const CharacterVector& xc) {
  R_xlen_t len = xc.length();
  for (R_xlen_t i = 0; i < len; ++i) {
    SEXP xci = xc[i];
    if (xci != NA_STRING && !IS_ASCII(xci) && !IS_UTF8(xci)) {
      return i;
    }
  }

  return len;
}
开发者ID:jayhesselberth,项目名称:dplyr,代码行数:11,代码来源:join.cpp

示例2: filter_grouped_single_env

DataFrame filter_grouped_single_env( const Data& gdf, const LazyDots& dots){
    typedef GroupedCallProxy<Data, Subsets> Proxy ;
    Environment env = dots[0].env() ;

    const DataFrame& data = gdf.data() ;
    CharacterVector names = data.names() ;
    SymbolSet set ;
    for( int i=0; i<names.size(); i++){
        set.insert( Rf_installChar( names[i] ) ) ;
    }

    // a, b, c ->  a & b & c
    Call call( and_calls( dots, set, env ) ) ;

    int nrows = data.nrows() ;
    LogicalVector test(nrows, TRUE);

    LogicalVector g_test ;
    Proxy call_proxy( call, gdf, env ) ;

    int ngroups = gdf.ngroups() ;
    typename Data::group_iterator git = gdf.group_begin() ;
    for( int i=0; i<ngroups; i++, ++git){
        SlicingIndex indices = *git ;
        int chunk_size = indices.size() ;

        g_test = check_filter_logical_result( call_proxy.get( indices ) ) ;
        if( g_test.size() == 1 ){
            int val = g_test[0] == TRUE ;
            for( int j=0; j<chunk_size; j++){
                test[ indices[j] ] = val ;
            }
        } else {
            check_filter_result(g_test, chunk_size ) ;
            for( int j=0; j<chunk_size; j++){
                if( g_test[j] != TRUE ) test[ indices[j] ] = FALSE ;
            }
        }
    }
    return grouped_subset<Data>( gdf, test, names, classes_grouped<Data>() ) ;
}
开发者ID:jeevadatascience,项目名称:dplyr,代码行数:41,代码来源:filter.cpp

示例3: distance

  List distance(CharacterVector& lhs, CharacterVector& rhs, int topn)
  {
    uint64_t lhsres;
    uint64_t rhsres;
    vector<pair<string, double> > lhsword;
    vector<pair<string, double> > rhsword;
    const char *const lhs_path = lhs[0];
    const char *const rhs_path = rhs[0];
    hash.make(lhs_path, topn, lhsres, lhsword);
    hash.make(rhs_path, topn, rhsres, rhsword);
    CharacterVector lhsm(lhsword.size());
    CharacterVector lhsatb(lhsword.size());
    //unsigned int it;
    CharacterVector::iterator lhsm_it = lhsm.begin();
    CharacterVector::iterator lhsatb_it = lhsatb.begin();
    for (vector<pair<string, double> >::iterator it = lhsword.begin(); it != lhsword.end(); it++)
    {
      *lhsm_it = (*it).first; lhsm_it++;
      *lhsatb_it = itos((*it).second); lhsatb_it++;
    }
    lhsm.attr("names") = lhsatb;
    
    CharacterVector rhsm(rhsword.size());
    CharacterVector rhsatb(rhsword.size());
    CharacterVector::iterator rhsm_it = rhsm.begin();
    CharacterVector::iterator rhsatb_it = rhsatb.begin();
    for (vector<pair<string, double> >::iterator it = rhsword.begin(); it != rhsword.end(); it++)
    {
      *rhsm_it = (*it).first; rhsm_it++;
      *rhsatb_it = itos((*it).second); rhsatb_it++;
    }
    rhsm.attr("names") = rhsatb;

    CharacterVector hashvec;
    hashvec.push_back(int64tos(hash.distances(lhsres, rhsres)));
    return List::create( Named("distance") = hashvec,
                              Named("lhs") = lhsm,
                              Named("rhs") = rhsm
    );
    
  }
开发者ID:hoyoung2015,项目名称:jiebaR,代码行数:41,代码来源:segtype.hpp

示例4: simhash_fromvec

 List simhash_fromvec(vector<string>& code, int topn)
 {
   vector<pair<string, double> > lhsword;
   uint64_t hashres;
   hash.make_fromvec(code, topn, hashres, lhsword);
   CharacterVector lhsm(lhsword.size());
   CharacterVector lhsatb(lhsword.size());
   //unsigned int it;
   CharacterVector::iterator lhsm_it = lhsm.begin();
   CharacterVector::iterator lhsatb_it = lhsatb.begin();
   for (vector<pair<string, double> >::iterator it = lhsword.begin(); it != lhsword.end(); it++)
   {
     *lhsm_it = (*it).first; lhsm_it++;
     *lhsatb_it = itos((*it).second); lhsatb_it++;
   }
   lhsm.attr("names") = lhsatb;
   CharacterVector hashvec;
   hashvec.push_back(int64tos(hashres));
   return List::create( Named("simhash") = hashvec,
                        Named("keyword") = lhsm);
 }
开发者ID:hoyoung2015,项目名称:jiebaR,代码行数:21,代码来源:segtype.hpp

示例5: connection_escape_identifier

// [[Rcpp::export]]
CharacterVector connection_escape_identifier(XPtr<PqConnectionPtr> con,
                                             CharacterVector xs) {
  int n = xs.size();
  CharacterVector escaped(n);

  for (int i = 0; i < n; ++i) {
    std::string x(xs[i]);
    escaped[i] = (*con)->escapeIdentifier(x);
  }

  return escaped;
}
开发者ID:bpgriner01,项目名称:RPostgres,代码行数:13,代码来源:connection.cpp

示例6: character_vector_equal

  bool character_vector_equal(const CharacterVector& x, const CharacterVector& y) {
    if ((SEXP)x == (SEXP)y) return true;

    if (x.length() != y.length())
      return false;

    for (R_xlen_t i = 0; i < x.length(); ++i) {
      SEXP xi = x[i];
      SEXP yi = y[i];

      // Ideally we'd use Rf_Seql(), but this is not exported.
      if (Rf_NonNullStringMatch(xi, yi)) continue;
      if (xi == NA_STRING && yi == NA_STRING) continue;
      if (xi == NA_STRING || yi == NA_STRING)
        return false;
      if (CHAR(xi)[0] == 0 && CHAR(yi)[0] == 0) continue;
      return false;
    }

    return true;
  }
开发者ID:pachevalier,项目名称:dplyr,代码行数:21,代码来源:utils.cpp

示例7: nodeName

std::string nodeName(T* node, CharacterVector nsMap) {
  std::string name = Xml2String(node->name).asStdString();
  if (nsMap.size() == 0)
    return name;

  xmlNs* ns = node->ns;
  if (ns == NULL)
    return name;

  std::string prefix = NsMap(nsMap).findPrefix(Xml2String(ns->href).asStdString());
  return prefix + ":" + name;
}
开发者ID:jimhester,项目名称:xml2,代码行数:12,代码来源:xml2_node.cpp

示例8: defineVariable

  void defineVariable(CharacterVector x, std::string name) {
    readstat_label_set_t* labelSet = NULL;
    if (rClass(x) == "labelled") {
      labelSet = readstat_add_label_set(writer_, READSTAT_TYPE_STRING, name.c_str());

      CharacterVector values = as<CharacterVector>(x.attr("labels"));
      CharacterVector labels = as<CharacterVector>(values.attr("names"));

      for (int i = 0; i < values.size(); ++i)
        readstat_label_string_value(labelSet, values[i], std::string(labels[i]).c_str());
    }

    int max_length = 0;
    for (int i = 0; i < x.size(); ++i) {
      int length = std::string(x[i]).size();
      if (length > max_length)
        max_length = length;
    }

    readstat_add_variable(writer_, READSTAT_TYPE_STRING, max_length,
      name.c_str(), var_label(x), NULL, labelSet);
  }
开发者ID:Jiangtang,项目名称:haven,代码行数:22,代码来源:DfWriter.cpp

示例9: enterGame

void Player::enterGame()
{
    this->sendMsg(Formatter::clearScreen());
    map<string, string>::reverse_iterator it;

    // Greet them.
    this->sendMsg(Formatter::bold() + "Welcome, " + name + "!\n" + Formatter::reset());

    // Load the news.
    this->sendMsg("#---------------- Global News ----------------#\n");
    for (it = Mud::instance().mudNews.rbegin(); it != Mud::instance().mudNews.rend(); ++it)
    {
        this->sendMsg("Date :" + it->first + "\n");
        this->sendMsg(it->second + "\n");
    }
    this->sendMsg("#---------------------------------------------#\n\n");
    this->sendMsg("You walked through the mist and came into the world...\n\n");

    // Notice all the players in the same room.
    if (room != nullptr)
    {
        room->addCharacter(this);
        // Set the list of exceptions.
        CharacterVector exceptions;
        exceptions.push_back(this);
        // Send the message inside the room.
        room->sendToAll("%s appears.\n", exceptions, name);
    }
    else
    {
        closeConnection();
    }

    // Set the player as logged in.
    logged_in = true;

    // New player looks around.
    doCommand("look");
}
开发者ID:carriercomm,项目名称:RadMud,代码行数:39,代码来源:player.cpp

示例10: output

CharacterVector compose::compose_multiple(DataFrame parsed_urls){
  
  CharacterVector schemes = parsed_urls["scheme"];
  CharacterVector domains = parsed_urls["domain"];
  CharacterVector ports = parsed_urls["port"];
  CharacterVector paths = parsed_urls["path"];
  CharacterVector parameters = parsed_urls["parameter"];
  CharacterVector fragments = parsed_urls["fragment"];
  
  unsigned int input_size = schemes.size();
  CharacterVector output(input_size);
  
  for(unsigned int i = 0; i < input_size; i++){
    if((i % 10000) == 0){
      Rcpp::checkUserInterrupt();
    }
    output[i] = compose_single(schemes[i], domains[i], ports[i], paths[i], parameters[i],
                               fragments[i]);
  }
  
  return output;
}
开发者ID:Ironholds,项目名称:urltools,代码行数:22,代码来源:compose.cpp

示例11: full_join_impl

// [[Rcpp::export]]
DataFrame full_join_impl(DataFrame x, DataFrame y,
                         CharacterVector by_x, CharacterVector by_y,
                         std::string& suffix_x, std::string& suffix_y,
                         bool na_match) {
  if (by_x.size() == 0) stop("no variable to join by");
  typedef VisitorSetIndexMap<DataFrameJoinVisitors, std::vector<int> > Map;
  DataFrameJoinVisitors visitors(y, x, SymbolVector(by_y), SymbolVector(by_x), true, na_match);
  Map map(visitors);

  // train the map in terms of y
  train_push_back(map, y.nrows());

  std::vector<int> indices_x;
  std::vector<int> indices_y;

  int n_x = x.nrows(), n_y = y.nrows();

  // get both the matches and the rows from left but not right
  for (int i = 0; i < n_x; i++) {
    // find a row in y that matches row i in x
    Map::iterator it = map.find(-i - 1);
    if (it != map.end()) {
      push_back(indices_y,  it->second);
      push_back(indices_x, i, it->second.size());
    } else {
      indices_y.push_back(-1); // mark NA
      indices_x.push_back(i);
    }
  }

  // train a new map in terms of x this time
  DataFrameJoinVisitors visitors2(x, y, SymbolVector(by_x), SymbolVector(by_y), false, na_match);
  Map map2(visitors2);
  train_push_back(map2, x.nrows());

  for (int i = 0; i < n_y; i++) {
    // try to find row in x that matches this row of y
    Map::iterator it = map2.find(-i - 1);
    if (it == map2.end()) {
      indices_x.push_back(-i - 1);
      indices_y.push_back(i);
    }
  }

  return subset_join(x, y,
                     indices_x, indices_y,
                     by_x, by_y,
                     suffix_x, suffix_y,
                     get_class(x)
                    );
}
开发者ID:Klaus012,项目名称:dplyr,代码行数:52,代码来源:join_exports.cpp

示例12: canParse

bool canParse(CharacterVector x, const canParseFun& canParse,
              LocaleInfo* pLocale) {
  for (int i = 0; i < x.size(); ++i) {
    if (x[i] == NA_STRING)
      continue;

    if (x[i].size() == 0)
      continue;

    if (!canParse(std::string(x[i]), pLocale))
      return false;
  }
  return true;
}
开发者ID:uribo,项目名称:readr,代码行数:14,代码来源:CollectorGuess.cpp

示例13: let2base_c

//' Finds the integer that represents the nucleotide
//'
//' Returns an integer for {G,A,T,G} and NA for 'N'
//' 
//' @param letter A single nucleotide, as a character.
//' @param alph_vect The alphabet we are using. A dataframe created using 
//' build_alphabet()
//' @return An integer, or NA if the input is 'N'
//' @author Tom Mayo \email{[email protected]@ed.ac.uk}
// [[Rcpp::export]]
int let2base_c(String letter, CharacterVector alph_vect){
    CharacterVector temp = alph_vect;
    temp.push_back("N");
    int len = temp.size();
    int i = 0;
    bool test = true;
    while (test){
        if (temp[i] == letter){
            test = false;
        }
        if(test){
            i++;
        }
        if(i == len){
            stop("Invalid letter, must be ACGTM or N");
        }
    }
    if(i == len - 1){
        double ret = NA_REAL;
        return ret;
    }
    return i;
}
开发者ID:TomMayo,项目名称:kmermods,代码行数:33,代码来源:counting.cpp

示例14: shingle_ngrams

// Create shingled n-grams
// [[Rcpp::export]]
CharacterVector shingle_ngrams(CharacterVector words, int n) {
  int out_length = words.size() - n + 1;
  CharacterVector ngrams(out_length);
  for(int i = 0; i < out_length; i++) {
    CharacterVector subset = words[i - 1 + seq_len(n)];
    std::string ngram;
    for(int j = 0; j < n; j++) {
      ngram += subset[j];
      if(j != n - 1) ngram += " ";
    }
    ngrams[i] = ngram;
  }
  return ngrams;
}
开发者ID:noamross,项目名称:textreuse,代码行数:16,代码来源:shingle_ngrams.cpp

示例15: type_convert_col

// [[Rcpp::export]]
RObject type_convert_col(CharacterVector x, List spec, int col,
                         const std::vector<std::string>& na, bool trim_ws) {
  CollectorPtr collector = Collector::create(spec);
  collector->resize(x.size());

  for (int i = 0; i < x.size(); ++i) {
    SEXP string = x[i];
    Token t;

    if (string == NA_STRING) {
      t = Token(TOKEN_MISSING, i - 1, col - 1);
    } else {
      const char* begin = CHAR(string);
      t = Token(begin, begin + Rf_length(string), i - 1, col - 1);
      if (trim_ws)
        t.trim();
      t.flagNA(na);
    }

    collector->setValue(i, t);
  }

  return collector->vector();
}
开发者ID:zhmz90,项目名称:readr,代码行数:25,代码来源:type_convert.cpp


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