#ifndef CONTAINERS_H #define CONTAINERS_H namespace std { template class iterator { public: iterator() {} iterator(const iterator &iter) : ptr(iter.ptr) {} typedef T value_type; typedef T *pointer; typedef T &reference; reference operator*() const { return *ptr; } pointer operator->() const { return ptr; } iterator &operator++() { ++ptr; return *this; } iterator &operator--() { --ptr; return *this; } iterator operator++(int) { iterator res(*this); ++ptr; return res; } iterator operator--(int) { iterator res(*this); --ptr; return res; } bool operator!=(const iterator &iter) const { return ptr != iter.operator->(); } private: T *ptr; }; template class const_iterator { public: const_iterator() {} const_iterator(const Iterator &iter) : iter(iter) {} const_iterator(const const_iterator &citer) : iter(citer.iter) {} typedef const typename Iterator::value_type value_type; typedef const typename Iterator::pointer pointer; typedef const typename Iterator::reference reference; reference operator*() const { return *iter; } pointer operator->() const { return iter.operator->(); } const_iterator &operator++() { return ++iter; } const_iterator &operator--() { return --iter; } const_iterator operator++(int) { return iter--; } const_iterator operator--(int) { return iter--; } bool operator!=(const Iterator &it) const { return iter->operator->() != it.operator->(); } bool operator!=(const const_iterator &it) const { return iter.operator->() != it.operator->(); } private: Iterator iter; }; template class forward_iterable { public: forward_iterable() {} typedef Iterator iterator; typedef const_iterator const_iterator; iterator begin() { return _begin; } iterator end() { return _end; } const_iterator begin() const { return _begin; } const_iterator end() const { return _end; } const_iterator cbegin() const { return _begin; } const_iterator cend() const { return _end; } private: iterator _begin, _end; }; template class reverse_iterator { public: reverse_iterator() {} reverse_iterator(const Iterator &iter) : iter(iter) {} reverse_iterator(const reverse_iterator &rit) : iter(rit.iter) {} typedef typename Iterator::value_type value_type; typedef typename Iterator::pointer pointer; typedef typename Iterator::reference reference; reference operator*() { return *iter; } pointer operator->() { return iter.operator->(); } reverse_iterator &operator++() { return --iter; } reverse_iterator &operator--() { return ++iter; } reverse_iterator operator++(int) { return iter--; } reverse_iterator operator--(int) { return iter++; } private: Iterator iter; }; template class backward_iterable { public: backward_iterable() {} typedef reverse_iterator reverse_iterator; typedef const_iterator const_reverse_iterator; reverse_iterator rbegin() { return _rbegin; } reverse_iterator rend() { return _rend; } const_reverse_iterator rbegin() const { return _rbegin; } const_reverse_iterator rend() const { return _rend; } const_reverse_iterator crbegin() const { return _rbegin; } const_reverse_iterator crend() const { return _rend; } private: reverse_iterator _rbegin, _rend; }; template class bidirectional_iterable : public forward_iterable, public backward_iterable {}; template struct pair { pair(A f, B s) : first(f), second(s) {} A first; B second; }; class string { public: string() {} string(const char *) {} }; template class array : public backward_iterable> { public: array() {} typedef T *iterator; typedef const T *const_iterator; iterator begin() { return &v[0]; } iterator end() { return &v[n - 1]; } const_iterator begin() const { return &v[0]; } const_iterator end() const { return &v[n - 1]; } const_iterator cbegin() const { return &v[0]; } const_iterator cend() const { return &v[n - 1]; } private: T v[n]; }; template class deque : public bidirectional_iterable> { public: deque() {} }; template class list : public bidirectional_iterable> { public: list() {} }; template class forward_list : public forward_iterable> { public: forward_list() {} }; template class vector : public bidirectional_iterable> { public: vector() {} }; template class set : public bidirectional_iterable> { public: set() {} }; template class multiset : public bidirectional_iterable> { public: multiset() {} }; template class map : public bidirectional_iterable>> { public: map() {} iterator> find(const key &) {} const_iterator>> find(const key &) const {} }; template class multimap : public bidirectional_iterable>> { public: multimap() {} }; template class unordered_set : public forward_iterable> { public: unordered_set() {} }; template class unordered_multiset : public forward_iterable> { public: unordered_multiset() {} }; template class unordered_map : public forward_iterable>> { public: unordered_map() {} }; template class unordered_multimap : public forward_iterable>> { public: unordered_multimap() {} }; } // namespace std #endif // CONTAINERS_H