Array.h is actually useful even though it may seem unnecessary.
It provides the struct Array which is simply a wrapper for new and delete.
When using new to allocate an Array in a subroutine,
and you want to return from the subroutine if things go wrong at any point,
you would normally have to ensure that you delete the Array at every return.
The main point of using the Array struct is that the destructor will delete the array elements correctly when the instance goes out of scope so there won't be any memory leaks.
You would only use this when the Array size isn't an fixed number on creation - otherwise int Table; would be fine.
Keeping the Array Element Count in the struct never seems to be useful: the count is generally known by whatever creates the array anyway.
A class called COMArray is in Array.h too, which is a wrapper for COM SafeArrays.
FixedArray.h provides a class called CFixedArray which would normally be used to hold an array of sorted data which you need to search very quickly (Binary Chop is used).
A sequential sort is also available for unsorted data.
It was developed for a graphics application which, while drawing potentially millions of things on the screen, needed to know if the thing it was currently drawing was "selected" or not (by the user).
So the Array holds the ID of selected entities which would be drawn in a specific way.
The array is set up before the redraw and the renderer asks the array if it contains the ID of each entity before it draws it.
Obviously this requires a search with minimal overhead - hashing was slower because of the large range of IDs and the small number of entities normally selected.
See the Tester class at the end of FixedArray.h for usage examples.
The Flat flag and Grow members are intended only for use while developing algorithms which are intended ultimately to result in fixed arrays.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(1475) Last modified: Fri, 15 May 2009 14:25:10 +0000