Java - pointer to a class - Very Stuck!

Associate
Joined
23 Aug 2004
Posts
1,493
I have a class Dictionary

public class Dictionary
{
private HashMap<String, ArrayList<String>> dictionary;
private HashMap<String, ArrayList<Details>> synset;

public Dictionary()
{
dictionary = new HashMap<String, ArrayList<String>>();
synset = new HashMap<String, ArrayList<Details>>();
}

//some methods
}

and a class Details

public class Details
{
private String word;
private String type;
private String meaning;
private String w_num;
private String sense_num;
private String tag_count;
private ArrayList<String> hyponyms;
private ArrayList<String> meronyms;

public Details(String word, String type, String meaning, String w_num, String sense_num, String tag_count)
{
this.word = word;
this.type = type;
this.meaning = meaning;
this.w_num = w_num;
this.sense_num = sense_num;
this.tag_count = tag_count;
hyponyms = new ArrayList<String>();
meronyms = new ArrayList<String>();
}
}

The dictionary class reads a file and creates Details objects. I have a method which allows me to enter a word into the dictionary HashMap which gives an id. I can put this into the synset HashMap to retrieve it's detail object. This can is passed to the Details class where a toString() method prints the details. A detail object has two array lists, hyponyms and meronyms (related words) which give an id.

What I want to do is pass the hyponym and meronym id's back to the synset HashMap in the dictionary class and retrieve the details. It is possible by using a pointer to the synset hashmap in the Detail constructer but I don't think the Detail class should be able to access the HashMaps at this level. I want a pointer to the dictionary class itself so I can access the HashMaps using defined accessor methods. Can anyone suggest how to do this?
 
Or you can simply use this, no need for the prefix, this, means 'myself', or 'this instance'. You are effectively saying this.this which works fine but is completely redundant.

I'm guessing your a second year Computer Science student (maybe?). We had the exact same project but ours was a Chinese dictionary and we had to use it to get the english translation, english meaning, and a Chinese transliteration. We were given a text file with something like 60,000 entries and we had to design a program to perform operations on the file and it has to be fast.

The searching/adding/editing/deleting code caused me a headache, I was in a muddle with maps and iterators. If you get stuck and need some assistance just post again or my email is in my trust.

-Rob
 
Back
Top Bottom