Fast linked list without list

If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution.
Derive your objects from this class and implement doSomething():

class Element
{
    public:
        Element();
        ~Element();

        virtual void doSomething()=0;

        Element* next;

        static void addElement( Element* el )
        {
            el->next = first;
            first = el;
        }

        static Element* first=nullptr;
};

And to use it:

    // Adding one element to the list:
    Element::addElement( &myObject );

    // Iterating over the objects:
    Element* el = Element::first;
    while( el )
    {
        el->doSomething();
        el = el->next;
    }


Fast linked list without list

If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution. Der...