Changeset

922:0e45234360cd

util.array: Add :reverse() method
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Mar 2009 13:50:59 +0100
parents 921:f97d37a7d8a6
children 923:c63f9bc45a85 940:776cb8c847c5
files util/array.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/array.lua	Sun Mar 29 02:14:32 2009 +0100
+++ b/util/array.lua	Sun Mar 29 13:50:59 2009 +0100
@@ -44,4 +44,12 @@
 	end
 end
 
+function array:reverse()
+	local len = #self-1;
+	for i=len,1,-1 do
+		self:push(self[i]);
+		self:pop(i);
+	end
+end
+
 _G.array = array