src/types.h

changeset 503
bebe09014dd6
parent 500
cad8cdc42a64
child 504
6a1fa662bfc1
--- a/src/types.h	Wed Oct 16 16:05:51 2013 +0300
+++ b/src/types.h	Wed Oct 16 16:40:42 2013 +0300
@@ -46,6 +46,7 @@
 typedef quint32 uint32;
 typedef quint64 uint64;
 
+template<class T> using List = QList<T>;
 template<class T> using initlist = std::initializer_list<T>;
 template<class T, class R> using pair = std::pair<T, R>;
 using std::size_t;
@@ -165,197 +166,6 @@
 };
 
 // =============================================================================
-// -----------------------------------------------------------------------------
-class Line
-{	public:
-		Line() {}
-		Line (const vertex& v0, const vertex v1) :
-			m_v0 (v0),
-			m_v1 (v1) {}
-
-		inline const vertex& getVertex (int i) const
-		{	assert (i == 0 || i == 1);
-			return (i == 0) ? m_v0 : m_v1;
-		}
-
-		inline void setVertex (int i, const vertex& a)
-		{	assert (i == 0 || i == 1);
-			(i == 0) ? m_v0 : m_v1 = a;
-		}
-
-		inline const vertex& v0() const
-		{	return m_v0;
-		}
-
-		inline const vertex& v1() const
-		{	return m_v1;
-		}
-
-		inline void setV0 (const vertex& a)
-		{	m_v0 = a;
-		}
-
-		inline void setV1 (const vertex& a)
-		{	m_v1 = a;
-		}
-
-	private:
-		vertex m_v0,
-		       m_v1;
-};
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
-// List
-//
-// Array class that wraps around std::deque
-// =============================================================================
-template<class T> class List
-{	public:
-		typedef typename std::deque<T>::iterator Iterator;
-		typedef typename std::deque<T>::const_iterator ConstIterator;
-		typedef typename std::deque<T>::reverse_iterator ReverseIterator;
-		typedef typename std::deque<T>::const_reverse_iterator ConstReverseIterator;
-
-		List() {}
-		List (initlist<T> vals)
-		{	m_vect = vals;
-		}
-
-		inline Iterator begin()
-		{	return m_vect.begin();
-		}
-
-		inline ConstIterator begin() const
-		{	return m_vect.cbegin();
-		}
-
-		inline Iterator end()
-		{	return m_vect.end();
-		}
-
-		inline ConstIterator end() const
-		{	return m_vect.cend();
-		}
-
-		inline ReverseIterator rbegin()
-		{	return m_vect.rbegin();
-		}
-
-		inline ConstReverseIterator crbegin() const
-		{	return m_vect.crbegin();
-		}
-
-		inline ReverseIterator rend()
-		{	return m_vect.rend();
-		}
-
-		inline ConstReverseIterator crend() const
-		{	return m_vect.crend();
-		}
-
-		void erase (int pos)
-		{	assert (pos < size());
-			m_vect.erase (m_vect.begin() + pos);
-		}
-
-		T& push_back (const T& value)
-		{	m_vect.push_back (value);
-			return m_vect[m_vect.size() - 1];
-		}
-
-		void push_back (const List<T>& vals)
-		{	for (const T& val : vals)
-				push_back (val);
-		}
-
-		bool pop (T& val)
-		{	if (size() == 0)
-				return false;
-
-			val = m_vect[size() - 1];
-			erase (size() - 1);
-			return true;
-		}
-
-		T& operator<< (const T& value)
-		{	return push_back (value);
-		}
-
-		void operator<< (const List<T>& vals)
-		{	push_back (vals);
-		}
-
-		bool operator>> (T& value)
-		{	return pop (value);
-		}
-
-		List<T> reverse() const
-		{	List<T> rev;
-
-			for (auto it = end() - 1; it != begin(); --it)
-				rev << *it;
-
-			return rev;
-		}
-
-		void clear()
-		{	m_vect.clear();
-		}
-
-		void insert (int pos, const T& value)
-		{	m_vect.insert (m_vect.begin() + pos, value);
-		}
-
-		void makeUnique()
-		{	// Remove duplicate entries. For this to be effective, the List must be
-			// sorted first.
-			sort();
-			Iterator pos = std::unique (begin(), end());
-			resize (std::distance (begin(), pos));
-		}
-
-		int size() const
-		{	return m_vect.size();
-		}
-
-		T& operator[] (int n)
-		{	assert (n < size());
-			return m_vect[n];
-		}
-
-		const T& operator[] (int n) const
-		{	assert (n < size());
-			return m_vect[n];
-		}
-
-		void resize (std::ptrdiff_t size)
-		{	m_vect.resize (size);
-		}
-
-		void sort()
-		{	std::sort (begin(), end());
-		}
-
-		int find (const T& needle)
-		{	int i = 0;
-
-			for (const T & hay : *this)
-			{	if (hay == needle)
-					return i;
-
-				i++;
-			}
-
-			return -1;
-		}
-
-	private:
-		std::deque<T> m_vect;
-};
-
-// =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 // StringFormatArg

mercurial