Reputation: 1186
During serializing objects, can we assign name to different objects? So, that on the time of reading objects, i can call any object by its name and later on can access its members.
I can do it by assigning a unique field to each object and later compare it against that field but that will cost - O(n).
Is there any other way to fast access any particular object, serialized in a file of suppose 100 objects.
Thanks you
Upvotes: 1
Views: 78
Reputation: 22514
Maybe it's overkill, but for that use case i would use a database. Something like Berkeley DB sounds appropiate:
http://download.oracle.com/docs/cd/E17277_01/html/GettingStartedGuide/index.html
Upvotes: 0
Reputation: 269687
Why do all of the objects have to be in one stream? What if you just save each object in its own file and access the object by file name? If you really need a single file, you could archive them all in a ZIP file, and let it handle the indexing function for you.
Upvotes: 0