protected boolean add ( GraphicalModel m , boolean recordOnDisk ) { boolean success = super . add ( m ) ; if ( ! success ) return false ; if ( recordOnDisk ) { try { if ( writeWithFactors ) { // Attempt to record this to the backing log file, with the factors writeExample ( m ) ; } else { // Attempt to record this to the backing log file, without the factors Set < GraphicalModel . Factor > cachedFactors = m . factors ; m . factors = new HashSet <> ( ) ; writeExample ( m ) ; m . factors = cachedFactors ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } return true ; }
Adds an element to the list and if recordOnDisk is true appends it to the backing store .