halcon学习之tuple元素排序操作

//转置一个数组

HTuple tuple;
    tuple = HTuple::TupleGenSequence(1, 10, 1);//获得1-10的数组序列

    for (int i = 0; i<tuple.Length(); i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;

    HTuple result = tuple.TupleInverse();//对数组序列进行转置
    for (int i = 0; i<result.Length();i++)
    {
        cout << (double)result[i] << " ";
    }
    cout << endl;

//对指定数组进行升序排列

tuple[5] = 14;
    tuple[1] = 21;
    tuple[9] = 1;
    for (int i = 0; i<tuple.Length(); i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    result = tuple.TupleSort();
    for (int i = 0; i<result.Length(); i++)
    {
        cout << (double)result[i] << " ";
    }
    cout << endl;

//对指定数组进行升序排列,返回数组元素下标的变换位置

tuple[5] = 10;
    tuple[1] = 24;
    tuple[9] = 5;
    for (int i = 0; i<tuple.Length(); i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    result = tuple.TupleSortIndex();
    for (int i = 0; i<result.Length(); i++)
    {
        cout << (double)result[i] << " ";
    }
    cout << endl;

你可能感兴趣的:(halcon学习之tuple元素排序操作)