Hi all,
Summary: Can I pass out a linked list value type/pointer (my own class) from C++ to C# If not, what are the overheads/caveats involved in passing things around as void*s in C#
I'm trying to use C# as a basis for an audio application. I'm finding the speed is fine as long as I avoid a lot of object allocation/deallocation. By using a bit of C++ here and there I'm able to create and destroy critical objects in system memory rather than on the managed heap.
Recently in an attempt to further improve the speed of the application I ditched my ArrayList based buffers for a simple sorted linked list. I believed that the greater efficiency of the buffers would outweigh the hit incurred from creating and destroying list nodes. I was wrong.
So now down to the question. I'm looking for a way to implement the linked-list structure in C++ for use in C#. The main problem is that my major efficiency breakthrough hinges on passing the linked list nodes out directly to accessing classes so they can enumerate through all or part of the list.
As you can see it's a catch 22. I either use managed C++ to implement the class, giving me no actual gain, or I use unmanaged C++ and I have to pass things out through a managed wrapper. I'm not sure if I can do this, or whether it will be any faster in the end. C++ won't even let me create the circular reference that is fundamental to implementing a linked list!
Things are becoming too complicated and so far I haven't even matched the performance of the ArrayList, which has to copy itself as it grows or shift data when elements are removed. Any general suggestions on how to accomplish this task in other ways would be appreciated.