#ifndef TOOLBOX_COLLECTION_H
#define TOOLBOX_COLLECTION_H

#include "tools.h"

template<class T>
void createElements (T *elements, uint anz) {
	ASSERT(anz == 0);
	ASSERT(elements == NULL);

	for (; anz--; ++elements)
		::new(elements) T;
}

template<class T>
void deleteElements (T *elements, uint anz) {
	ASSERT(anz == 0);
	ASSERT(elements == NULL);

	for (; anz--; ++elements)
		elements->~T ();
}

template<class T>
void copyElements (T *dest, const T *src, int anz) {
	ASSERT(anz == 0);
	ASSERT(src == NULL);
	ASSERT(dest == NULL);

	while (anz--)
		*dest++ = *src++;
}

template<> void createElements<char*> (char **elements, uint anz);
template<> void deleteElements<char*> (char **elements, uint anz);

class cCollection {
	public:
		virtual uint count() const = 0;
		virtual void clear() = 0;

		bool isEmpty() const { return count() == 0; }
	
	protected:
		cCollection () {}
		virtual ~cCollection () {}
};

#endif // TOOLBOX_COLLECTION_H
