From: Scott H. <sco...@us...> - 2005-07-27 00:32:10
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25913/src/org/actionstep Modified Files: NSArray.as Log Message: Added some comments Added + (NSArray) initWithCapacity Index: NSArray.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSArray.as,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** NSArray.as 29 Jun 2005 02:19:00 -0000 1.15 --- NSArray.as 27 Jul 2005 00:32:00 -0000 1.16 *************** *** 42,45 **** --- 42,47 ---- * Represents an array of objects. * + * This class is a combination of both NSArray and NSMutableArray classes. + * * @author Scott Hyndman */ *************** *** 756,759 **** --- 758,790 ---- /** + * Creates and returns an NSArray with a capacity of numItems. + * + * Since the Cocoa docs say that numItems is an unsigned int, and + * we don't have any equivalent in ActionScript, this method + * will throw an exception if numItems is negative. + */ + public static function arrayWithCapacity(numItems:Number):NSArray + { + // + // Throw an exception if out of range. + // + if (numItems < 0) + { + var e:NSException = NSException.exceptionWithNameReasonUserInfo( + "NSInvalidArgumentException", + "numItems cannot be negative.", + null); + TRACE(e); + throw e; + } + + var ret:NSArray = new NSArray(); + ret.m_list = new Array(numItems); + + return ret; + } + + + /** * Creates and returns an array containing the single element anObject. * |