def to_file( Class, dict, file, is_little_endian=True ):
        io = BinaryFileWriter( file, is_little_endian=is_little_endian )
        start_offset = io.tell()
        io.seek( start_offset + ( 8 * 256 ) )
        subtables = [ [] for i in range(256) ]
        for key, value in dict.items():
            pair_offset = io.tell()
            io.write_uint32( len( key ) )
            io.write_uint32( len( value ) )
            io.write( key )
            io.write( value )
            hash = cdbhash( key )
            subtables[ hash % 256 ].append( ( hash, pair_offset ) )
        subtable_offset = io.tell()
        for subtable in subtables:
            if len( subtable ) > 0:
                ncells = len( subtable ) * 2
                cells = [ (0,0) for i in range( ncells ) ]
                for hash, pair_offset in subtable:
                    index = ( hash >> 8 ) % ncells
                    while cells[index][1] != 0:
                        index = ( index + 1 ) % ncells
                    cells[index] = ( hash, pair_offset )
                for hash, pair_offset in cells:
                    io.write_uint32( hash )
                    io.write_uint32( pair_offset )
        end_offset = io.tell()
        io.seek( start_offset )
        index = subtable_offset
        for subtable in subtables:
            io.write_uint32( index )
            io.write_uint32( len( subtable * 2 ) )
            index += ( len( subtable ) * 2 ) * 8
        io.seek( end_offset )