template<class T>
ostream& WriteVector(ostream& os, T& v)
{
	typename T::size_type i;
	
	os << v.size();

	for(i = 0; i < v.size(); i++) os << v[i];

	return os;
}

template<class T>
istream& ReadVector(istream& is, T& v)
{
	typename T::size_type size;
	typename T::size_type i;

	//remove all existing records
	v.clear();
	
	//read in the size of the database
	is >> size;
	v.resize(size);


	for(i=0; i < size; i++) is >> v[i];

	return is;
}

template<class T>
ostream& WriteList(ostream& os, T& v)
{
  typename T::iterator i;
  int count = v.size();

  os << count;

  for(i = v.begin(); i != v.end() && count > 0; i++, count--)
    {
      os << *i;
    }

  return os;
}

template<class T>
istream& ReadList(istream& is, T& v)
{
  int count;
  typename T::value_type item;

  is >> count;

  v.clear();

  for(; count > 0; count--)
    { 
      is >> item;
      v.push_back(item);
    }
      
  return is;
}
