code: private void writeObject(final ObjectOutputStream out) throws IOException {
          out.defaultWriteObject();
          out.writeInt(size());
          for (final E e : this) {
              out.writeObject(e);
          }
      }
docs: Write the queue out using a custom routine.
  
  @param out  the output stream
  @throws IOException if an I/O error occurs while writing to the output stream