#ifndef TINYSTL_ALGORITHM
#define TINYSTL_ALGORITHM

namespace std {
	
  // for_each
  
  // count
  // count_if
  // min_element
  // max_element
  // find_if
  // search_n
  // search
  // find_end
  // find_first_of
  // adjancent_find
  // equal
  // mismatch
  // lixicographical_compare

  template<typename InputIterator, typename OutputIterator>
  inline OutputIterator copy(InputIterator sourceBeg, InputIterator sourceEnd,
			     OutputIterator destBeg)
  {
    while (sourceBeg != sourceEnd) {
      *destBeg++ = *sourceBeg++;
    }
    return destBeg;
  }

  template<typename BidirectionalIterator1, typename BidirectionalIterator2>
  inline BidirectionalIterator2
  copy_backward(BidirectionalIterator1 sourceBeg,
		BidirectionalIterator1 sourceEnd,
		BidirectionalIterator2 destEnd)
  {
    while (sourceBeg != sourceEnd) {
      *destEnd-- = *sourceEnd--;
    }
    return destEnd;
  }


  template<typename T>
  inline void swap(T& a, T& b)
  {
    const T tmp = a;
    a = b;
    b = tmp;
  }

  template<typename InputIterator, typename T>
  InputIterator find (InputIterator first, InputIterator last, const T& val)
  {
    while (first != last && !(*first == val))
      ++first;
    return first;
  }

  template<typename InputIterator, typename OutputIterator, class Op>
  void transform (InputIterator first, InputIterator last, OutputIterator result, Op op)
  {
    while (first != last) {
      *result++ = op (*first++);
    }
  }
  

}

#endif
