Set DataStructure

Discussion in 'Java' started by Anony!, Aug 12, 2004.

  1. Anony!

    Anony! Guest

    Hi

    I know that a list contains duplicates and a set does not.

    Whats the difference between the 3 implementations of the set interface?
    They being the hashset, linkedhashset, and treeset?

    What I predict:

    1. Hashset: dont know.
    2. LinkedHashSet: no order, elements in a linkedlist structure, and has no
    duplicates.
    3. Treeset: orders elements in a tree-like structure and has no duplicates.

    Anyone want to complete the picture?

    Thanks.
    AaA


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    Anony!, Aug 12, 2004
    #1
    1. Advertising

  2. Anony!

    Murray Guest

    "Anony!" <> wrote in message
    news:yIHSc.53272$...

    > 1. Hashset: dont know.


    HashSet has no guaranteed order. Order may even change over time. It is
    based on the hashCode of an object (which is essentially random) and it is
    backed by a HashMap implementation

    LinkedHashSet has a predictable order i.e. insertion order

    TreeSet uses natural ordering of Comparable elements, or a supplied
    Comparator

    By the way, all this info is easily found in the Java API e.g.
    http://java.sun.com/j2se/1.4.2/docs/api/ or you own local copy
    Murray, Aug 12, 2004
    #2
    1. Advertising

  3. Anony!

    Anony! Guest

    > "Anony!" <> wrote in message
    > news:yIHSc.53272$...
    >
    > > 1. Hashset: dont know.

    >
    > HashSet has no guaranteed order. Order may even change over time. It is
    > based on the hashCode of an object (which is essentially random) and it is
    > backed by a HashMap implementation


    I thought a hashcode for an object is unique to that object and would not
    change.

    > LinkedHashSet has a predictable order i.e. insertion order
    >
    > TreeSet uses natural ordering of Comparable elements, or a supplied
    > Comparator





    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    Anony!, Aug 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sharp

    Index-based datastructure

    Sharp, Mar 14, 2005, in forum: Java
    Replies:
    1
    Views:
    314
    Chris Uppal
    Mar 14, 2005
  2. Replies:
    3
    Views:
    378
    shakah
    Jun 23, 2005
  3. Santosh

    Datastructure design

    Santosh, Nov 19, 2003, in forum: C Programming
    Replies:
    6
    Views:
    365
    pandy
    Nov 20, 2003
  4. Prateek Basu

    Datastructure and Algorithms

    Prateek Basu, Jan 23, 2004, in forum: C Programming
    Replies:
    4
    Views:
    2,192
    Prateek Basu
    Jan 24, 2004
  5. jason
    Replies:
    4
    Views:
    293
    Bruno Desthuilliers
    Sep 9, 2006
Loading...

Share This Page