Inserting into a massive name list

I’m hoping to have a list holding previous used names, so that each one can only be used once. This is because once player’s die they will stay dead and need to make a new character. There can be repeat, but they will be named “Dumb Jerk the second”, or whatever, to show that they’re same-named descendent.

Anyhow this list can potentially get huge from all the players making new characters, and I’m having problems thinking of a way to add to the list in a quick manner once it gets big. I tried using a random access file with the names in alphabetical order, in which searching for a existant name is decently quick in large files. However there seems to be no way to write to it without either writing to the end or overwriting something else. The alternative, re-writing the entire file with the new entry is very slow.

Perhaps using mysql would speed things up here? I had problems finding what the runtimes were for inserting and finding stuff in an alphabetically ordered list that was large, and aside from that I don’t really want to use mysql if I don’t have to.

Any ideas on how to handle such a large list [30mb+] for this?

maybe try SQLite (which has a Java port, i think). writing it yourself (a.k.a. reinventing the wheel) probably isn’t going to speed it all up

Yah, but I figured the solution might be something smaller than I was thinking. I’m not comfortable enough with sql yet that I could put it cleanly into my game, I think.

Anyhow, would SQL actually be able to handle that many entries significantly better? 1 million entries takes like 30 seconds worst case with how I was doing it [on my olde computer at least]

You might want to focus on the real problem: getting the game done.

After that, you can worry about scalability a bit.

Huh, that’s a good idea indeed. I get caught up trying to solve the more aesthetic elements and ignore the more major elements perhaps too much :stuck_out_tongue:

Just write some interface, dao, and then a bad slow implementation that still works! You can always replace it with something faster later on.

Although a database would be more appropriate, you could split it up alphabetically. Have 26 files each with names starting with the appropriate letter. Or 626 files that start with the first 2 letters.