'Inserts input record at given index.
Example usage:
>>> for i in range(5):
...     record.write_idx(i, \'record_%d\'%i)
>>> record.close()
Parameters
idx : int
Index of a file.
buf :
Record to write.'

def write_idx(self, idx, buf):

    key = self.key_type(idx)
    pos = self.tell()
    self.write(buf)
    self.fidx.write(('%s DCTB %d\n' % (str(key), pos)))
    self.idx[key] = pos
    self.keys.append(key)
