Anda di halaman 1dari 1

public:

#include
using
template
{class
private:
namespace
Vector
<iostream>
<string>
<cassert>
<algorithm>
<cstring>
<class
Ttypedef
Vector();
Vector(unsigned
Vector(const
~Vector();
unsigned
* buffer;
std;Tint
T>
* Iterator;
my_capacity;
Vector<T>
capacity()
size()
my_size;
int const;
size);
size,
&v);
const;
const
// Returns
T &initial);
Constructor
// the
Returns
thatcapacity
number
copies
of elements
of vector
in the
vector
Iterator
bool empty()
begin();
const; ////isReturns
vectoriterator
empty? pointing the first element o
f the vectorIterator end(); // Returns iterator pointing to the last element of
vector
T &back();
void
&front();
push_back(const
// Returns
T &reference
value); //toAdds
the new
firstelement
last
element
elementto back of vecto
r
void reserve(unsigned
pop_back(); // Removes
int capacity);
the last //
element
Adjusts
of the
vector
capacity of vecto
rt///emplate<class
};
Vector<T>::Vector()
Vector<T>::Vector(unsigned
Vector<T>::Vector(const
Vector<T>::~Vector()
unsigned
template
bool
typename
void
Ttemplate<class
}{Vector<T>
/&Vector<T>::operator[](unsigned
&Vector<T>::front()
&Vector<T>::back()
Method
check
Returns
Return
Add
remove
Readjusts
return
Adjusts
T{if(buffer
copy(buffer,
assert(new_buffer);
delete[]
//
delete[]buffer;
if
my_size--;
reserve(size);
delete[
my_size
my_capacity
buffer
for
}return
Vector<T>::reserve(unsigned
Vector<T>::empty()
Vector<T>::push_back(const
Vector<T>::pop_back()
Vector<T>::resize(unsigned
*(my_size
else
(capacity
create
5loop
my_size
my_capacity
return;
new_buffer
buffer[index]
return
reserve(my_capacity
(int
buffer[i]
int
if
<class
Vector<T>::Iterator
to
return
to
the
last
reference
&Vector<T>::operator
Vector<T>
Tvoid
my_capacity;
{my_size;
buffer;
iterator
buffer
buffer[0];
buffer[my_size
[my_size++]
=buffer[index];
*this;
the
through
=]the
&inew
buffer;
new_buffer;
0;
index
Vector<T>::capacity()
return
Vector<T>::size()
the
==operator[](unsigned
0;
new
first
last
size;
buffer;
v.my_size;
capacity
true;
false;
element
=T>
resize(unsigned
T>0;
==
capacity
=>=
0)=v.my_capacity;
<=
buffer
T[size];
T[my_size];
the
vector
Tsize
capacity;
0;
size;
+array
=[size];
0)
element
my_capacity)
[my_size];
=&capacity
my_capacity)
//
vector
the
pointing
size();
element
ito
v.buffer[i];
new
0;
{=0;operator=(const
<of
=default
of
numbered
+ofvector
initial;
Vector<T>
and
index
v.buffer[index];
size
is
const
my_size;
Tvector
of
v;
-my_size,
vector
[capacity];
int
and
empty
of
assign
of
1];
+the
of5);
the
Vector<T>::begin()
to
Vector<T>::end()
<=the
of
the
constructor
size)
size,
assign
copy
const
int
size;
my_size;
the
Tvector
element
{int
the
first
(const
i++)
vector
&v)
int
int
new_buffer);
it
const
vector
size);
elements
vector
last
size)
capacity)
//Constructs
const
vector
initial
index++)
to
{index)
Vector<T>
index);
element
Vector<T>
buffer
index++)
element
T//to
&initial)
Readjusts
param
{buffer
of
&);
of&the
{ v)
tovector
vector
buffer
the size
with
[index]
ofthevector
given size

Anda mungkin juga menyukai