#ifndef N_BUCKET_H #define N_BUCKET_H //------------------------------------------------------------------------------ /** @brief A bucket contains a fixed-size array of nArray objects, each initialized with a size of 0, and a grow size. Handy for bucket sorts. @author - RadonLabs GmbH @since - 2005.6.30 @remarks - Áö¿Ï Ãß°¡ */ #include "Narray.h" //------------------------------------------------------------------------------ template class nBucket { public: /// constructor nBucket(int initialSize, int growSize); /// destructor ~nBucket(); /// access to bucket array nArray& operator[](uint bucketIndex); /// clear all arrays void Clear(); /// reset all contained arrays void Reset(); /// get number of bucket arrays int Size() const; private: /// default constructor is private nBucket(); /// assignment operator is private (FIXME) nBucket& operator=(const nBucket& rhs); nArray arrays[NUMBUCKETS]; }; //------------------------------------------------------------------------------ /** */ template nBucket::nBucket(int initialSize, int growSize) { uint i; for (i = 0; i < NUMBUCKETS; i++) { this->arrays[i].Reallocate(initialSize, growSize); } } //------------------------------------------------------------------------------ /** */ template nBucket::~nBucket() { // empty } //------------------------------------------------------------------------------ /** The default constructor is illegal. */ template nBucket::nBucket() { } //------------------------------------------------------------------------------ /** The assignment operator is illegal (FIXME). */ template nBucket& nBucket::operator=(const nBucket& rhs) { return *this; } //------------------------------------------------------------------------------ /** Access to embedded arrays. */ template nArray& nBucket::operator[](uint bucketIndex) { return this->arrays[bucketIndex]; } //------------------------------------------------------------------------------ /** Clear all contained arrays (does apply element destructor). */ template void nBucket::Clear() { uint i; for (i = 0; i < NUMBUCKETS; i++) { this->arrays[i].Clear(); } } //------------------------------------------------------------------------------ /** Reset all contained arrays (does not apply element destructor). */ template void nBucket::Reset() { uint i; for (i = 0; i < NUMBUCKETS; i++) { this->arrays[i].Reset(); } } //------------------------------------------------------------------------------ /** Returns number of bucket arrays. */ template int nBucket::Size() const { return NUMBUCKETS; } //------------------------------------------------------------------------------ #endif