BaseArray



  • On 07/04/2014 at 01:01, xxxxxxxx wrote:

    Sorry, I tried a sorts of typecasts, but I did not succeed.
    It keeps telling me Error: identifier "ConstIterator" is unidentified .

    Could you please give me an example.

    Pim



  • On 07/04/2014 at 08:34, xxxxxxxx wrote:

    Is Swap() not supposed to used like this ?

      
    myBaseArray.Swap(myBaseArray[2], myBaseArray[1]);  
    


  • On 08/04/2014 at 01:56, xxxxxxxx wrote:

    I read the manual as that you have to supply two indexes in basearray.
    But I think you are right. I give it a try.

    Thanks, Pim

    _<_div ="memproto" style="font-weight: bold; font-size: 14px; line-height: 22px; font-family: roboto, sans-serif; border-top-width: 1px; border-top-style: solid; border-top-color: rgb150, 170, 209; border-left-width: 1px; border-left-style: solid; border-left-color: rgb150, 170, 209; border-right-width: 1px; border-right-style: solid; border-right-color: rgb150, 170, 209; padding: 6px 0px; color: rgb26, 37, 59; text-shadow: rgba255, 255, 255, 0.901961 0px 1px 1px; -: http://kinug.com/c4d/cpp/help/pages/c4d_miscav_f.png; : rgb220, 226, 239; -shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; -webkit--shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; border-top-right-radius: 4px; border-top-left-radius: 4px; -repeat: repeat no-repeat;"_>_void Swap ( Iterator a,
    Iterator b
    ) inline_>

    _<_div ="memdoc" style="font-size: 14px; line-height: 22px; font-family: roboto, sans-serif; border-width: 0px 1px 1px; border-bottom-style: solid; border-bottom-color: rgb150, 170, 209; border-left-style: solid; border-left-color: rgb150, 170, 209; border-right-style: solid; border-right-color: rgb150, 170, 209; padding: 6px 10px 2px; -: http://kinug.com/c4d/cpp/help/pages/c4d_miscav_g.png; -shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; -webkit--shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; -repeat: repeat no-repeat;"_>_epeat no-repeat;">
    Swaps elements a and b (equivalent to global Swap(array[a], array **)
    Parameters
    [in]| a| Position of element to be swapped.
    ---|---|---
    [in]| b| Position of elemen_<_t_>_ be swapped.



  • On 09/04/2014 at 03:03, xxxxxxxx wrote:

    Have you tried something like this?

    arr.Swap(arr.Begin() + 2, arr.Begin() + 1)
    


  • On 09/04/2014 at 07:53, xxxxxxxx wrote:

    This is working:

    myBaseArray.Swap(myBaseArray.Begin() + 2, myBaseArray.Begin() + 1)
    

    This is NOT working:

    myBaseArray.Swap(myBaseArray[2], myBaseArray[1]);
    


  • On 09/04/2014 at 15:35, xxxxxxxx wrote:

    Very strange since the documentation shows the NOT working way as an example.  Maybe we can get some resolution on what is valid and what is not?



  • On 10/04/2014 at 01:50, xxxxxxxx wrote:

    Yes, indeed strange. Hopefully someone can check / explain.
    But for now, I have a solution.



  • On 10/04/2014 at 03:59, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Very strange since the documentation shows the NOT working way as an example.  Maybe we can get some resolution on what is valid and what is not?

    Could you point me to the link where the BaseArray documentation shows a wrong example?

    The documentation states that you need an iterator for the position and just using an Int or passing the content of a specific array position (like the OP did in his examples) of course doesn't magically create an iterator (just imagine the swap function would have expected a String as input parameter for the position, then just passing an Int wouldn't work either).

    You have to pass the expected parameter type - and Niklas showed how to do it properly.

    Best regards,

    Wilfried



  • On 10/04/2014 at 18:17, xxxxxxxx wrote:

    Not a direct example, but it somewhat draws one in the wrong direction if you have no idea about BaseArray::Swap() :

    Swaps elements a and b (equivalent to global Swap(array[a], array[b]))
    

    **
    **
    **
    **




  • On 11/04/2014 at 07:07, xxxxxxxx wrote:

    Reading that, I immediately think of Swap looking like this:

    template <typename T>
    void Swap(T& a, T& b) {
        T c = a;
        a = b;
        b = c;
    }
    

    Would be of no advantage to define it as a member method if it is declared and implemented 
    like this. I agree, though, that the documentation could elaborate more on swapping.

    Best,
    -Niklas


Log in to reply