Results 1 to 13 of 13
Thread: Table Data Type
- 03-14-2011, 02:31 AM #1
What is a "Table ADT"? What specifically are your requirements?
Edit: For what it's worth, normally, I'd store this frequency data in a HashMap<Character, Integer>.
Last edited by Fubarable; 03-14-2011 at 03:14 AM.
- 03-14-2011, 03:17 AM #3
not an ADT, sorry. The characters and their counts will be kept in a table data structure.
- 03-14-2011, 03:19 AM #4
so the characters would be the 'keys' of the map?
- 03-14-2011, 03:25 AM #6
Ok, so if I do a myHashMap.put(A,1) for the first time I find an A, how would I update the value portion (the 1) the next time I find an A?
First you'd call get on the HashMap using your char as a key. If it returns null, then you know that this is the first time that this char was encountered and you'd put in a 1 for this char. Otherwise if it returns a viable Integer, you get the intValue, add one to it, and put the resulting incremented value.
- 03-14-2011, 03:31 AM #8
hmm.. looks like get is returning an object. Is it as simple as casting it to an int?
- 03-14-2011, 03:36 AM #9
nevermind, I see what what you are saying
- 03-14-2011, 03:56 AM #11
so it would be like:
HashMap table = new HashMap<Character,Integer>;
- 03-14-2011, 04:28 AM #13
- By fraB3422 in forum New To JavaReplies: 7Last Post: 02-27-2011, 03:08 AM
- By JONCOM in forum New To JavaReplies: 11Last Post: 01-30-2011, 10:57 PM
- By crishantha in forum LuceneReplies: 0Last Post: 12-03-2010, 07:07 AM
- By edi.gotieb in forum JDBCReplies: 9Last Post: 05-19-2010, 02:13 PM
- By java girl in forum Threads and SynchronizationReplies: 3Last Post: 02-13-2009, 09:37 AM