ArrayList.as

Go to the documentation of this file.
00001 import gugga.collections.IIterable;
00002 import gugga.collections.IIterator; 
00003 import gugga.collections.ArrayListIterator;
00007 class gugga.collections.ArrayList extends Array implements IIterable
00008 {
00009         public function addItem(aValue):Void
00010         {
00011                 this.push(aValue);
00012         }
00013 
00014         public function addAll(aArray:Array):Void
00015         {
00016                 for(var i:Number = 0; i < aArray.length; i++)
00017                 {
00018                         addItem(aArray[i]);
00019                 }
00020         }
00021         
00022         public function removeItem(aValue):Void
00023         {
00024                 var itemIndex:Number = indexOf(aValue);
00025                 if(itemIndex != -1)
00026                 {
00027                         this.splice(itemIndex, 1);
00028                 }
00029         }
00030         
00031         public function removeAt(aIndex:Number) : Object
00032         {
00033                 var result : Object = null;
00034                 if (0 <= aIndex && aIndex < this.length)
00035                 {
00036                         result = this[aIndex];
00037                         this.splice(aIndex, 1);
00038                 }
00039                 
00040                 return result;
00041         }
00042         
00043         public function containsItem(aValue):Boolean
00044         {
00045                 var itemIndex:Number = indexOf(aValue);
00046                 
00047                 if(itemIndex == -1)
00048                 {
00049                         return false;
00050                 }
00051                 
00052                 return true;
00053         }
00054         
00055         public function indexOf(aValue):Number
00056         {
00057                 var result:Number = -1;
00058                 for(var i:Number = 0; i < this.length; i++)  
00059                 {
00060                         if(this[i] == aValue)
00061                         {
00062                                 result = i;
00063                                 break;
00064                         }
00065                 }
00066                 return result;
00067         }
00068         
00069         public function isEmpty(aValue):Boolean
00070         {
00071                 if(this.length <= 0)
00072                 {
00073                         return true;
00074                 }
00075                 else
00076                 {
00077                         return false;
00078                 }
00079         }
00080         
00081         public function getItem(aIndex:Number)
00082         {
00083                 return this[aIndex];
00084         }
00085         
00086         public function clone() : ArrayList
00087         {
00088                 var result : ArrayList = new ArrayList();
00089                 result.addAll(this);
00090                 return result;
00091         }
00092         
00101         public function getIterator() : IIterator
00102         {
00103                 var iterator : IIterator = new ArrayListIterator(this.clone());
00104                 return iterator;
00105         }       
00106 }

Generated on Fri May 11 17:12:42 2007 for GuggaFramework by  doxygen 1.5.2