public void growAccessList ( int iTargetPosition ) { int iArrayIndex ; if ( m_aRecords == null ) { m_aRecords = new Object [ MAX_RECORD_ARRAY_SIZE ] ; m_iRecordListStep = 1 ; m_iRecordListMax = MAX_RECORD_ARRAY_SIZE ; // Last + 1 } else { // First, free the odd items for ( iArrayIndex = 1 ; iArrayIndex < MAX_RECORD_ARRAY_SIZE ; iArrayIndex += 2 ) { // Free the objects that are no longer used this . freeElement ( m_aRecords [ iArrayIndex ] ) ; m_aRecords [ iArrayIndex ] = null ; } // Next, compact the even ones to the first half of the array int nSourceIndex , nDestIndex ; for ( nSourceIndex = 2 , nDestIndex = 1 ; nSourceIndex < MAX_RECORD_ARRAY_SIZE ; nSourceIndex += 2 , nDestIndex ++ ) { Object bookmark = m_aRecords [ nSourceIndex ] ; m_aRecords [ nDestIndex ] = bookmark ; m_aRecords [ nSourceIndex ] = null ; } // Now, reduce the size of the array and increase the step m_iRecordListMax = m_iRecordListMax * 2 ; m_iRecordListStep = m_iRecordListStep * 2 ; // Grow the array by elimating the odd records } if ( iTargetPosition >= m_iRecordListMax ) this . growAccessList ( iTargetPosition ) ; // Still not big enough, do it again }
Increase the granularity of the access list .