public ZipFileData addLast ( ZipFileData newLastData , int maximumSize ) { String newLastPath = newLastData . path ; Cell dupCell = cells . get ( newLastPath ) ; if ( dupCell != null ) { throw new IllegalArgumentException ( "Path [ " + newLastPath + " ] is already stored" ) ; } int size = size ( ) ; if ( ( maximumSize == - 1 ) || ( size < maximumSize ) ) { @ SuppressWarnings ( "unused" ) ZipFileData oldLastData = addLast ( newLastData ) ; return null ; } Cell oldFirstCell = anchor . next ; ZipFileData oldFirstData = oldFirstCell . data ; String oldFirstPath = oldFirstData . path ; if ( oldFirstCell != cells . remove ( oldFirstPath ) ) { throw new IllegalStateException ( "Bad cell alignment on path [ " + oldFirstPath + " ]" ) ; } oldFirstCell . data = newLastData ; cells . put ( newLastPath , oldFirstCell ) ; if ( size != 1 ) { oldFirstCell . excise ( ) ; oldFirstCell . putBetween ( anchor . prev , anchor ) ; } return oldFirstData ; }
Add data as the last data of the store . If the addition pushes a cell out of the list answer the data of the cell which was removed .