Ver Fonte

Simplify Array.h

taylor001 há 13 anos atrás
pai
commit
e1bf13f87a
1 ficheiros alterados com 33 adições e 19 exclusões
  1. 33 19
      src/core/containers/Array.h

+ 33 - 19
src/core/containers/Array.h

@@ -56,10 +56,14 @@ public:
 	void					Clear();
 	void					Clear();
 
 
 	int						Find(const T& element) const;
 	int						Find(const T& element) const;
-	const T&				GetElement(int index) const;
 
 
 	const Array<T, size>&	operator=(const Array<T, size>& b);
 	const Array<T, size>&	operator=(const Array<T, size>& b);
 
 
+	T*						GetBegin();
+	const T*				GetBegin() const;
+	T*						GetEnd();
+	const T*				GetEnd() const;
+
 private:
 private:
 
 
 	int						mCount;			// The number of elements
 	int						mCount;			// The number of elements
@@ -273,24 +277,6 @@ inline int Array<T, size>::Find(const T& element) const
 	return -1;
 	return -1;
 }
 }
 
 
-/**
-	Random access.
-@note
-	The index has to be smaller than GetSize()
-@param index
-	The index
-@return
-	The element at the given index
-*/
-template <typename T, int size>
-inline const T& Array<T, size>::GetElement(int index) const
-{
-	assert(index >= 0);
-	assert(index < mCount);
-
-	return mArray[index];
-}
-
 /**
 /**
 	Copies the content of the other list into this.
 	Copies the content of the other list into this.
 @return
 @return
@@ -309,3 +295,31 @@ inline const Array<T, size>& Array<T, size>::operator=(const Array<T, size>& b)
 	return *this;
 	return *this;
 }
 }
 
 
+//-----------------------------------------------------------------------------
+template <typename T, int size>
+inline const T* Array<T, size>::GetBegin() const
+{
+	return mArray;
+}
+
+//-----------------------------------------------------------------------------
+template <typename T, int size>
+inline T* Array<T, size>::GetBegin()
+{
+	return mArray;
+}
+
+//-----------------------------------------------------------------------------
+template <typename T, int size>
+inline const T* Array<T, size>::GetEnd() const
+{
+	return mArray + (mCount - 1);
+}
+
+//-----------------------------------------------------------------------------
+template <typename T, int size>
+inline T* Array<T, size>::GetEnd()
+{
+	return mArray + (mCount - 1);
+}
+