Internal mechanism of Sorted Set

Hi,
I want to understand the internal mechanism of how the objects in a SortedSet gets sorted automatically? Also i have a confusion about the objects thar are stored in a Sorted set:-
1. Is it mandatory for the objects to be stored in Sorted set to override equals and hascode? If yes, are these methods called automatically every time a new object is stored in Sorted Set?
OR
2. Is it mandatory for the objects to be stored in Sorted set to implement comparable or comparator interface? If yes, is the compareTo method called automatically every time a new object is stored in Sorted Set?
Thanks

Neha_Khands wrote:
1. Is it mandatory for the objects to be stored in Sorted set to override equals and hascode? No, but probably a very good idea to do so.
If yes, are these methods called automatically every time a new object is stored in Sorted Set?They might be. It would depend on the particular implementation. The documentation for the given implementation should specify and requirements around those methods.
OR
2. Is it mandatory for the objects to be stored in Sorted set to implement comparable or comparator interface?Either the class your storing must implement Comparable, OR you must provide a separate Comparator object (and that Comparator would NOT be implemented by the class you're storing).
If yes, is the compareTo method called automatically every time a new object is stored in Sorted Set?Yes. Imagine you have a bunch of cards with numbers written on them, and they're laid out in a row, in numerical order, such as [2, 8, 9, 10, 14, 19]. Now you have a card with the number 12 on it. You want to insert it into that group, in the proper place to keep order. To do that, you're going to have to compare that card's value to some of the cards already there, to know where it goes. At some point you'll compare it to 10, find that it's greater, and know that it must therefore go to the right of 10. This comparison is performed "automatically" by you when someone asks you to add (store) a new card into that set.

Similar Messages

  • Internal mechanism of User changes

    One End (XYZ) user is login to the system, As a security person i am assigning one role to end user.it is immediately impact to (xyz) user.more over i am changing address, locking/unlocking,reset password... is not immediately  impacted to user...while the user logoff and login again....than only changes should me applied..
    What is the internal mechanism involved in the above task....
    Regards,
    KIRAN P

    Hi,
    I read your question in a different way. If it is on how the user authorizations are updated without user logging off/login, here is the answer:
    The auth/new buffering parameter will update the role assignment data immediately for the user. Hence, users need not logoff and login again. This parameter value should be set to 4.
    However, the other activities, such as password reset, lock/unlock are not related to authorizations and will not be stored in the user buffer. Hence, they are not considered by this parameter.
    Please re-phrase your question if my understanding is incorrect.
    Regards,
    Raghu
    Edited by: Raghu Boddu on Nov 14, 2010 10:38 PM

  • Internal mechanism about setOutgoing(), setOutgoingLength(), sendBytes()?

    Title: Who knows internal mechanism about setOutgoing(), setOutgoingLength(), and sendBytes()?
    The thing I want my applet to do is sending a 160-byte array out. The environment is JCOP 2.2 on card and JPCSC off card, and the code (prefixed with line number) is as follow:
    1       byte apduBuffer[] = apdu.getBuffer();
    2       // set the data transfer direction to outbound
    3       apdu.setOutgoing();
    4       // inform the host of the number of bytes in the data field
    5       apdu.setOutgoingLength((short)160);
    6       //copy data from an internal array to apduBuffer[]
    7       for((short)i=0; i<(short)160; i++)
    8       {
    9           apduBuffer[i] = Bob_PubSpecData;
    10 }
    11 // at offset 0 send x byte of data in the buffer
    12 apdu.sendBytes((short)0, (short)160);
    The array Bob_PubSpecData[160] has data as 385C...614A3C8B92D8.
    The ADPU message I received off card is 00300000A0385C...61, which has a header of 00300000A0 and data is 5-byte shorter than Bob_PubSpecData[160]. Strangely only 155-byte data but the Lc is still A0 (=160).
    (All the following tests are starting only from the above codes)
    Test(1): I changed 0 in 12th line to 5. ADPU message received off card is 385C...610000000000. Header is removed but the last 5 bytes are all filled by 0s.
    Test(2): I changed apduBuffer[i] in 9th line to apduBuffer[i+5], and got the same result as test(1).
    Test(3): I changed 160 in 5th line to 165, and got the same result as test(1).
    Who knows the internal mechanism of the setOutgoing(), setOutgoingLength(), and sendBytes()? I have the book of Java Card by Zhiqun Chen, but she didn't explain very clearly about these. I and my team member spent long time doing the various experiment today but still cannot get the correct result. Who can give us a hand?

    Very strange indeed.
    If I were you, I would perform the following tests:
    1. Change 160 to 4.
    2. Change 160 to 127.
    3. Place "apdu.setOutgoingLength((short)160)" right before apdu.sendBytes() (in 11th string).
    Indistinct ideas, but they may give some additional info...

  • Cache server internal Mechanism

    Hi all,
    I want to know architecture & internal mechanism of cache server. Also if possible give me some material @ same.
    Thanks & regards.

    Hi,
        Here I am giving the link, it may be help for you.
    http://www.dbuggr.com/milly/description-explanation-business-objects-enterprise-architecture-comp/
    Regards,
    Narendra.

  • Javabean & sorted set

    hello
    i'm developing a web service, for the server part i have developed a java bean because i need to return a complex type from the database but i don't know how to implement the interface comparator and the Sorted Set that I need to access the database,
    please help!!

    Could you post the Comparator you wrote and the code where you use it? Also, if you could post the results you are getting, that would help too.
    fitz

  • Type of sorted set

    hello
    i have a sorted set
    private static SortedSet database = new TreeSet(new PageContent());
    PageContent is a java bean.
    i want to know if the type of database is xml or not.

    i want to know if the type of database is xml or not.Yes, it's xml or not.

  • Internal and External different set of menu for ESS

    Hi
    We have 2 portal server - Internal and External. The Portal are being used not.
    We are planning to implement ESS now in Portal. We are planning to provide two different set of options when the same user access internally and externally.
    For example, User XYZ access internally he will get menus ABCDE but the same user access from external he only gets manu AB.
    If anyone has implemented with similar concepts or know how to do it technically, kindly advice.
    Thanks
    Yuva

    Let us assume we have 3 internal groups :
    internalGroup_1 -> Role A, Role B
    internalGroup_2 -> Role C, Role D,
    internalGroup_3 -> Role E,
    and 2 external group :
    externalGroup_1 -> Role A,
    externalGroup_2 -> Role B,
    We add similar user under a group. and then roles are assigned to groups. in above example Role A , Role B is assigned to internalGroup_1.
    We can have a single user id in which is attached to interalGroup_1, interalGroup_2, interalGroup_3 , externalGroup_1and interalGroup_2.
    When user logon to Internal portal he will see role A, B,C,D and E
    and when user logon to internal  poral he will see role A,B.
    provided A,B,C,D,E roles should exist in internal protal and role A,B exist in External portal. You can use transport roles from external portal to internal portal.

  • IMac A1311 broken internal monitor need to set external as primary

    My internal monitor's backlight is no longer working.
    I connected an external monitor, but I need to set it to mirror mode or to primary.
    F7 key doesn't work

    David,
    If you leave the internal display open, you cannot turn it off, but you can turn the brightness down to zero.
    You can in fact run the Lombard with the display closed if you have a USB keyboard, mouse, and external monitor. You must have the power adapter connected to run with the external monitor according to Apple.
    http://docs.info.apple.com/article.html?artnum=58334
    The default setting for an attached external monitor is extended desktop and you want mirroring; resetting the PRAM defaults to extended desktop.
    To find your System Preferences or Displays panel...
    - Select All (command-A) > then start click-dragging across the screen until you find the HD icon > open the HD icon and find the Applications folder > System Preferences > Displays.
    - Or try this: Find... (command-F) > enter Displays in the search field.

  • Internal and external mail setting

    I have 20 WinXP users connecting to my Xserve.
    I want to set up Mail so that only 3 Users can access mail both internally and externally from the office, the others I want to allow internal mail to each other but not to send/receive externally. Is this possible? If so how do I configure this behaviour?
    Regards
    Tony

    Can anyone assist with my previous posting?
    Can the functionality I want be achieved via the server or do I have to look foe alternative methods?
    Can anyone point me in the directon of info that will let me solve this issue?
    Regards
    Tony

  • Bypassing Internal IP for Proxy setting

    Hi,
    Does anyone know who to set the iPad to bypass proxy for any internal IP address? I.e Intranet sites should not need to go through our proxy server

    You can use the Auto proxy option to do this, but you will have to host a proxy.pac file on a suitable web server on your network that you can point the URL to.  This approach has the advantage that you can specifiy different proxies for different domains if necessary, as well as to connect directly for one or more local domains.
    Example code based on our setup:
    function FindProxyForURL(url, host)
    if (isPlainHostName(host))
    return "DIRECT";
    else if (shExpMatch(host, "*.domain1*"))
    return "DIRECT";
    else if (shExpMatch(host, "*.domain2.*"))
    return "DIRECT";
    else if (shExpMatch(host, "*.domain3*"))
    return "DIRECT";
    else
    return "PROXY InternetProxy:8080";

  • Sorting Set elements

    Hi all,
    Can anybody please help me on this one.
    im reading elemets from a file, The file is structured like this, student number | last name | firstname
    I store this values into a TreeSet and use a Comparator to sort them, and display them sorted by student number, NOW what i want is when 2 student numbers are equal, i want to sort by last name as a tie breaker. The problem is how do i do this.
    here's what i have done so far
    Method ReadFile
           String[][] values = (new CSVParser(new FileReader("D:\\test.csv"))).getAllValues();
            TreeSet<Students> students  = new  TreeSet<Students>();
            ArrayList<Students> stud = new ArrayList<Students>();
            for (int i = 0; i < values.length; i++) {
                for (int j = 0; j < values.length; j++) {
    if(!values[i][j].startsWith("#")){
    if(j==0){
    studentNumber = Long.parseLong(values[i][j]);
    if(j==1){
    timestamp = Long.parseLong(values[i][j]);
    }else{
    marks.add(Float.parseFloat(values[i][j]));
    stud.add(new Students(studentNumber, timestamp, marks));
    //marks.clear();
    for(int i = 0;i < stud.size();i++){
    System.out.print(stud.get(i).getStudentNumber() + ": " + stud.get(i).getTimestamp()+":"+stud.get(i).getMarks());
    System.out.println();
    Collections.sort(stud, new sortByStudentNuber());
    System.out.println("After Sorting");
    for(int i = 0;i < stud.size();i++){
    System.out.print(stud.get(i).getStudentNumber() + ": " + stud.get(i).getTimestamp()+":"+stud.get(i).getMarks());
    System.out.println();
    class: sortByStudentNuber
    public class sortByStudentNuber implements Comparator<Students> {
        public int compare(Students o1, Students o2) {
            long stud1 = o1.getStudentNumber();
            long stud2 = o2.getStudentNumber();
            if (stud1 > stud2) {
                return 1;
            } else if (stud1 < stud2) {
                return -1;
            } else {
                return 0;

    Ok, thanx for that. but let me make my question clear.
    Lets say There are predefined sortOrders which should be passed as parameters by the user when the program is running.
    S=sortByStudentNumber ascending order, s=sortByStudentNumber descending order, L=sortBylastname in ascending order, l = sortBylastname in descending order, F=sortByfirstname in ascending order, f=sortByfirstname in descending order.
    When the user runs the program and Enters the S for example then the list will be sorted by StudentNumber, the user can also pass a second parameter as tie breaker, for example SF or FS or SL, or even SFL, so in other words the program should dynamically cater for this sortOrder characters by the user.. Can anyone please just give me a tip on how i can implement this.

  • Distribution agent internal mechanism in sql server replication ?

    Hi All,
    Please explain the which stored procedures running internally ?
    Thanks in advance 
    RAM

    Read these
    http://blogs.msdn.com/b/chrissk/archive/2010/01/28/troubleshooting-transactional-replication-part-1.aspx
    http://blogs.msdn.com/b/chrissk/archive/2009/05/25/transactional-replication-conversations.aspx
    http://mssqlwiki.com/tag/transactional-replication-internals/
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • TestStand internal mechanism: call sequence/ architecture c++ code module adapter, .dll functions

    I would like to know more about this particular aspect of TestStand's architecture:
    What exactly happens "internally" (class/seq diagram ?)when a c/c++ dll code module adapter step invokes/ calls an exported .dll function (testStand sequence executed from sequenceEditor) ?
    My guess (wrong/correct ?) is that:
    I execute
    SeqEdit.exe
    which hosts
    teengn.dll
    which hosts
    cppAdp.dll
    which hosts
    "myDllWithExportedFunctions.dll"
    and (finally) directly calls exported functions of "myDllWithExportedFunctions.dll"

    Christoph -
    Your binary file presentation at a high level is correct.
    The object relationship is:
    - The Sequence Editor is just a client of the TestStand engine.
    - The Engine is the creator of all TestStand objects.
    - The Engine creates the Sequence File object for the Sequence Editor.
    - The Sequence File has a reference to a Sequence object, i.e. RunState.SequenceFile.Data.Seq["MainSequence"]
    - The Sequence has a reference to a Step object, i.e. RunState.SequenceFile.Data.Seq["MainSequence"].Main["Action"]
    - The Step has a Module object, i.e. RunState.SequenceFile.Data.Seq["MainSequence"].Main["Action"].TS.SData
    - The Module object uses its associated Adapter class to Load/Run code modules.
    - The DLL handle and function pointer are stored
    in the Module object.
    - The Module object with the Adapters help knows how to call the function in the DLL.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • How to set a selected checkbox in output internal table of oops ALV grid

    Hi All,
    i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command.
    i have given the below code also in fieldcatolg.
    f_fldcat-fieldname = 'checkbox'.
    f_fldcat-tabname ='gi_output'
    f_fldcat-checkbox = 'X'.
    f_fldcat-edit = 'X'.
    but the checkbox is not getting set in internal table when i select some checkboxes.
    can anybody explain y the checkbox in internal table not getting set?
    Thanks,
    Srilakshmi.

    Hi,
    i tried already whatever u said, but still not resolved.Pasted my code below..can u please look into it.
    MODULE pbo OUTPUT.
      PERFORM init_container.
      PERFORM prepare_field_catalog.
      PERFORM prepare_layout.
      PERFORM display_output.
    ENDMODULE.                 " PBO  OUTPUT
    *&      Module  PAI  INPUT
          text
    MODULE pai INPUT.
       DATA: lt_rows TYPE lvc_t_row.
      CASE gv_okcode.
        WHEN gc_exit OR gc_back OR gc_canc. " Finish program
          LEAVE PROGRAM.
          when 'PRINT'.
           CALL METHOD gv_grid->get_selected_rows
                     IMPORTING et_index_rows = lt_rows.
            CALL METHOD cl_gui_cfw=>flush.
      ENDCASE.
    ENDMODULE.                 " PAI  INPUT
    *&      Form  INIT_CONTAINER
          text
    FORM init_container .
      CREATE OBJECT gv_custom_container
        EXPORTING
          container_name = gc_container.
      CREATE OBJECT gv_grid
        EXPORTING
          i_parent = gv_custom_container.
      CREATE OBJECT gv_document
        EXPORTING
          style = 'ALV_GRID'.
    *&      Form  PREPARE_FIELD_CATALOG
          text
    FORM prepare_field_catalog .
      PERFORM fill_catalog USING:
    'Table Name'   'Field Name' 'NoZero'   'sel-text'
      'GI_OUTPUT'  'CHECKBOX'   ' '           text-013  'X',
      'GI_OUTPUT'  'KUNNR'      'X'           text-003  ' ',
      'GI_OUTPUT'  'NAME1'      ' '           text-004  ' ',
      'GI_OUTPUT'  'BELNR'      'X'           text-005  ' ',
      'GI_OUTPUT'  'BLART'      ' '           text-006  ' ',
      'GI_OUTPUT'  'BUDAT'      ' '           text-007  ' ',
      'GI_OUTPUT'  'BLDAT'      ' '           text-008  ' ',
      'GI_OUTPUT'  'DMBTR'      ' '           text-009  ' ',
      'GI_OUTPUT'  'WAERS'      ' '           text-010  ' '.
    ENDFORM.                    " PREPARE_FIELD_CATALOG
    *&      Form  FILL_CATALOG
          text
    FORM fill_catalog  USING    fv_tabname
                                fv_fldname
                                fv_nozero
                                fv_seltxt
                                fv_checkbox.
      DATA f_fldcat TYPE lvc_s_fcat.
      f_fldcat-fieldname     = fv_fldname.
      f_fldcat-tabname       = fv_tabname.
      f_fldcat-no_zero       = fv_nozero.
      f_fldcat-coltext       = fv_seltxt.
      f_fldcat-checkbox      = fv_checkbox.
      IF fv_checkbox = gc_x.
        f_fldcat-edit = gc_x.
      ENDIF.
      APPEND f_fldcat TO gi_fieldcat.
    ENDFORM.                    " FILL_CATALOG
    *&      Form  PREPARE_LAYOUT
          text
    FORM prepare_layout .
      gs_layout-info_fname = 'COL'.
      gs_layout-cwidth_opt = gc_x.
      gs_layout-zebra      = gc_x.
      gs_layout-no_toolbar = gc_x.
      gs_layout-no_rowmark = '1'.
      gs_layout-sel_mode = 'A'.
    ENDFORM.                    " PREPARE_LAYOUT
    *&      Form  DISPLAY_OUTPUT
          text
    FORM display_output .
      CALL METHOD gv_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_outtab       = gi_output
          it_fieldcatalog = gi_fieldcat.
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_user_command FOR gv_grid.
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = gv_grid.
    ENDFORM.                    " DISPLAY_OUTPUT

  • Why does Test-EcpConnectivity throws a warning regarding the internal URL property not being set, when in fact it is set?

    Hello,
    I have setup an Exchange 2013 CU6 environment which contains the following:
    1 machine with client access role
    3 machine with mailbox role
    1 machine with both client access and mailbox server role.
    When I run the Test-EcpConnectivity against the machine which has both roles I get the following:  
    WARNING: The test couldn't test the internal URL of this virtual directory, because the InternalURL property isn't set.
    But when I run "Get-EcpVirtualDirectory|fl" against the same machine, it shows that internal url property is set.
    Why is this happening and how can it be solved?

    Hi,
    The Test-OwaConnectivity cmdlet has been deprecated. It is recommended to use the
    Get-ServerHealth cmdlet to monitor server state.
    Regarding the parameter of Get-ServerHealth
    http://technet.microsoft.com/en-SG/library/jj218703(v=exchg.150).aspx
    Refer to this similar thread
    https://social.technet.microsoft.com/Forums/en-US/e952a854-647e-4f88-b54c-449c82c1c82e/testowaconnectivity-fails-cannot-find-internalurl-property?forum=exchangesvrdeploy
    Best Regrads.

Maybe you are looking for