This is proving to be more useful than I imagined it would be when I first wrote this utility! Consequently, I have seen fit to add two additional methods and to think very carefully about a potential dll problem (described below and in detail within the user guide).
The new methods are :
- SwapElements() - no explanation required here I think!
This is very fast even with structured arrays because all it does in these cases is swap pointers etc.
- GetPointerToValue().
Now this is for structured array classes only and is much faster than the GetValue() method in these cases because it does not populate a given structure from an array, but simply returns a pointer. (DO NOT use this pointer to directly alter string fields within the array itself though!)
Please see the user guide for a detailed explanation of this.
Of course, this is really only an issue for those who decide to stuff the code for the array classes within a dll and attempt to call the resulting functions from the host application etc. Not a problem in general, just for this rather special case.
Download
============================================
Hi,
this is the second of my long standing utilities which I've now converted to OOP and this one I use more than any other utility I possess. Indeed, as I now spend the majority of my coding time creating custom Window's controls, this utility deals very nicely with just about all of the dynamic memory requirements which creating such controls demand.
In converting to OOP I have also taken the opportunity to upgrade the library somewhat.
Basically, this library (provided in source code form) allows you to dynamically create and nest dynamic arrays of any structured type - including those containing string fields. Such arrays can be nested and embedded in structures or linked lists or even other arrays etc.
The library basically wraps PB's memory functions, but takes care to ensure, in particular, that string fields are handled correctly so that there are no memory leaks etc. This is always tricky when dealing with dynamic memory allocations and strings. I tend to avoid linked lists for such things in order to ensure threadsafety without having to resort to synchronisation techniques etc.
The library is fully cross-platform and the download includes all the source code, two examples (one each for the different types of array class) and a short user guide.
Methods exposed by each of the two array classes :
- Destroy()
- GetUpperBound()
- GetValue()
- ReDim()
- SetValue()
- ShiftElementsLeft()
- ShiftElementsRight()
I will ask that if you are no fan of OOP or indeed cannot see any use (or have no use) for this utility then please refrain from commenting here. Start another thread, send a pm, write a letter, send a carrier pigeon, contact your local MP... etc.
