sources/list.h

changeset 5
146825d63b9a
parent 1
4dd5bde4e777
child 11
cffa2777d917
--- a/sources/list.h	Wed Dec 10 19:26:13 2014 +0200
+++ b/sources/list.h	Thu Dec 11 05:58:55 2014 +0200
@@ -37,10 +37,8 @@
 #include <cassert>
 #include "range.h"
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 class Container
 {
@@ -141,114 +139,90 @@
 template<typename T, typename C>
 Container<T, C>::Container() {}
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 Container<T, C>::Container (const C& other) :
 	m_container (other) {}
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 Container<T, C>::Container (std::initializer_list<T> && a) :
 	m_container (a) {}
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 Container<T, C>::Container (int numvalues) :
 	m_container (numvalues) {}
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::begin() -> Iterator
 {
 	return m_container.begin();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::begin() const -> ConstIterator
 {
 	return m_container.cbegin();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::end() -> Iterator
 {
 	return m_container.end();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::end() const -> ConstIterator
 {
 	return m_container.cend();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::rbegin() -> ReverseIterator
 {
 	return m_container.rbegin();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::crbegin() const -> ConstReverseIterator
 {
 	return m_container.crbegin();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::rend() -> ReverseIterator
 {
 	return m_container.rend();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::crend() const -> ConstReverseIterator
 {
 	return m_container.crend();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::remove_at (int pos) -> void
 {
@@ -256,10 +230,8 @@
 	m_container.erase (m_container.begin() + pos);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::prepend (const T& value) -> T&
 {
@@ -267,10 +239,8 @@
 	return m_container[0];
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::append (const T& value) -> T&
 {
@@ -278,10 +248,8 @@
 	return m_container[m_container.size() - 1];
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::merge (const Self& other) -> void
 {
@@ -290,10 +258,8 @@
 	std::copy (other.begin(), other.end(), begin() + oldsize);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::pop (T& val) -> bool
 {
@@ -305,10 +271,8 @@
 	return true;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator<< (const T& value) -> Self&
 {
@@ -316,10 +280,8 @@
 	return *this;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator<< (const Self& vals) -> Self&
 {
@@ -327,10 +289,8 @@
 	return *this;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::reverse() const -> Self
 {
@@ -339,30 +299,24 @@
 	return rev;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::clear() -> void
 {
 	m_container.clear();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::insert (int pos, const T& value) -> void
 {
 	m_container.insert (m_container.begin() + pos, value);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::remove_duplicates() -> void
 {
@@ -370,20 +324,16 @@
 	resize (std::distance (begin(), std::unique (begin(), end())));
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::size() const -> int
 {
 	return m_container.size();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator[] (int n) -> T&
 {
@@ -391,10 +341,8 @@
 	return m_container[n];
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator[] (int n) const -> const T&
 {
@@ -402,40 +350,32 @@
 	return m_container[n];
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator[] (const Range<int>& n) const -> Self
 {
 	return splice (n);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::resize (int size) -> void
 {
 	m_container.resize (size);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::sort() -> void
 {
 	std::sort (begin(), end());
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::find (const T& needle) -> Iterator
 {
@@ -447,10 +387,8 @@
 	return it;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::find (const T& needle) const -> ConstIterator
 {
@@ -462,10 +400,8 @@
 	return it;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::find (Function<bool (T const&)> func) -> Iterator
 {
@@ -478,10 +414,8 @@
 	return end();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::find (Function<bool (T const&)> func) const -> ConstIterator
 {
@@ -494,10 +428,8 @@
 	return end();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::remove_one (const T& a) -> void
 {
@@ -507,20 +439,16 @@
 		m_container.erase (it);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::is_empty() const -> bool
 {
 	return size() == 0;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::splice (int a, int b) const -> Self
 {
@@ -535,60 +463,48 @@
 	return result;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::splice (const Range<int>& a) const -> Self
 {
 	return splice (a.min(), a.max());
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::container() const -> const C&
 {
 	return m_container;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::first() const -> const T&
 {
 	return *m_container.cbegin();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::last() const -> const T&
 {
 	return *(m_container.cend() - 1);
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::contains (const T& a) const -> bool
 {
 	return std::find (m_container.cbegin(), m_container.cend(), a) != m_container.end();
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto Container<T, C>::operator+ (const Self& other) const -> Self
 {
@@ -597,10 +513,8 @@
 	return out;
 }
 
-//
 // -------------------------------------------------------------------------------------------------
 //
-
 template<typename T, typename C>
 auto operator>> (const T& value, Container<T, C>& haystack) -> Container<T, C>&
 {

mercurial