Custom ArrayList class Please review my custom ArrayList class I constructed from scratch and add any suggestions or constructive criticisms. The point of this template class is give the user a lightweight ArrayList with optimal control over how it operates.

It is automatically created on the heap with an optional seed value which determines how much space to give it upon being recreated after filling up. It comes with a refine function which cuts off the garbage values at any time and it can also be reseeded. Seed default is 10 new array spots for each recreation.

#ifndef MEMORYLIST_H
#define MEMORYLIST_H

//Class is designed to be a basic array list off the stack
template &lt;class Heap&gt; class MemoryList {
private:
    Heap *array;    //ArrayList on Heap
    int length;     //Max Length of ArrayList
    int counter;    //Current Position on ArrayList
    int seed;       //amount to add by when limit is breached

    //Increase list if needed
    inline void spaceCheck() {
        if (counter == length) {
            int i;

            Heap *temp = new Heap[length];

            for (i = 0; i &lt; length; ++i) {
                temp[i] = array[i];
            }

            delete [] array;

            length += seed;
            array = new Heap[length];

            for (i = 0; i &lt; length - 10; ++i) {
                array[i] = temp[i];
            }

            delete[] temp;
        }
    }

    inline void shiftRight(int place) {
        for (int i = length - 1; i &gt;= place + 1; --i) {
            array[i] = array[i - 1];
        }
    }

public:
    MemoryList(int seed = 10) {
        this-&gt;seed = seed;
        length = seed;
        counter = 0;
        array = new Heap[length];
    }

    //just shows what value is stored in what position
    Heap showValue(int position) {
        return array[position];
    }

    //tack a value to the end
    void newValue(Heap variable){
        spaceCheck();

        array[counter] = variable;
        ++counter;
    }

    //tack a value anywhere you want and array will self adjust
    void insertValue(int position, Heap variable) {
        spaceCheck();
        shiftRight(position);

        array[position] = variable;
        ++counter;
    }

    //delete any value you'd like and array will self adjust
    void deleteValue(int position) {
        for (int i = position; i &lt; length - 1; ++i) {
            array[i] = array[i + 1];
        }

        --counter;
    }

    //Overwrite any value you'd like, no need to adjust anything
    void overWrite(int position, Heap variable) {
        array[position] = variable;
    }

    //swap any two array points
    void swap (int position1, int position2) {
        Heap temp;
        temp = array[position1];
        array[position1] = array[position2];
        array[position2] = temp;
    }

    //reseed amount of space you'd like to allocate when you're running out
    //of room
    void reSeed(int seed) {
        this-&gt;seed = seed;
    }

    //is item in array?
    bool search(Heap item) {
        //this might make it faster ::shrug::
        for (int i = 0, j = counter; i &lt; counter; ++i, --j) {
            if (array[i] == item || array[j] == item) return true;
        }
        return false;
    }

    //Creates perfect ArrayList stored on heap without garbage
    void refine() {
        int i;

        length = counter;     
        Heap *temp = new Heap[length];

        for (i = 0; i &lt; length; ++i) {
            temp[i] = array[i];
        }

        delete [] array;
        array = new Heap[length];

        for (i = 0; i &lt; length; ++i) {
            array[i] = temp[i];
        }

        delete[] temp;
    }

    void finished(){
        delete[] array;
    }
};

#endif // MEMORYLIST_H
A couple of things jump out:

Use size_t for the all allocation sizes/indices. I have had real-world bugs because of this in third-party libraries.

Use exponential, not linear, reallocations. Doubling each time is the best way. This allows .newValue to append in \$O(1)\$ amortized time, as opposed to the current \$O(n)\$.