output data and sequences

I have this problem :
I have a sequence of float and i must find all the pair next values that differ of more than a delta.
I do this for separating some tokens in a sequence of float.
Each token that differs more than a delta to the next must be separed.

my principal problems that i’m not understand in opencl (Because in opencl there aren’t containers)are these:

1)I don’t know how many tokens are in the sequence , then how i can set all the sequences in a out buffers ? and how many big must be the out buffer?
2)if I have some values that aren’t sequential how i can create a buffer that is sequential?I must use prefix sum?how?
for ex:

if i have
values: 1 0 0 2 3
indexes: 1 2 3 4 5

how i can create this sequence :

values: 1 2 3 0 0
indexes: 1 2 3 4 5


These links might be helpful for you:


very thanks tera.

i found also this for the use of scan in gpu programming(the reason of scan), http://http.developer.nvidia.com/GPUGems3/gpugems3_ch39.htmlthanks.