Re: help on Indexing contents in file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Nash" <jeevs007@xxxxxxxxx> ha scritto nel messaggio
news:1192006852.776581.12020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Thanx for your reply.

You're welcome.

What i was thinking is the format of the file
can be changed to something like this

Category A
2(No of items)
item A1 0
item A3 0

Category B
1(No of items)
item B2 0

so that we can save some memory and also we can directly go to
category insted of parsing all the results.

I think it is a good idea.
Maybe the management is a bit more complicated than the "flat" approach I
suggested in my previous post, because here you are introducing a hierarchy,
so you need also to mantain a new state about the category you are currently
processing.

Frankly speaking, if you want to give some hierarchical organization to your
data, and not just use "flat" data, I would start considering XML...
Using an XML parser for read/write your *hierarchical* data could be easier
than developing a custom binary format and code to process it (it all
depends also from your programming skills, and the level of optimization you
want to achieve...).

You may consider using XML (and an already built XML parser), and then if
you don't like the performances, you may switch to a custom binary format.

While displaying category A items(it may have 10 items for eg) in list
i need to take each item and compare against all the items under
category A to determine the ranking and also while assigning a rank i
need to loop through all the items to find whether it is already rated
if not add a new entry else update the existing one. So what could be
the better aproach for doing that?

If you have these needs of grouping items, you may define a class/structure
to store just Item name and Rank.
And you can define a Category class to store items of that category.
And then you can store all Category instances into a container.
This is a hierarchical approach, and it is good if you need to group items
by category.

You may also consider using std::map instead of std::vector for containers,
if you want to identify the items or categories by their names (the std::map
key would be a string).

Moreover, considering that you are defining a more complex data structure
context to represent your data, you may consider using *pointers* to class
instances (and not stack-based automatic class instances), to avoid
deep-copy. And you can combine STL containers like std::vector or std::map
with boost::shared_ptr, getting kind of a "C++ garbage collector" :)

Giovanni


.



Relevant Pages

  • Re: The animal, not the environment, controls behavior.
    ... "HTMs are organized as a tree-shaped hierarchy of nodes, ... Paraphrasing this as "associations in the environment" just ... That means "internally" in the HTM model. ... Now the only way I could do it was to "store" the ...
    (comp.ai.philosophy)
  • Re: The animal, not the environment, controls behavior.
    ... "HTMs are organized as a tree-shaped hierarchy of nodes, ... internal associations would reflect the environements ... Now the only way I could do it was to "store" the ...
    (comp.ai.philosophy)
  • Re: Request help in understanding levels.
    ... Or once the hierarchy is defined, ... The rank of S is the least ordinal k such that S is a subset of Vk. ... What do you mean by "defining a set" and "refer ... is the axioms that "do the checking". ...
    (sci.logic)
  • Re: format for data storage?
    ... > I need to store a lot of datainto a single file. ... > interface, maybe ZIP, a Database, or other. ... a hierarchy can however be simulated ... The not-so-low-level way is OLE Structured Storage (a.k.a. Active Structured ...
    (comp.programming)
  • Re: Public folder store not being stamped with smtp by RUS
    ... No, the public stores email each other the hierarchy information, which is ... done before any replication is set up. ... If one store doesn't have an SMTP ...
    (microsoft.public.exchange2000.admin)