random_shuffle not working?

This line of code is giving problems..
random_shuffle( buffer[ 0 ],buffer[ NSITES - 1 ] );

in the function..
1
2
3
4
5
6
7
8
9
10
11
12
void Lattice::initialiseSitesAtomID()
{
        //buffer stores ordered sequence
	int buffer[ NSITES ];
	for( int i = 0; i < NSITES; i++ ) { buffer[ i ] = i; }

	//shuffle sequence
    random_shuffle( buffer[ 0 ],buffer[ NSITES - 1 ] );

    //buffer gives shuffled sequence to sites
    for( int i = 0; i < NSITES; i++ ) { sites[ i ].setAtomID( buffer[ i ] ); }
}


Can anybody see why?
Does it only work with vectors?
I think arrays should be fine.. how can you shuffle a sequence in arrays otherwise?

Thanks,
Clodi
randome_shuffle works with pointers(in arrays) or iterators (STL containers).
do randome_shuffle(buffer,buffer+x)
where buffer is the start of the array, and x is the offset position from the beginning.
If the array is declared type buffer[size]; , then x will be size if you wnat to shuffle the whole array.
thanks a lot!! it worked!
Topic archived. No new replies allowed.