[go: up one dir, main page]

Menu

[8f591a]: / common / simple_vector.h  Maximize  Restore  History

Download this file

71 lines (62 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef SIMPLE_VECTOR_HEADER
#define SIMPLE_VECTOR_HEADER
__STXXL_BEGIN_NAMESPACE
template < class _Tp /*, class _Alloc=__STL_DEFAULT_ALLOCATOR(_Tp) */ >
class simple_vector
{
simple_vector ()
{
};
public:
typedef size_t size_type;
typedef _Tp value_type;
// typedef simple_alloc<_Tp, _Alloc> _data_allocator;
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 = _data_allocator.allocate(sz);
_array = new _Tp[sz];
}
~simple_vector ()
{
// _data_allocator.deallocate(_array,_size);
delete [] _array;
}
iterator begin ()
{
return _array;
}
const_iterator begin () const
{
return _array;
}
iterator end ()
{
return _array + _size;
}
const_iterator end () const
{
return _array + _size;
}
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
#endif