Link to home
Start Free TrialLog in
Avatar of Winston Smith
Winston SmithFlag for Canada

asked on

C# ring buffer using pointers

I have a need to create a series of ring buffers for storing data from a tool. A simple explanation is there are 8 streams of data coming in, i need to create 8 buffers to hold the data and apply offsets to each streams data to 'straighten' it in time. My lead developer has asked me to use pointers to the head and tail as it will speed up processing immensely.

I do not use pointers very often and I realize pointer based ring buffers are not new. Can someone point me in the right direction for a tutorial, code example etc?

Cheers and Thanks in advance!!

C# windows forms, .NET 3.5
Avatar of Cong Minh Vo
Cong Minh Vo
Flag of Viet Nam image

you can use List, LinkedList, Dictionary(T) ... class to store your ring buffer objects.
You're using C#, a manager language with REFERENCES.  Pointers are not used unless you're talking about UNSAFE blocks.

If your ring buffers are fixed in size then use a classic ARRAY since access to any point will be constant time (a calculation to any index instead of iterating over a list to find that point).
Avatar of Winston Smith

ASKER

Would not the use of pointers, declared as unsafe of course, give a speed advantage over simple array searching? Rather than storing the value at head and tail I am simply updating the address etc etc. thanks for clearing this up, I will need to explain to my lead why we do not go with pointers.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial