shuffling lines in a stream

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 10 15:27:38 PDT 2008


BCS wrote:
> Reply to Andrei,
> 
> 
>> Well I agree things can be coded such that you make the copy only if
>> the file is too large anyway. But one lseek call per line is a
>> complete disaster, whether you call it I/O effect or whatnot. I'd go
>> as far as saying I'd never even try such a solution, especially since
>> there exists a forward-pass algorithm. Of course measuring would be a
>> great way to prove me wrong.
>>
>> Andrei
>>
> 
> I think Big-O on mine is n.

I disagree. Big-O with lseek under the rug? That's a non-solution 
because it essentially redefines the problem into "if I had a 
random-access operator then this is pretty much like array shuffling". 
If you have a random-access operator there is no problem to think about.

Andrei



More information about the Digitalmars-d mailing list