A short thread, a big wtf



  •  another great thread from java forums:

     

    http://forum.java.sun.com/thread.jspa?threadID=5297974&tstart=0 

     

    someone asks a question that doesnt make sense, and 10 people give wrong answers. yey! 



  • I have a hashtable in which some of the values are exactly the same. I want to remove the duplicates so that for one value there is only one copy in the hashtable.

    How does that not make sense?



  • @stinch said:

    I have a hashtable in which some of the values are exactly the same. I want to remove the duplicates so that for one value there is only one copy in the hashtable.

    How does that not make sense?

    Makes sense, but it sounds like a hash table is probably the wrong data structure to use here...



  • @merreborn said:

    Makes sense, but it sounds like a hash table is probably the wrong data structure to use here...

    Why is it the wrong data structure?  It just sounds like he needs a bi-directional hashtable.



  • @JosAH said:

    That is nonsense.

    kind regards,

    Jos
    I love how they start acting all superior and then later have to swallow their pride.



  • @Zecc said:

    @JosAH said:

    That is nonsense.

    kind regards,

    Jos
    I love how they start acting all superior and then later have to swallow their pride.

    Lyle wouldn't have to swallow his pride because of course he would be right.



  •  Ouch, wow. None of them actually read the OP. What I read was duplicate*values*, not *keys*, of which everyone else was assuming he meant. Having duplicate values in a hash table is perfectly valid, though yeah there are probably better structures out for what he's doing.

    Who in their right mind reads the java forums anyway? It's so much cesspool it's depressing.



  • The question makes sense, and at least 2 answers are right, too.  The original post asked how to remove duplicate values from a Hashtable.  The Hashtable can most certainly contain duplicate values.  All those who remarked that the question was wrong were confusing "values" with "keys".  Keys must be unique, but values not necessarily.

        dZ. 



  • @DZ-Jay said:

    The question makes sense, and at least 2 answers are right, too.  The original post asked how to remove duplicate values from a Hashtable.

    @JosAH said:

    It still doesn't make any sense: for a map like this: (A, X) (B, X) after removing the duplicate value what should the result be: (A, X) or (B, X)?

    I agree with JosAH here.



  • @derula said:

    @DZ-Jay said:
    The question makes sense, and at least 2 answers are right, too.  The original post asked how to remove duplicate values from a Hashtable.

    @JosAH said:

    It still doesn't make any sense: for a map like this: (A, X) (B, X) after removing the duplicate value what should the result be: (A, X) or (B, X)?

    I agree with JosAH here.

    One would presume the latest entry would overwrite the previous one, just like a hashtable does with identical keys. 



  • @morbiuswilters said:

    One would presume the latest entry would overwrite the previous one, just like a hashtable does with identical keys. 
     

    That would appear to be the obvious solution, unless you are the type of person to sit around all day and not do anything because the specs/boss didn't hold your hand...



  • AFAIunderstand, the structure he wants is two sets with bijection. Not completely trivial, actually.



  • @fbjon said:

    AFAIunderstand, the structure he wants is two sets with bijection. Not completely trivial, actually.

    Simply using two hashtables sounds pretty trivial to me.



  • @Morbii said:

    @fbjon said:

    AFAIunderstand, the structure he wants is two sets with bijection. Not completely trivial, actually.

    Simply using two hashtables sounds pretty trivial to me.

    You still need to map between them.


  • @fbjon said:

    You still need to map between them.

    And why is that difficult?  Obviously you should make your own parent class, but I don't see where the problem lies.  If your bi-directional hash table is meant to be 1:1 on keys and 1:1 on values, it's trivial.

     For example, C# (that may or may not be broken) for your Set method might look something like this:

     assuming member hashtables ktov (key to value) and vtok (value to key)
    void Set(object key, object value)
    {
     object currentValue, currentKey;
     if(ktov.Lookup(key, out currentValue))
      vtok.Remove(currentValue);
     if(vtok.Lookup(value, out currentKey))
      ktov.Remove(currentKey);
     ktov.Set(key, value);
     vtok.Set(value, key); 
    }

     



  • ^^^

    You'd also have to recurse and remove all key/value pairs that got removed due to the first removal as well (until there were no more collisions).

     



  • Not sure if anyone noticed, but I believe this data structure would actually have to remove every element if a duplicate key came along that had a different value or vice versa :)  (if you were to make sure that every key had a value that was in the value table and vice versa)



  •  Ok, I've got to ask... can anyone make out wth it is that Morbii has as an avatar?



  • @DOA said:

     Ok, I've got to ask... can anyone make out wth it is that Morbii has as an avatar?

    I always figured it was either KISS or the Finnish metal band Lordi.

    Perhaps we could just ask Morbii though.



  • @belgariontheking said:

    @DOA said:

     Ok, I've got to ask... can anyone make out wth it is that Morbii has as an avatar?

    I always figured it was either KISS or the Finnish metal band Lordi.

    Oh, a schooner!



  • @belgariontheking said:

    Perhaps we could just ask Morbii though.

     

    It's actually the Norwegian metal band Immortal.  It's the cover of their album "Blizzard Beasts".

     

    http://www.youtube.com/watch?v=3GmNBeG4fiE



  • @Morbii said:

    @belgariontheking said:
    Perhaps we could just ask Morbii though.
    It's actually the Norwegian metal band Immortal.

    That's close enough. belgariontheking had 4 correct letters, and three of them in the right order.


Log in to reply