vectorbase::Wrap

Description

Wrap around elements of the vector.

Syntax

BOOL Wrap( int nNum = 0 )

Parameters

nNum
[input]number of elements to wrap around. For value greater than 0, elements are wrapped to the left. For values less than 0, elements are wrapped to the right. If value is 0, no wrapping is performed.

Return

Returns TRUE on success or FALSE on error.

Examples

EX1

void vectorbase_Wrap_ex1()
{
    vector vec1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    // Wrap right
    vec1.Wrap(-3);
    for( int ii=0; ii<vec1.GetSize(); ii++ )
        printf("%.0f ",vec1[ii]);
    printf("\n");
    // Result:
    //        vec1 = {7, 8, 9, 1, 2, 3, 4, 5, 6}
    //
    vector vec2 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    // Wrap left
    vec2.Wrap(2);
    for( ii=0; ii<vec2.GetSize(); ii++ )
        printf("%.0f ",vec2[ii]);
    // Result:
    //        vec2 = {3, 4, 5, 6, 7, 8, 9, 1, 2}                                
}

Remark

Wrap around elements of the vector by specified number of elements.

See Also

header to Include

origin.h