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


C++ StringTokenizer::nextIntToken方法代码示例

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


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

示例1: get_vectors

// this returns a vector of vector<int>s. each vector is a group of parameters
// that are related to one another by one or more constraints
//  uses global variable num_groups and group_info to divide the point
//  co-ordinate values to independent groups
vec_of_intvec get_vectors (string point)
{
    vec_of_intvec matrix;
    StringTokenizer strtok (point, " ");
    // num_groups :: how many independent groups?
    for(int i=0; i < num_groups; i++)
    {
        vector<int> temp_vector;
        // group_info :: how to divide up the values?
        for(int j=0; j < group_info[i];j++)
        {
            int temp = strtok.nextIntToken();
            temp_vector.push_back(temp);
        }
        matrix.push_back(temp_vector);
    }
    return matrix;
}
开发者ID:jonfetterdegges,项目名称:activeharmony,代码行数:22,代码来源:pserver.c

示例2: simplex_construction

void simplex_construction(HDescrMessage *mesg, int client_socket)
{
    // Assumption: The string message is of the form :
    //    radius point
    //    [if different radii]: radius1:radius2:...

    // first get the query string
    char* temp = (char *) malloc(strlen(mesg->get_descr())+10);
    strcpy(temp, mesg->get_descr());
    printf("simplex construction :::: got the request point: %s \n", temp);
    string str_point(temp);
    StringTokenizer strtok(str_point, " ");
    //string r_str = strtok.nextToken();
    int radii[num_groups];
    int radius=1;

    // use different scaling?
    if(use_diff_radius == 1)
    {
        string r_str = strtok.nextToken();
        StringTokenizer radtok (r_str, ":");
        if(radtok.countTokens() != num_groups) {
            fprintf(stderr, "not enough radius values \n");
        } else {
            for(int i = 0; i < num_groups; i++)
            {
                radii[i]=radtok.nextIntToken();
            }
        }
    } else {
        radius = strtok.nextIntToken();
    }
    printf("radius: %d \n", radius);
    string remaining    = strtok.remainingString();
    cout << "remaining: ";
    cout << remaining;
    cout << "\n";

    // first make sure the given init_point is a valid point : make a call
    // to projection function : could move this to a new routine later on
    vec_of_intvec vec_of_vec = get_vectors(remaining);
    string projected_init_point="";
    for(int i=0; i < num_groups; i++) {
        int temp_dim=group_info[i];
        vector<int> temp_vector = vec_of_vec.at(i);
        ANNpoint point = make_point_from_vector(temp_vector,temp_dim);
        if(!is_valid(trees.at(i),temp_vector, temp_dim))
        {
            projected_init_point += get_neighbor(trees.at(i),point,nn_num[i]);
        }
        else
        {
            projected_init_point += vector_to_string(temp_vector);
        }
    }
    cout << "Init Point projected from " << remaining << " to " << projected_init_point << "\n";

    // now constructed the simplex around the projected point
    vec_of_vec = get_vectors(projected_init_point);
    string return_string = "\n global init__ \n set init__ [list ";
    for(int i=0; i < num_groups; i++)
    {
        int temp_dim=group_info[i];
        vector<int> temp_vector = vec_of_vec.at(i);
        ANNpoint init_point = make_point_from_vector(temp_vector, temp_dim);
        if(use_diff_radius)
        {
            return_string += get_neighbor_at_dist(trees.at(i), radii[i], init_point, nn_num[i], i);
        } else
        {
            return_string += get_neighbor_at_dist(trees.at(i), radius, init_point, nn_num[i], i);
        }
    }
    return_string+="]";

    cout << "Initial Simplex Possible points:: " << return_string << "\n";
    char *char_star;
    char_star = new char[return_string.length() + 1];
    strcpy(char_star, return_string.c_str());
    //FILE * pFile;
    FILE *pFile;
    pFile = fopen ("/hivehomes/tiwari/tutorial-2010/harmony/bin/constructed_simplex.tcl","w");
    if (pFile!=NULL)
    {
        fputs (char_star,pFile);
        fclose (pFile);
    }
    HDescrMessage *mesg_desr=new HDescrMessage(HMESG_SIM_CONS_RESULT,char_star,strlen(char_star));
    send_message(mesg_desr, client_socket);
    delete mesg_desr;
    delete [] char_star;
}
开发者ID:jonfetterdegges,项目名称:activeharmony,代码行数:92,代码来源:pserver.c


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