class BinaryTreeMap implements Binarylizable, Serializable {
    /** */
    private static final long serialVersionUID = 0L;

    /** Original map. */
    private TreeMap map;

    /**
     * Default constructor.
     */
    public BinaryTreeMap() {
        // No-op.
    }

    /**
     * Constructor.
     *
     * @param map Original map.
     */
    public BinaryTreeMap(TreeMap map) {
        this.map = map;
    }

    /** {@inheritDoc} */
    @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
        BinaryRawReader rawReader = reader.rawReader();

        Comparator comp = rawReader.readObject();

        map = comp == null ? new TreeMap() : new TreeMap(comp);

        int size = rawReader.readInt();

        for (int i = 0; i < size; i++)
            map.put(rawReader.readObject(), rawReader.readObject());
    }

    /**
     * Reconstructs object on unmarshalling.
     *
     * @return Reconstructed object.
     * @throws ObjectStreamException Thrown in case of unmarshalling error.
     */
    protected Object readResolve() throws ObjectStreamException {
        return map;
    }
}

        BinaryRawWriter rawWriter = writer.rawWriter();

        rawWriter.writeObject(map.comparator());

        int size = map.size();

        rawWriter.writeInt(size);

        for (Map.Entry<Object, Object> entry : ((TreeMap<Object, Object>)map).entrySet()) {
            rawWriter.writeObject(entry.getKey());
            rawWriter.writeObject(entry.getValue());
        }
    
<no_super_class>