Interface


//******************************************************************************
//******************************************************************************
//******************************************************************************
// svector
template <typename T>
svector<T>::svector() : size_(0), array_(0), capacity_(0)
{
}

template <typename T>
svector<T>::~svector()
{
  // Release resources
}

template <typename T>
void svector<T>::push_back(const_reference value)
{
    // Add 'value' to the end
  insert(end(), value);
}

template <typename T>
typename svector<T>::iterator svector<T>::insert(iterator it, const_reference value)
{
    // Find index since iterator will be invalidated after we grow
  difference_type index = it - begin();

    // If the array is full, we need to grow it to accommodate the new element
  if (size_ == capacity_)
    grow();

    // Move all elements to the right of the insertion point over one slot
  for (int i = size_ - 1; i >= index; --i)
    array_[i + 1] = array_[i];

    // Insert the element in the available position
  array_[index] = value;

    // Increment 'size_'
  size_++;

    // Return iterator to newly inserted element
  return begin() + index;
}

template <typename T>
void svector<T>::grow(void)
{
    // Double the capacity
  capacity_ = (capacity_) ? capacity_ * 2 : 1;

    // Create the new array
  T* new_array = new T[capacity_];

    // Copy all elements from old array to new array
  for (size_type i = 0; i < size_; ++i)
    new_array[i] = array_[i];

    // The new size is still the same (didn't add/remove anything)
  int new_size = size_;

    // If we had elements, release them
  if (array_)
  {
    clear(); // ???
    delete [] array_;
  }

    // Set members to new values
  array_ = new_array;
  size_ = new_size;
}

template <typename T>
typename svector<T>::iterator svector<T>::begin(void)
{
}

template <typename T>
typename svector<T>::iterator svector<T>::end(void)
{
}

template <typename T>
void svector<T>::clear(void)
{
  // Remove all elements from container
}

template <typename T>
typename svector<T>::const_iterator svector<T>::begin(void) const
{
}

template <typename T>
typename svector<T>::const_iterator svector<T>::end(void) const
{
}

template <typename T>
typename svector<T>::size_type svector<T>::size(void) const
{
}

//******************************************************************************
//******************************************************************************
//******************************************************************************
// svector_iter
template <typename T>
svector<T>::svector_iter::svector_iter() : elem_ptr_(0)
{
}

template <typename T>
svector<T>::svector_iter::svector_iter(pointer ptr) : elem_ptr_(ptr)
{
}

template <typename T>
typename svector<T>::svector_iter::difference_type svector<T>::svector_iter::operator-(const svector_iter& rhs)
{
}

template <typename T>
typename svector<T>::svector_iter svector<T>::svector_iter::operator+(difference_type rhs)
{
}

template <typename T>
T& svector<T>::svector_iter::operator[](difference_type index)
{
}

//******************************************************************************
//******************************************************************************
//******************************************************************************
// const_svector_iter
template <typename T>
svector<T>::const_svector_iter::const_svector_iter() : elem_ptr_(0)
{
}

template <typename T>
svector<T>::const_svector_iter::const_svector_iter(pointer element) : elem_ptr_(element)
{
}

template <typename T>
const T& svector<T>::const_svector_iter::operator*(void) const
{
}

template <typename T>
typename svector<T>::const_svector_iter& svector<T>::const_svector_iter::operator++(void)
{
}

template <typename T>
bool svector<T>::const_svector_iter::operator!=(const const_svector_iter &rhs) const
{
}