http://stxxl.sourceforge.net
<dementiev@mpi-sb.mpg.de>
<beckmann@cs.uni-frankfurt.de>
http://www.boost.org/LICENSE_1_0.txt
#ifndef STXXL_SIMPLE_VECTOR_HEADER
#define STXXL_SIMPLE_VECTOR_HEADER
#include <algorithm>
#include <stxxl/bits/noncopyable.h>
#include <stxxl/bits/common/types.h>
__STXXL_BEGIN_NAMESPACE
template <class _Tp >
class simple_vector : private noncopyable
{
public:
typedef unsigned_type size_type;
typedef _Tp value_type;
protected:
size_type _size;
value_type * _array;
public:
typedef value_type * iterator;
typedef const value_type * const_iterator;
typedef value_type & reference;
typedef const value_type & const_reference;
simple_vector(size_type sz) : _size(sz), _array(NULL)
{
if (size() > 0)
_array = new _Tp[size()];
}
void swap(simple_vector & obj)
{
std::swap(_size, obj._size);
std::swap(_array, obj._array);
}
~simple_vector()
{
delete[] _array;
}
iterator begin()
{
return _array;
}
const_iterator begin() const
{
return _array;
}
const_iterator cbegin() const
{
return begin();
}
iterator end()
{
return _array + _size;
}
const_iterator end() const
{
return _array + _size;
}
const_iterator cend() const
{
return end();
}
size_type size() const
{
return _size;
}
reference operator [] (size_type i)
{
return *(begin() + i);
}
const_reference operator [] (size_type i) const
{
return *(begin() + i);
}
};
__STXXL_END_NAMESPACE
namespace std
{
template <class Tp_>
void swap(stxxl::simple_vector<Tp_> & a,
stxxl::simple_vector<Tp_> & b)
{
a.swap(b);
}
}
#endif