Jesus Christ people downvotes this? You guys are so damn harsh. Maybe have a fucking conversation?
How many lines typically are in a basic text editor! Even windows notepad chokes in large files.
If you for example use it for a programming scratchpad well the longest since file I ever had was maybe 8000 lines long. And say 80 characters wide. They ain't shit for memory. You could literally just make a whole new array each time without problems. Not even something to worry about in modern computers
I get some of you guys are data structure nerds and I never said it wasn't worth using them. I just said you probably could get away with not even bothering to do so anymore, unless you are planning on working on some giant manuscripts. And for just text O(n) is plenty fast
Fucking premature optimizers the lot of ya
Even my solution is faster than O(n) if you resize the array in place (or even just allocate a big ass chunk of ram ahead of time why not) you only have to move the characters after the insert to make room!
The longest files I have during programming are million-line log files. Open that, do one edit command, and watch the computer churn a little too long.
-56
u/MetalSlug20 Dec 15 '19 edited Dec 15 '19
Jesus Christ people downvotes this? You guys are so damn harsh. Maybe have a fucking conversation?
How many lines typically are in a basic text editor! Even windows notepad chokes in large files.
If you for example use it for a programming scratchpad well the longest since file I ever had was maybe 8000 lines long. And say 80 characters wide. They ain't shit for memory. You could literally just make a whole new array each time without problems. Not even something to worry about in modern computers
I get some of you guys are data structure nerds and I never said it wasn't worth using them. I just said you probably could get away with not even bothering to do so anymore, unless you are planning on working on some giant manuscripts. And for just text O(n) is plenty fast
Fucking premature optimizers the lot of ya
Even my solution is faster than O(n) if you resize the array in place (or even just allocate a big ass chunk of ram ahead of time why not) you only have to move the characters after the insert to make room!