code: private void writeEntry(HashtableEntry entry)
  
      throws IOException, EOFException, FileManagerException, ClassNotFoundException {
  
          long index = getHtindex(entry.index, entry.tableid);
          if (index == 0) { // first one in this bucket
              updateEntry(entry); // write to disk
              writeHashIndex(entry.index, entry.location, entry.tableid); // update index
          } else if (index == entry.location) { // replacing first entry
              updateEntry(entry);
              writeHashIndex(entry.index, entry.location, entry.tableid); // update index
          } else { // 
              //
              // If the entry has a "previous" pointer, then it was read earlier
              // from disk.  Otherwise, it is a brand new entry.  If it is a brand
              // entry, we write it to disk and chain at the front of the bucket.
              // If "previous" is not zero, we check to see if reallocation is
              // needed (location == 0).  If not, we simply update on disk and we're
              // done.  If reallocation is needed we update on disk to do the allocation
              // and call updatePointer to chain into the bucket.
              //
              if (entry.previous == 0) {
                  entry.next = index;
                  updateEntry(entry);
                  writeHashIndex(entry.index, entry.location, entry.tableid); // update index
              } else {
                  if (entry.location == 0) { // allocation needed?
                      updateEntry(entry); // do allocation
                      updatePointer(entry.previous, entry.location); // chain in
                  } else {
                      updateEntry(entry); // no allocation, just update fields
                  }
              }
          }
  
      }
docs: ************************************************************************
  Common code to insert an entry into the hashtable.
  ***********************************************************************