File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection Interface

 
wrushasen dakhane
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

1. Why Map is not part of the Collection Interface?

2. What is THashMap? and how it is benificial compared to HashMap?
(What do you mean by weakHashMap)

Wrushasen D.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why Map is not part of the Collection Interface?

Are you asking why Map doesn't extend Collection? A Map is a collection of bindings from key to value, so there are always two elements involved (key and value). You can get collections of the keys, the values, and the bindings from the Map, though, if you need to treat those as Collection.


What is THashMap? and how it is benificial compared to HashMap?

Do you mean TreeMap? Have you read its javadoc? It spells out how it differs from HashMap. The same goes for WeakHashMap.
 
wrushasen dakhane
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I have gone through the javadoc for the same but unable to understand the reason for the same.

Can you please explain me the THashMap --- it is not TreeMap

Explain me the concept of WEakHashMap.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get "THashMap" from? That is not a class or interface in the standard Java API.

With some Googling I found this: GNU Trove: High performance collections for Java. That's probably where you got this from. Read the documentation there.
[ April 05, 2007: Message edited by: Jesper Young ]
 
wrushasen dakhane
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

You will get the information using the below link.

http://trove4j.sourceforge.net/javadocs/gnu/trove/THashMap.html
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That appears to be part of trove, not the JDK. As Jesper suggests, the trove documentation should say.
 
bala nannaka
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WeakHashMap which is subtype of HashMap contains a weak object references.
weak object reference means It will not wait till garbage collector come and cleans when there is a no reference present it will be deleted immediately.

this is used for security purpose
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a bit confusing or maybe incorrect. Removal will always "wait for the garbage collector" because that's what removes objects from memory.

WeakHashMap says: An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. And once the key is gone, it removes the whole MapEntry. So when you put something in a WeakHashMap it will stay there as long as there is a strong reference to the key somewhere.

The map itself makes only a WeakReference to the key. WeakReference says when the GC finds that all references to an object are weak, it will make the object eligible for collection by breaking all the references.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic