public synchronized int add ( E object ) { if ( object == null ) throw new NullPointerException ( "FastList add called with null" ) ; if ( ( count + 1 ) >= maxCount ) resize ( capacity * 2 ) ; int initialAddIndex = addIndex ; // find right spot to add to - start with addIndex and look // for first open spot. give up if we get back to initialAddIndex while ( listElements [ addIndex ] != null ) { addIndex ++ ; if ( addIndex == capacity ) addIndex = 0 ; if ( addIndex == initialAddIndex ) { // should not happen - we should have resized if we needed more // capacity throw new RuntimeException ( "FastList out of space" ) ; } } count ++ ; listElements [ addIndex ] = object ; return addIndex ; }
Adds specified object to the list and increments size