Query regarding implementation of HashSet and TreeSet and AbstractSet

I have found that the treeSet and HashSet extends AbstractSet and implements Cloneable and Serializable interfaces.
What happens if AbstractSet itself implements Cloneable and Serializable interfaces, so that The HashSet and TreeSet need not to implement separately?
Is it a design concern or is there any logic behind in doing so?
I appreciate your quick response..
Thanks
Shiva kumar

It would mean that anybody else such as me who extended AbstractSet would be stuck with my implementation being serializable and cloneable whether I wanted or not. No doubt the designers wanted to provide the freedom not to do so.

Similar Messages

  • Query regarding the Node manager configuration(WLS and OAM Managed server)

    Query regarding the Node manager configuration(WLS and OAM Managed server):
    1) In the nodemanager.properties I have added the ListenAddress:myMachineName and ListenPort: 5556
    My setup : One physical Linux machine(myMachineName) has : WLS admin server, managed server(OAM 11G) and nodemanager.No clustered environment.
    2) nodemanager.log has the following exception when I start the oam_server1 using EM(Enterprise Manager11g):
    Mar 23 2012 1:39:55 AM> <SEVERE> <Fatal error in node manager server>
    java.net.BindException: Address already in use
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336)
    at java.net.ServerSocket.bind(ServerSocket.java:336)
    at javax.net.ssl.impl.SSLServerSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.<init>(ServerSocket.java:202)
    at javax.net.ssl.SSLServerSocket.<init>(SSLServerSocket.java:125)
    at javax.net.ssl.impl.SSLServerSocketImpl.<init>(Unknown Source)
    at javax.net.ssl.impl.SSLServerSocketFactoryImpl.createServerSocket(Unknown Source)
    Default port on which node manager listen for requests is localhost:5556.I have changed it to point to my machine. The port should be of WLS admin server or it should be the managed server port?
    3) I have started the NodeManager using the startNodeManager.sh script.
    4) The admin server port is 7001 and the oam managed server port is 14100.
    Any inputs on what might be wrong in the setup will be helpful.Thanks !

    By using netstat -anp|grep 5556 you can check which process on your machine is using the 5556 port.

  • Query regarding implementing non leading ledger

    Hi friends,
    I am suppose to implement the non leading ledger along with the leading ledger. Its fiscal year is from Jan - Dec. I have a query that is there any issues at the year change ( like any kind of adjustment at year end) and what are the things needed to be carried out at the beginning of the year.

    Dear Mr.Anand,
    Could you please clear the below points.
    1. Are you using NewGL ?
    2. Want to add the Non-Leading ledger ?
    3.  "I am suppose to implement the non leading ledger along with the leading ledger" means want to implement both ledgers
           like Leading ledger and non leading ledger
    4. You want to classic ledger to New ledger ?
    If you are using classic ledger then you need to go for newgl migration.
    IF you allready using the NewGL and want to add non leading leadger then useing the New GL migration scenarios 6, 7,8.
    Please refer the below link.
    http://wiki.sdn.sap.com/wiki/x/JghNCw
    please revert back to me with more details.
    Reg
    Madhu

  • Urgent query regarding performance

    hi
    i have one query regarding performance.iam using interactive reporting and workspace.
    i have all the linsence server,shared services,and Bi services and ui services and oracle9i which has metadata installed in one system(one server).data base which stores relationaldata(DB2) on another system.(i.e 2 systems in total).
    in order to increase performance i made some adjustments
    i installed hyperion BI server services, UI services,license server and shared services server such that all web applications (that used web sphere 5.1) such as shared services and UI services in server1(or computer1).and remaining linsence and bi server services in computer2 and i installed database(db2) on another computer3.(i.e 3 systems in total)
    my query : oracle 9i which has metadata where to install that in ( computer 1 or in computer 2 )
    i want to get best performance.where to install that oracle 9i which has metadata stored in it.
    for any queries please reply mail
    [email protected]
    9930120470

    You should know that executing a query is always slower the first time. Then Oracle can optimise your query and store it temporary for further executions. But passing from 3 minutes to 3 seconds, maybe your original query is really, really slow. Most of the times I only win few milliseconds. If Oracle is able to optimize it to 3 seconds. You must clearly rewrite your query.
    Things you should know to enhance your execution time : try to reduce the number of nested loops, nested loops give your an exponential execution time which is really slow :
    for rec1 in (select a from b) loop
      for  rec2 in (select c from d) loop
      end loop;
    end loop;Anything like that is bad.
    Try to avoid Cartesian products by writing the best where clause possible.
    select a.a,
             b.b
    from  a,
            b
    where b.b > 1This is bad and slow.

  • TreeSet and HashSet

    Hello
    There is a very useful functionality, that I think should be implemented in
    TreeSet nad HashSet
    that is the method: Object get(Object o).
    The method should return the same object from colletion as the parameter object.
    In TreeSet complexity would be log(n), in HashSet would be constant.
    With lack of this functionality one must implement collections on maps, so the unnecessary and more complex type will be used.
    What do you think about this?
    Regards
    Marcin

    This is a strange question :)
    I assume, the OP does not want the object to be returned, but the one from the Set, which is equals to the given object, or null. This might be useful, if operating in a template scenario like JINI, where the given object defines a template (or pattern) that suffices the equals method but does not have further data contained by the object in the Set (which actually should be solved by using a Map). Or if you want to match and return the equal object to have the exact instance. E.g. for a simple Set:public Object get(Object o) {
      for (Object object : objects) {
        if (object.equals(o)) {
          return object;
    }which might be optimized for HashSet (quicker due to buckets) and TreeSet (quicker due to tree structure).
    �dit: Ok, my first scenario was the one. I'd suggest using a Map instead, which is much cleaner wrt. equals/hashcode implementation and contract.
    Message was edited by: stefan.schulz

  • Timing analysis on HashSet and TreeSet Help

    Need help with this problem. I need to test two implementations of the java.util.Set interface for time efficiency. The implementations are java.util.HashSet and java.util.TreeSet. The code to construct each follows like this:
    import java.util.*;
    ....main()
    Set s = new HashSet();
    // test
    s = new TreeSet();
    // test
    Sample Output: (HashSet versus TreeSet: 1000000 insertions timed every 100 insertions. )
    Test run for HashSet
         Total elapsed time (ms) for HashSet: 12137
         Average time (ms) to insert 100 elements: 1.2137
    Test run for TreeSet
         Total elapsed time (ms) for TreeSet: 14607
         Average time (ms) to insert 100 elements: 1.4607
    CODING DETAILS:
    1. What to insert? Randomly generated integers. Here's a code slice to illustrate:
    Set s = new HashSet();
         Random r = new Random();
         long start = new Date().getTime(),
         mark = start,
         stop = 0;
         for (int i = 0; i < tries; i++) {      // tries is 1,000,000
         s.add(new Integer(r.nextInt()));
         if ((i % segment) == 0) {          // segment is 100
         stop = new Date().getTime();
         long diff = stop - mark;
    2. Need to save the elapsed time per 100 insertions. It can be generated by adding up the 100-insertions times. Like in the above code, the variable diff records the time per 100 insertions, and
    it save the different values of diff.

    Are you adding up the time intervals for every 100 insertions to get the total time it took? The current time provided by the runtime may not be accurate due to some caching done in the OS level. It can be as bad as 50 ms (in windows 98, I think). So adding up such short time intervals can give you inacurate results. Also, you should use System.currentTimeMillis() rathen than new Date().getTime()
    Theoritically, Treeset gives you guranteed O(logN) while HashSet gives you O(1) as long as you have a decent hashing algorithm. Since, you are getting the int from a pseudo-random genetor (and Integer.hashcode() returns the int value it represents), HashSet should perorm better for such large number of data.
    Here is a slightly changed version of your code,
    import java.util.*;
    public class TreeHashPlay {
    public static void main(String[] args) {
    double hs = measure(new HashSet());
    double ts = measure(new TreeSet());
    System.out.println("ration TreeSet/HashSet: "+ ts/hs);
    static double measure(Set set) {
    long end = 0;
    long start;
    final int UP = 1000000;
    Random rand = new Random();
    start = System.currentTimeMillis();
    for(int i = 0; i < UP; i++) {
    set.add(new Integer(rand.nextInt()));
    end = System.currentTimeMillis();
    long duration = end - start;
    System.out.println("impl: "+set.getClass()+" total time: "+ duration+" total item: "+ UP
    +" average time: "+(double)duration/UP);
    return (double)duration/UP;
    }//class ends
    and Here is a sample output:
    impl: class java.util.HashSet total time: 11530 total item: 1000000 average time: 0.01153
    impl: class java.util.TreeSet total time: 18460 total item: 1000000 average time: 0.01846
    ratio TreeSet/HashSet: 1.6010407632263661
    Hope it helps.

  • A Query regarding 'Events' published and 'Event' subscribed

    I have a query regarding 'Events' and 'EventHandling' in Java Swing.
    Swing in an EVENT based application whereby 'events' are generated
    by interacting with the components.
    Eg: Clicking on a Button generates an 'ActionEvent' and every event
    generated has an associated 'EventListener'.
    Now,my question is:
    a)When an event is generated,(let's say by clicking a button),
    an 'event' is published,right?
    That means that there is an 'Event Publisher'.
    In the above case,the Button is the 'Publisher' of the event,right?
    b) Who are the subscribers for the events generated?
    Where do we specify the 'subscibers' to the events generated?(and once
    the subscribers get the Event,the subscriber will call the methods
    of the event object)
    We just say
       addButton.addActionListener(new ButtonHandler);
       private class ButtonHandler implements ActionListener {
            public void actionPerformed(ActionEvent e){
      In the above code :
    a) Who is the Event Publisher?
    b) Who is the Event Subscriber?
    No offence meant for the question.

    The 'event publisher' for the mouse click is the ToolKit implementation (translates the OS mouse event to a Java mouse event).
    The 'event subscriber' for the mouse click on a button is typically a ButtonUI (you can add a mouse listener directly though).
    The 'event publisher' for the action event is the ButtonModel (notified by the ButtonUI when the button is unpressed, etc).
    The 'event subscriber' for the action event are the action listeners.

  • Query regarding Inline Query and a Join.Please see

    I have a query regarding Inline Queries
    I have 2 tables
    TRADE and POSTING
    TRADE has Primary Key:id_trade_ref and POSTING has Foriegn.Key: id_trade_ref
    id_trade_ref 5V973781B has 5 records in POSTINGS
    If i need to join these 2 tables,I use
    1) Select t.id_entity,t.id_trade_ref,p.am_stock
       from trade t,posting p
       where t.id_trade_ref = '5V973781B'
       and   p.id_trade_ref = '5V973781B'
    2) Now I can use the same as an Inline Query:
       select
       t.id_entity,
       t.id_trade_ref,
       (  select p1.am_stock 
          from posting p1
          where p1.id_entity =  t.id_entity
          and   p1.id_trade_ref= t.id_trade_ref
          and   p1.id_posting_type in ( 'NEW', 'CAN')
    from
    trade t
    where t.id_entity = 'DBL'
    and   t.id_trade_ref = '5V973781B'
    My Query:
    Of the two,which is a better option to use.?
    Is Inline a better option or a normal join?

    I would rewrite the first one to:
    Select t.id_entity,t.id_trade_ref,p.am_stock
    from trade t,posting p
    where t.id_trade_ref = '5V973781B'
    and p.id_trade_ref = t.id_trade_ref
    This way, you really make the join between the table.
    I think the join is better because it uses less code. I do not think you will notice much performance win between one or the other, especially because it concerns only a few rows.

  • Hung queries, and Oracle thin driver query timeout implementation

    We are seeing occasional instances of stuck threads, where the code is in Oracle thin XA driver code waiting for a socket read for a response from the database. Usually only one thread at a time. The connection never terminates and we have to shut down WebLogic to clear it. The DBAs tell us that all connections to the 11g RAC cluster members from our hosts are idle, with no hung or long-running transactions.
    This happens every few days across two WebLogic 10.3.5 clustered instances in our QA environment, usually not the same time on two servers (one had four incidents, the other had only one, in the last 15 or so days). Sometimes it has resulted in a hung server, as the driver is holding a lock that blocks other threads (today we had numerous threads block in a TX rollback).
    I'm guessing our WebLogic instance somehow is not getting the connection close from the remote host. BTW, there is no firewall between us and the DB. I have not got any strong suspect for the cause (although we are running Linux on a VMWare 4.0 VM, which always worries me).
    Ordinarily I'd either ask the application to set a query timeout, or set the query timeout parameter for the connection pools as a workaround (we are using a MultiDatasource), so the transaction would at least abort and the application can handle it. However, while the Oracle driver does support java.sql.Statement.setQueryTimeout(), some brief investigation on my part leads me to believe the timeout is implemented on the server side and not the client side - so that if it is indeed the case that WebLogic does not see the close on the connection, it also would never see the timeout.
    Two questions:
    1. Is my suspicion about server-side implementation of timeout for Oracle 11g correct?
    2. If so, is there some property I can set for the driver that will implement a socket timeout? Is this "safe"?
    Thanks for any help!
    [ Oracle WebLogic 10.3.5, HotSpot 64 bit JVM 1.6.0_29 on RHEL 5.6 on VMWare; Oracle Thin XA driver bundled with WebLogic; Oracle RAC 11g (three-node cluster)]
    Edited by: SteveElkind on Dec 3, 2012 5:25 AM

    Thanks, Joe.
    My investigations were heading in this direction (e.g., http://docs.oracle.com/cd/B28359_01/java.111/b31224/apxtblsh.htm#CHDBBDDA). However, for WebLogic, is it as simple as adding the following property in the Datasource Connection properties edit box in the WebLogic console?
    oracle.net.READ_TIMEOUT=300000
    or do I have to edit the connection URL?
    I've tried this, and the Datasource restarts OK after the change, but I have no way right now to check whether it actually "works".
    (we have some long-running queries; five minutes seems to be a "safe" limita for now)

  • Query regarding Exception and invocation.

    I have a query regarding Exception.
    In my code, which throws an ArithmeticException:
    <code>
    public class TestArithmeticException{
    public static void main(String[] args)
    int a,b ;
    try {
    b=0;
    a = 50/b;
    }catch(Exception ex) {
    ex.printStackTrace()
    </code>
    The above code is catching exception of type Exception(which is superclass of all RuntimeExceptions)
    and which inturn extends the Throwable class.
    ie. Throwable -
    Exception -
    RuntimeException
    ArithmeticException
    Am I correct in my assumption below:
    a Because ArithmeticException is an indirect subclass of Throwable and has access to its inherited methods,
    it overrides the methods defined in 'Throwable', and then via polymorphism(superclass reference 'ex' in the catch clause)
    invokes the method ex.printStackTrace() ?
    Does it mean that all runtime exception child classes override the methods defined in Throwable, and then via polymorphism execute overridden
    methods?

    Yes.

  • ABAP Query, To list both, the PO created and PO modified for a given period

    Hi
    I want to create a query that list the purchasing orders created or modified during a given period. however, the creation date and the modification date are two different fields stored in differents tables.
    if I have these two fields in the selection creteria screen, the relationship between them will be the operator AND. so this will not enable me to have the information targeted.
    My quetion, is there a possibility to have the Operator OR in the first selection creteria screen , between these 2 fields.?
    the tables are:
    for the creation EKKO
    for the change :
    MECDGRID
    CDHDR Change document header
    CDPOS Change document items
    thanks

    Hello,
    Fetch data from EKKO and do a for all entries on the table CDHDR on the field OBJECTID and EBELN and t-code = ME21N OR ME21 ETC.
    Similarly between CDHDR and CDPOS tables based on objectid`s.
    Hope this helps you in solving your problem!
    Regards,
    Reetesh

  • SQL 2012 SP1 - How to determine a query that causes Error 8623 in SQL Log: The query processor ran out of internal resources and could not produce a query plan. This is a rare event...

    We are getting multiple 8623 Errors in SQL Log while running Vendor's software.
    How can you catch which Query causes the error?
    I tried to catch it using SQL Profiler Trace but it doesn't show which Query/Sp is the one causing an error. 
    I also tried to use Extended Event session to catch it, but it doesn't create any output either.
    Error:
    The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that
    reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
    Extended Event Session that I used;
    CREATE EVENT SESSION
        overly_complex_queries
    ON SERVER
    ADD EVENT sqlserver.error_reported
        ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
        WHERE ([severity] = 16
    AND [error_number] = 8623)
    ADD TARGET package0.asynchronous_file_target
    (SET filename = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xel' ,
        metadatafile = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xem',
        max_file_size = 10,
        max_rollover_files = 5)
    WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
    GO
    -- Start the session
    ALTER EVENT SESSION overly_complex_queries
        ON SERVER STATE = START
    GO
    It creates only .xel file, but not .xem
    Any help/advice is greatly appreciated

    Hi VK_DBA,
    According to your error message, about which query statement may fail with error message 8623, as other post, you can use trace flag 4102 & 4118 for overcoming this error. Another way is looking for queries with very long IN lists, a large number of
    UNIONs, or a large number of nested sub-queries. These are the most common causes of this particular error message.
    The error 8623 occurs when attempting to select records through a query with a large number of entries in the "IN" clause (> 10,000). For avoiding this error, I suggest that you could apply the latest Cumulative Updates media for SQL Server 2012 Service
    Pack 1, then simplify the query. You may try divide and conquer approach to get part of the query working (as temp table) and then add extra joins / conditions. Or You could try to run the query using the hint option (force order), option (hash join), option
    (merge join) with a plan guide.
    For more information about error 8623, you can review the following article.
    http://blogs.technet.com/b/mdegre/archive/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Implementing Auto Contract Generation/Negotiation and Execution

    Would love to hear from anyone that has implemented auto contract generation/negotiation and execution.  Were there any lessons learned you could share during implementation?  Were there things you found out - too late? Are you seeing adoption?  How long did the implementation take?  Pain points along the road?  Things you would do differently?  We are getting ready to take this trip ourselves and I have a feeling it will not be smooth sailing.

    Hello Sravan
    Your message isn't clear fo me
    If you used import for new master data you can use automatic key generation ability for inbound port
    The another way:
    You can create special key field in MDM and
    create simple workflow which fire when ADD record.
    That worklflow call assignment which fill key field
    Regards
    Kanstantsin

  • Bug using list and treeset

    I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:
    package treeset;
    import java.util.Comparator;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.TreeSet;
    import java.io.Serializable;
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class TreeSetExample
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The TreeSetExample demonstreates a odity in the sorting of list using a treeset
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class TreeSetExample extends Object {
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * Constructs a TreeSetExample object
    public TreeSetExample() {
    } // end constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * getDatea
    public List<SimpleVO> getData() {
       List<SimpleVO> returnList = new LinkedList<SimpleVO>();
       SimpleVO simpleVO = null;
       for (int i = 0;i < 5;i++) {
          returnList.add(new SimpleVO());
       } // end for
       return(returnList);
    } // end getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * runTest - Test the insert sorting of a tree set with a list of data
    * @param loopCount number of time to load data into the saveset
    public void runTest(int loopCount) {
       List<SimpleVO>    simpleList   = getData();
       SimpleVO          simpleVO     = null;
       TreeSet<SimpleVO> saveSet      = new TreeSet<SimpleVO>(new simpleComparator());
       SimpleVO          tempSimpleVO = null;
       Iterator<SimpleVO> iterator      = null;
       Iterator<SimpleVO> printIterator = null;
       int id = 0;
       for (int i = 0; i < loopCount;i++) {
          iterator = simpleList.iterator();
       // for each of the user's zip codes find the distance to the RSL
       while (iterator.hasNext()) {
          simpleVO = iterator.next();
          id ++;
          simpleVO.setName("" + id);
          saveSet.add(simpleVO);
       } // end while
       // print saveset at the end of each load
       System.out.println("list count after loop [" + (i + 1) + "] number of elements = [" + saveSet.size() + "] contents:");
       printIterator = saveSet.iterator();
       while(printIterator.hasNext()) {
          tempSimpleVO = printIterator.next();
          System.out.println(" save simpleVO name = [" + tempSimpleVO.getName() + "]");
       } // end while
       } // end For
    } // end runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * IbotMailParser main thread
    * @param arg standard main input string array.
    public static void main(String[] arg) {
       System.out.println("Main - Started");
       try {
          System.out.println("*************** starting test 1 *********************");
          TreeSetExample treeSetExample = new TreeSetExample();
          treeSetExample.runTest(1);
          System.out.println("\n");
          System.out.println("\n");
          System.out.println("*************** starting test 2 *********************");
          treeSetExample.runTest(2);
       } // end try
       catch (Exception any) {
          System.out.println("Exception [" + any.getMessage() + "]");
       } // end catch
       System.out.println("Main - we gone bye-bye...!");
    } // end main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The SimpleVO is a value object pattern used for this example
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class SimpleVO extends Object {
        * Default user name for Oracle connection.
       private String name = "";
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Returns the name value associated with this attribute
        * @return String - the Name parameter
       public String getName() {
          return(name);
       } // end getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start setName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Sets the name value for this attribute
        * @param newName the Name to be set
       public void setName(String newName) {
          if (newName != null) {
             name = newName.trim();
          } // end if
       } // end setName
    } // end SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class simpleComparator
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The SimpleComparator is a comparator object used for sorting simple value objects
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class simpleComparator implements Comparator<SimpleVO>, Serializable {
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Returns the name value associated with this attribute
        * @return String - the Name parameter
       public int compare(SimpleVO simpleVO_1, SimpleVO simpleVO_2) {
          return(1);
       } // end compare
    } // end SimpleComparator
    } // end class TreeSetExample
    output :
    c:\treeset>java treeset.TreeSetExample
    Main - Started
    *************** starting test 1 *********************
    list count after loop [1] number of elements = [5] contents:
    save simpleVO name = [1]
    save simpleVO name = [2]
    save simpleVO name = [3]
    save simpleVO name = [4]
    save simpleVO name = [5]
    *************** starting test 2 *********************
    list count after loop [1] number of elements = [5] contents:
    save simpleVO name = [1]
    save simpleVO name = [2]
    save simpleVO name = [3]
    save simpleVO name = [4]
    save simpleVO name = [5]
    list count after loop [2] number of elements = [10] contents:
    save simpleVO name = [6]
    save simpleVO name = [7]
    save simpleVO name = [8]
    save simpleVO name = [9]
    save simpleVO name = [10]
    save simpleVO name = [6]
    save simpleVO name = [7]
    save simpleVO name = [8]
    save simpleVO name = [9]
    save simpleVO name = [10]
    Main - we gone bye-bye...!
    Edited by: EJP on 7/04/2011 10:44: added code tags. Please use them.

    user12607386 wrote:
    I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:Well, first off, when you post code, please put it in '' tags; but the basic problem is your[code]simpleVO.setName("" + id);[/code]line. A name should normally be *final*, so you shouldn't be able to set it at all.
    When you add the second set of 5 to your Set, you're simply changing the name of the first 5 you just added, but since your Comparator doesn't actually do anything useful, it allows the second 5 to be added, which, of course, then show up as duplicates.
    My advice: +THINK+ about what you want to do; don't just sit down and code. If need be, get out a pencil and paper and write out in English the steps you need.
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to implement XI interfaces in online and offline modes?

    Hi Everybody,
    Can you please tell me how to implement XI interfaces in online and offline modes?
    thanks a lot,
    Ramya Shenoy.

    Hi,
    Are you looking for Push and Pull mechanism of PI?
    When the adapters like SOAP, HTTP, IDOC, etc. send the data to PI , it is nothing but a push mechanism, and hence the communication is synchronous by default.
    But adapters like JDBC, File, etc. they fetch the data from Source Applications, so it is a kind of Pull mechanism for PI, and
    by default communication is asynchrnous.
    Pls elaborate exactly what are you looking for?
    Regards,
    Supriya.

Maybe you are looking for

  • Extension error while running but not during debug

    Hi all, I'm using JDev 10.1.2 and I developed an extension for it. This extension guides the user to the creation of a sql file through a sequence of frames. While in debug mode, this extension works without the smallest problem, but when i restart j

  • Using DBMS_JOB to schedule auto execution of procedure on a daily basis

    I need to implement a batch procedure for my project and would be using DBMS_JOB for the same purpose.I have tried creating a job for the same that I submitted using DBMS_JOB.SUBMIT() and I ran the job initially using DBMS_JOB.run(). Now at this inst

  • I no longer have a screen...

    So my laptop is in two pieces... I no longer have a screen, but the computer part still works. I tried hooking it up to my HDTV, but it's very blurry and the sides of the screen can't be seen, aka the important parts like the menu bar on the left and

  • Apple HD Cinema Display not working

    Hello everyone, I bought a used Apple HD Cinema Display a few months ago and I have been using it with no problems in Leopard with my white macbook (late 2007). I have recently installed XP using bootcamp (the display was not connected at the time of

  • Updating Jtree problem

    I have a JTree which has to refresh (show the new node) on click of button when ever i am adding a new node. I am adding node by the DefaultTreeModel : insertNodeInto() method.I added the TreeModelListener to treeModel and also called the nodeStructu