Well, shift and cshift STL algorithms shifts the whole array. In your first
example you wrote:

>Imagine that indexes 0, 1 and 2 are used.  Then 1 moves to 0, 2 to 1, and 0
>to 2.

If I'm getting you right, this means that vector 0,1,2 becomes 1,2,0 and
this is exactly what the code I wrote does.

Anyway, if you need a more versatile function, you might want to have a look
at std::slice

HTH,
Carlos

----- Original Message ----- 
From: "Truckle, Andrew J" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 05, 2004 11:28 AM
Subject: RE: [msvc] How to shift up array items


> But I am shifting the whole array.  I am shifting the first x entries in
the
> array and the first one does not go to the bottom of the array but to the
> tail end of the entries I am shifting.  So the addition entries in the
array
> are irrelevant and stay as they are...
>
> > -----Original Message-----
> > From: Juan Carlos [mailto:[EMAIL PROTECTED]
> > Sent: 05 July 2004 10:32
> > To: [EMAIL PROTECTED]
> > Subject: Re: [msvc] How to shift up array items
> >
> >
> > Hi,
> >
> > > Hi
> > >
> > > > Never used vectors....  But yes, using c++
> > >
> > > Those two sentacnes don't really go togehter. ;-)
> > >
> > > It's in MSDN and is usually a much better alternitive to an array.
> >
> > You can use valarrays. For example:
> >
> > #include <valarray>
> > int main(int argc, char* argv[])
> > {
> >  int ar[] = {  0, 1, 2};
> >
> >  std::valarray<int> v(ar, sizeof(ar)/sizeof(ar[0]));
> >
> > //Shift vector ciclycally
> >   v = v.cshift(1);
> >
> >
> >  return 0;
> > }
> >
> > _______________________________________________
> > msvc mailing list
> > [EMAIL PROTECTED]
> > See
> > http://beginthread.com/mailman/listinfo/msvc_b> eginthread.com
> > for subscription changes, and list archive.
> >
> >
> >
> > This message has been scanned for viruses by BlackSpider
> > MailControl - www.blackspider.com
> >
>
>
> This email and any attached files are confidential and copyright
protected.
> If you are not the addressee, any dissemination of this communication is
> strictly prohibited. Unless otherwise expressly agreed in writing, nothing
> stated in this communication shall be legally binding.
>
>
>
> _______________________________________________
> msvc mailing list
> [EMAIL PROTECTED]
> See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive

_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription 
changes, and list archive.

Reply via email to