J
John Galt
Hi All,
Suppose I have a TreeMap, and I want to update one of the values in
it.
I would do:
TreeMap tree;
Object count = tree.get(Object word);
count = count + 1; // assume that "+" is defined somehow
tree.put(Object word, count);
My Questions:
1. My question is, assuming that get() and put() each run in lg(n)
time, won't this be inefficient as opposed to how it could be done in
C, say:
struct node *p;
p = tree_search(char *word); // only one lookup, returns node pointer
p->count++;
2. So ultimately, can it be done as its done in C? How can "pointers"
(however they exist) be used in Java?
3. I am using a TreeMap to build an index to find the words that occur
in the most documents - in some large set of documents. Is there a
more efficient data structure in Java?
thanks in advance,
John
Suppose I have a TreeMap, and I want to update one of the values in
it.
I would do:
TreeMap tree;
Object count = tree.get(Object word);
count = count + 1; // assume that "+" is defined somehow
tree.put(Object word, count);
My Questions:
1. My question is, assuming that get() and put() each run in lg(n)
time, won't this be inefficient as opposed to how it could be done in
C, say:
struct node *p;
p = tree_search(char *word); // only one lookup, returns node pointer
p->count++;
2. So ultimately, can it be done as its done in C? How can "pointers"
(however they exist) be used in Java?
3. I am using a TreeMap to build an index to find the words that occur
in the most documents - in some large set of documents. Is there a
more efficient data structure in Java?
thanks in advance,
John