Dynamic Arrays (Similar to C++ std::vector)

Here is an early implementation of a dynamic array for Ecere…

It is most likely a interim solution until truer “templates” make an apparition in eC.

Download Array.ec

(Please don’t mind the obscurity of the internals. Like all things, it’s impermanent.)

You would use it as such:

import “Array”

public class ArrayPoint : Array
{
type = class(Point);
public Point * points;
};
void Test()
{
ArrayPoint points { size = 10 };
points.points[0] = { 10, 10 };
points.size = 20;
points.points[19] = { 5, 5 };
delete points;
}

One Response to “Dynamic Arrays (Similar to C++ std::vector)”

  1. admin says:

    The truer templates have arrived!

    See release 0.43 notes at:

    http://www.ecere.com/blog/2008/09/03/ecere-sdk-043-templates-syntax-highlighting/

    This example would now read:

    void Test()
    {
    Array points { size = 10 };
    points[0] = { 10, 10 };
    points.size = 20;
    points[19] = { 5, 5 };
    delete points;
    }

Leave a Reply