c++ - Adding items to a sorted list of numbers inside a file without splitting it -


i'm searching best way accomplish what's specified in title. let's have file ( let's make text file sake of simplicity ) list of pre sorted numbers, such

    0 2 3 4 4 6 12 13 14 16 16 16 17 18 ... 

i want insert new number in list, let's 5, without loading memory , perform sorting on every item in file again ( example, in case have huge amount of data , loading memory not doable ) , without splitting file "lower bound" , "upper bound" parts ( temporary files ) rejoin them number in middle. there way insert in given position of file , making offset on "shift" appropriate number of bytes ?

solutions both standard functions such (f)open, (f)write, etc , windows specific apis ( memory mapped files ) welcomed.

realistically

based on how filesystems , operating systems implemented, i'd solution question posed impossible.

may suggest need sql database...

aside

if talking sorted binary records size of record matched size of sector on disk, might theoretically possible avoid rewriting data on disk other file meta-data if had hypothetical filesystem let insert 'sectors' middle of file.

in theory, anyway, if such strange file system existed (scroll down 'rel' file type -- never thought i'd thinking again!) ...


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -