library/src/utility/BP-NumberUtilities.cc
// generates a size_t * array of indexes the size of the array.  Results must be bpfreed.
generates a size_t * array of indexes the size of the array.  Results must be bpfreed.
generates a size_t * array of indexes the size of the array . Results must be bpfreed .
size_t * BP_GenIntegerIndexArray(size_t arr_elems, size_t randomize_order)
{
	if(!arr_elems)
		return NULL;
	size_t * elems = (size_t *) bpcalloc(sizeof(size_t) * arr_elems, 1);
	size_t n = 0;
	for(; n < arr_elems; n++)
		elems[n] = n;
	if(!elems)
		return NULL;
	if(randomize_order)
	{
		size_t * elems_old = elems;
		elems = (size_t *) BP_RandomizePointerArray((char **) elems, arr_elems);
		bpfree(elems_old);
	}
	return elems;
}
size_t * BP_GenIntegerIndexArray ( size_t arr_elems , size_t randomize_order ) { if ( ! arr_elems ) return NULL ; size_t * elems = ( size_t * ) bpcalloc ( sizeof ( size_t ) * arr_elems , 1 ) ; size_t n = 0 ; for ( ; n < arr_elems ; n ++ ) elems [ n ] = n ; if ( ! elems ) return NULL ; if ( randomize_order ) { size_t * elems_old = elems ; elems = ( size_t * ) BP_RandomizePointerArray ( ( char * * ) elems , arr_elems ) ; bpfree ( elems_old ) ; } return elems ; }
generates a size_t * array of indexes the size of the array.
generates a size_t * array of indexes the size of the array .
// check to make sure that the element size request is non-zero // generate elements // return null on allocation failure // randomize the elements if asked // save old before randomizing // create new randomized array from the old array // destroy the non-randomized elements // return the elements