32 #include "dcmtk/config/osconfig.h" 34 #ifndef HAVE_CLASS_TEMPLATE 35 #error Your C++ compiler cannot handle class templates: 38 #if defined(HAVE_STL) || defined(HAVE_STL_VECTOR) 43 #ifdef HAVE_STD_NAMESPACE 44 #define OFVector std::vector 46 #define OFVector vector 51 #define INCLUDE_CASSERT 52 #define INCLUDE_CSTDLIB 53 #include "dcmtk/ofstd/ofstdinc.h" 54 #include "dcmtk/ofstd/oftypes.h" 89 OFVector() : values_(NULL), allocated_(0), size_(0)
100 for (const_iterator it = other.
begin(); it != other.
end(); ++it)
108 explicit OFVector(size_type n,
const T& v = T()) : values_(NULL), allocated_(0), size_(0)
121 OFVector(const_iterator from, const_iterator to) : values_(NULL), allocated_(0), size_(0)
144 for (const_iterator it = other.
begin(); it != other.
end(); ++it)
157 size_type tmp_size =
size_;
165 other.
size_ = tmp_size;
171 iterator
begin() {
return &values_[0]; }
176 const_iterator
begin()
const {
return &values_[0]; }
186 const_iterator
end()
const {
return &values_[
size_]; }
196 OFBool
empty()
const {
return size_ == 0; }
218 size_type idx = it -
begin();
219 for (size_type i = idx + 1; i <
size_; i++) {
220 values_[i - 1] = values_[i];
234 size_type idx = it -
begin();
237 for (size_type i = size_; i > idx; i--) {
238 values_[i] = values_[i - 1];
242 return &values_[idx];
252 template<
class InputIterator>
253 void insert(iterator it, InputIterator from, InputIterator to)
312 const T&
at(size_type i)
const 328 for (
size_t i = size_; i < n; i++)
352 new_values =
new T[n];
355 for (size_type i = 0; i <
size_; i++)
356 new_values[i] = old_values[i];
360 values_ = new_values;
OFVector(size_type n, const T &v=T())
construct an OFVector with predefined content.
size_type size() const
get the size of this OFVector.
size_type size_
the number of valid entries in values_.
const T * const_iterator
the type of constant iterators on this object
const_iterator end() const
get an iterator that points past the last valid object.
size_t size_type
the type used for sizes and indexes
T & operator[](size_type i)
access an entry by index.
OFVector(const OFVector &other)
copy constructor.
iterator end()
get an iterator that points past the last valid object.
T value_type
the type of elements that this OFVector stores
this is a resizable array.
const_iterator begin() const
get an iterator for the first element in this object.
void clear()
clear this OFVector.
T * values_
array that is used for storing the entries in this OFVector
void insert(iterator it, InputIterator from, InputIterator to)
insert a range of elements in this OFVector.
void resize(size_type n, T v=T())
resize this OFVector.
iterator insert(iterator it, const T &v)
insert an entry in this OFVector.
const T & operator[](size_type i) const
access an entry by index.
OFBool empty() const
check wether this OFVector is empty.
void push_back(const T &v)
insert an entry at the end of this object
void pop_back()
remove the last entry in this object
void erase(iterator it)
removes an entry from this OFVector.
OFVector()
default constructor.
const T & at(size_type i) const
access an entry by index.
T * iterator
the type of mutable iterators on this object
T & at(size_type i)
access an entry by index.
OFVector(const_iterator from, const_iterator to)
construct an OFVector from a range of iterators.
OFVector & operator=(const OFVector &other)
assignment operator.
iterator begin()
get an iterator for the first element in this object.
size_type allocated_
the size for which values_ was allocated
void reserve(size_type n)
reserves enough space for the given number of elements.
void swap(OFVector &other)
swap this vector's content with some other vector.