--- a/sources/list.h Sat Jan 09 02:35:00 2016 +0200 +++ b/sources/list.h Sat Jan 09 17:41:21 2016 +0200 @@ -32,10 +32,11 @@ #include "basics.h" #include <algorithm> #include <deque> -#include <initializer_list> #include <functional> #include <cassert> +#include <vector> #include "range.h" +BEGIN_ZFC_NAMESPACE // ------------------------------------------------------------------------------------------------- // @@ -43,11 +44,11 @@ class Container { public: - using Iterator = typename C::iterator; - using ConstIterator = typename C::const_iterator; - using ReverseIterator = typename C::reverse_iterator; - using ConstReverseIterator = typename C::const_reverse_iterator; - using Self = Container<T, C>; + typedef typename C::iterator Iterator; + typedef typename C::const_iterator ConstIterator; + typedef typename C::reverse_iterator ReverseIterator; + typedef typename C::const_reverse_iterator ConstReverseIterator; + typedef Container<T, C> Self; Container(){} @@ -57,9 +58,6 @@ Container (const C& other) : m_container (other) {} - Container (std::initializer_list<T>&& a) : - m_container (a) {} - T& append (const T& value) { m_container.push_back (value); @@ -73,7 +71,7 @@ ConstIterator begin() const { - return m_container.cbegin(); + return m_container.begin(); } void clear() @@ -83,17 +81,17 @@ bool contains (const T& a) const { - return std::find (m_container.cbegin(), m_container.cend(), a) != m_container.end(); + return std::find (m_container.begin(), m_container.end(), a) != m_container.end(); } ConstReverseIterator crbegin() const { - return m_container.crbegin(); + return m_container.rbegin(); } ConstReverseIterator crend() const { - return m_container.crbegin(); + return m_container.rend(); } const C& container() const @@ -108,7 +106,7 @@ ConstIterator end() const { - return m_container.cend(); + return m_container.end(); } Iterator find (const T& needle) @@ -123,15 +121,15 @@ ConstIterator find (const T& needle) const { - auto it = std::find (m_container.cbegin(), m_container.cend(), needle); + auto it = std::find (m_container.begin(), m_container.end(), needle); - if (it == m_container.cend()) + if (it == m_container.end()) return end(); return it; } - Iterator find (Function<bool (T const&)> func) + Iterator find (bool (*func)(T const&)) { for (Iterator it = begin(); it != end(); ++it) { @@ -142,7 +140,7 @@ return end(); } - ConstIterator find (Function<bool (T const&)> func) const + ConstIterator find (bool (*func)(T const&)) const { for (ConstIterator it = begin(); it != end(); ++it) { @@ -329,17 +327,28 @@ // template<typename T> -using List = Container<T, std::deque<T>>; +class List : public Container<T, std::deque<T> > +{ +public: + typedef Container<T, std::deque<T> > Super; + + List(){} + + List (int numvalues) : + Super (numvalues) {} + + List (const Super& other) : + Super (other) {} +}; // ------------------------------------------------------------------------------------------------- // template<typename T> -class Vector : public Container<T, std::vector<T>> +class Vector : public Container<T, std::vector<T> > { public: - using Super = Container<T, std::vector<T>>; - using typename Super::Container; + typedef Container<T, std::vector<T> > Super; Vector(){} @@ -361,3 +370,5 @@ return data(); } }; + +END_ZFC_NAMESPACE