How does new Comparator() work?

I have this code segment in my program. It works fine, but I don't know how exactly it works.
Collections.binarySearch(vertexList, new Integer(vertexID),
new Comparator() {
public int compare(Object obj, Object key) {
PDGVertex vertex = (PDGVertex)obj;
Integer vertexID = (Integer)key;
if (vertex.id < vertexID.intValue())
return -1;
else if (vertex.id > vertexID.intValue())
return 1;
else
return 0;
I know that Comparator() has two methods, compare() and equals(). But in the code segment above, I only implemented one, compare(), in the new Comparator() body. Don't I have to implement both of the two methods?
To test it, I wrote the following test program.
interface TestInter {
void tt();
void jj();
class Test {
static TestInter testInter = new TestInter() {public void tt() {System.out.println("In tt");}};
public static void main(String args[]) {
testInter.tt();
When I compiled it, I saw the following error message:
Test.java:7: <anonymous Test$1> is not abstract and does not override abstract method jj() in TestInter
static TestInter testInter = new TestInter() {public void tt() {System.out.println("In tt");}};
^
1 error
Any thoughts? Thanks.

The compare method is for comparing two objects of a particular type--two Employees, two Orders, whatever. That's the Comparator's reason to live.
The equals method is just like it is on any other object---it's to compare this Comparator to another Comparator. I believe the docs say that it's always safe to leave it as the default Object implementation which is true only if the two references point to the same Comparator object.
If you do decide to override it, it's so that you can determine that two Comparators will return the same results. I suppose you might want to do this if you know that two different implementations will return the same results (maybe the implement the same rules, but one is optimized for certain kinds of data and the other for other kinds) and you want to avoid repeating a sort that's already been done. For what it's worth, I've never needed to override equals on a Comparator.

Similar Messages

  • I wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support

    i wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support?

    basically I’m doing a project were I wanted to find out if there are recent technology  out that provides technical support for example they do it with remote access but is they any new ways that  they can support us and just wanted to find out if icloud gives technical support then how?

  • How does new Label Management feature works in Aruba Central?

    Q: How does new Label Management feature works in Aruba Central?
    A: Central provides a standard web-based interface that allows you to configure and monitor multiple Aruba Wi-Fi networks.  
    With as many as devices that central could manage, searching a specific device or set of devices becomes difficult. This is where "Label management" feature of Aruba Central helps out.
    With "Label Management", administrator can create various labels in advance and use them to assign it to different IAPs or Switches as required.  Once the labels are assigned, user can use the label string to search a device or group of devices in central.
    Follow these steps create various set of labels in "Label Management":
    Login to Aruba Central and click on "All Groups"
    In the left-menu, under "Maintenance" select "Label Management"
    Click on "Create Label" button and create as many labels you require as per the environment and ease of use.

    for rating . you need to enable rating from List options and choose if it's going to be 5 star or like 
    to add like button to each page in a publishing site you can use the below script 
    function LikePage() {
    var aContextObject = new SP.ClientContext.get_current();
    EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
    Microsoft.Office.Server.ReputationModel.
    Reputation.setLike(aContextObject, _spPageContextInfo.pageListId, _spPageContextInfo.pageItemId;, true);
    aContextObject.executeQueryAsync(
    function () {
    alert('you liked the page'); //here you can update the likes count of the page
    }, function (sender, args) {
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • Anybody use Word Perfect?  How does 'Pages' compare?

    For anyone who wants to cut to the quick, just read the question....the last paragraph.
    I need some comfort. It's probably normal to get frustrated with a new Word Processing program like 'Pages' after only 2 days of using it so I'm willing to be patient, but I have a general question, which actually appears in the Title of this post.
    I've used Word Perfect on my non-Mac computers for 20 years and although the program is without equal in it's sophistication and ease of use (IMO), I do believe it caused some big problems for other programs on my computer (incompatibility problems with other software). I've wanted an iMac for a long time just to get rid of all the problem I had with those other computers, thinking I'd be rid of WordPerfect, which I blamed for many of the problems. I wanted a fresh, clean start, so I sure don't want to mess up my 2 day-old iMac by loading up a word-processor like WordPerfect again....that'll just mess everything up again.
    But I have mixed emotions. After my past experience with Word Perfect, it's just hard for me to believe that the WP people actually got rid of all their bugs, and wouldn't inadvertently stick them all into an Apple product. I'm paranoid, I know. I'm asking this question because word-processing is the most important thing to me in using a computer and I found WordPerfect to be perfect, as a word-processor, that is.
    I'm certainly willing to give 'Pages' a fair try, and hope it works out for me. But, is there anyone here who uses WordPerfect on their Mac (and with which OS) and does it cause you any problems? Also, in your opinion how does it compare with 'Pages'?

    I was an avid WP user (DOS, AtariST, and Mac versions) for years and I was a beta tester for the Atari and Mac versions. I was never all that impressed with the Windows versions. When the program was sold to Novel support and quality became uneven and after Novel sold it to Corel, well, let's let sleeping dogs lie, eh?
    Pages isn't WP - it is a consumer word processor and desktop publishing program. Still it is quite powerful and easy to use...once you accept its conventions. That is a sticking point for a lot of people. With OS X, Apple has taken the toolbar and adapted it to its own purpose. Unlike some programs that attempt to put every command in toolbars, Apple prefers to target a smaller number and allow the user some ability to custom it. Apple has also adopted the idea of palettes - one palette actually. The inspector. In OS X the inspector is used to take commands that might be buried in the menu hierarchy and puts them out front. With Pages, like many OS X programs, getting to know the Inspector is key to using Pages.
    As I said, Pages isn't WP or MS Word. That's good and bad. The good is that the program is cleaner and easier to learn. It also means that lots of features you might consider important are missing. You should have a demo version of iWork on your new iMac and you have 30 days to use it before you have to decide to keep it or ditch it.

  • How does Muse compare to Apple's iWeb?

    I just heard about Muse.
    How does Muse compare to Apple's iWeb?
    Is it a similar type of user experience?
    Is it more or less versitile?

    I just migrated from iWeb to Muse.
    I've run my very small but well-established business in iWeb for almost 5 years and I was so sad to see Apple cut off iWeb. It worked super-well for my needs.
    I looked around and chose Muse because I could build what I wanted without being hemmed in by a template. In every other program I tried I either had to live life in a template or know how to code. I just wanted mine to be a simple straight-forward website that harmonized with my content. My followers don't need or want or like a lot of bells and whistles, they are interested in my content and in ease of navigating around.
    I moved my iWeb site from mobileme to another server about 3 months ago and then two days ago began moving into my new Muse site.
    In the last couple of days I have had about 600 or so of my followers find Muse and many have written to say they like my new site, that it loads fast for them and (as I suspected) they like that it is simple and easy to use.
    Mind you, I have a TON of work to do before my move is complete, but so far it is all I hoped it would be. I wish it had a couple of features more (such as a way to collapse and store pages when I'm not working on them) but I'm hoping they'll come in the future.
    Do I miss iWeb? Yes, because I knew how to run it so well and easily, but for my level of web participation Muse is a good replacement.
    Hope this helps.

  • How does SAPscript 'WRITE_FORM' works ?

    Hi
    I have a Z program working fine, it is a SAPM07DR copy and i aggregated some fields to WASCHEIN form.
    But i see when the program (standard or copy) calls the write form, the field values in program have other values (just the previous values) than the values wich appears in the printed form.
    For example: 
    WASCHEIN KOPF Window has the WERKS value:
             Plant:    &*T001W-WERKS&
    But when the write form is called
              CALL FUNCTION 'WRITE_FORM'
                EXPORTING ELEMENT = 'KOPF'
                WINDOW            = 'KOPF'.
    In the program the *T001W-WERKS field has a different value that the value wich appears in the spool, debugging i see that the field has the prevoius value in the program:
    Program
    *T001W-WERKS
    (when Write Form).............Spool
        '     '...................................Plant:  0900
        '0900'.............................Plant:  0901
    I had to do the same logic in my new aggregated fields, but i realy don't know why does the program works in this way.
    Why the print program and sapscript function works in this way ?
    How does WRITE-FORM works, that is where the function take from the values to print ?
    Thanks
    Frank

    Hi Max
    I hope the program works like you said, but it works:
    old_werks = '   '
    T001W-WERKS = '0900'.
    *T001W-WERKS = T001W-WERKS .
    *T001W-WERKS = old_werks.    <-- '   '
    CALL FUNCTION 'WRITE_FORM'
    (form KOPF with *T001W-WERKS)
    old_werks = '0900'
    T001W-WERKS = '0901'.
    *T001W-WERKS = T001W-WERKS .
    *T001W-WERKS = old_werks.    <--  '0900'
    CALL FUNCTION 'WRITE_FORM' 
    (form with *T001W-WERKS)
    But the FM prints 0900 and after 0901, when the *T001W-WERKS values were '    '  and  '0900'   !!!
    (and with the *T001W-NAME1 field occurs in the same way)
    Why does the FM prints that values ??
    Thanks
    Frank

  • How do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the onli

    how do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the online photoshop, and I really want to create my own customized url and post photos to my gallery and share them with the world, family, and friends, but i need help because i can't figure how to do any of this, would really appreciate feedback and assistance, thanks, - claire conlon

    To add to sig's reply, "calibrating" does not calibrate Lithiu-Ion batteries, it calibrates the charge reporting circuitry.  If you look at the effect of deep discharging Lithium-Ion batteries in the data from the independent test group, Battery University, you will see that doing so shortens the life of the battery significantly. It looks like an optimum balance between use and life is at a discharge level of 50%.

  • How does TimeOut(Sec) works/ behave in FTP Adapter?

    Hi ,
    How does TimeOut(Sec) works/ behave in FTP Adapter?
    Lets Say : If I mention 300 Secs in this . How Should it behave ??
    if a file processing in adapter is taking more then 300 sec , will it also be  terminated ??? what error response i will get in such case.
    Regards
    Prabhat Sharma.

    Hi,
    if there's a network error the channel may hang (for a very long time)
    if you specify 300 secs after that time the channel will reset the connection and you can start pooling again
    for more details:
    Note 849089 - XI 3.0 / PI 7.0 File Adapter: FTP Timeout Handling
    Regards,
    Michal Krawczyk

  • How does Blogger compare to iWeb 09, and starting tips?

    I've never had a blog site, but I would like to start one, with an 'About me', posts, and comment ability that I can handle. Some have recommended opening a free site with Blogger. Now that I have iWeb 09 (3.0.1, still unopened) and a MobileMe account, I'd like to ask:
    1) How does iWeb compare to Blogger (or any other blogging software)
    2) What should I know before starting a blog with iWeb?
    Best regards, Isshi.

    If you use one of the industrial strength blogging sites that have been suggested here you might be able to add it to an iWeb page using an HTML snippet and iFrame code as in this demo page: Embed One Site Within an iWeb Page.
    OT

  • How does Merged Dimensions Work in WebI created on SAP BI Queries

    Hi,
    I need to know how does Merge dimensions work in WebI when using SAP BI Query as source?
    Below is my understanding when connection is defined for the universe on oracle database:
    1) To get the data in merged dimensions, there must be physical join (Either Direct or vai some other tables) between different tables at backend level (This means  there  must be join between tables in Oracle database.)
    2) we get the UNION of data when dimensions are merged at webI level.
    I dont know how this works in SAP BI.
    Since there is different data model defined for different BI Queries in SAP , and for each BI Query and there is seperate Universe, So how can you get correct data in WebI when there is no connections in DSO's used in different BI queries?
    Can any one suggest me the way data apperas in merged dimensions for WebI created on SAP BI?

    I assume we are only talking about merging dimensions in Web Intelligence here and not on the BW backend. this is a client side mere where you have 2 resultsets.
    if you want to do this on the BI server side it would be a multi-provider combining different InfoProviders - or a InfoSet - depending on the join type you need. MultiProvider is a union, Infoset allows you to choose
    Ingo

  • Transfer Rules: How does the mapping work?

    Transfer Rules: How does the mapping work?
    Is there a document out there that explains the following or can someone help clarify it for me. I have some confusion on what is really going on.
    When I create an InfoSource (IS_Test)  as a “Flexible update…”  and then “Assign DataSource”  (DS_Test) and I respond Yes, to the message “DataSource assignment DS_Test to InfoSource IS_Test Save”
    a) <b>Under “Transfer_Structure/Transfer_Rules”</b> in the InfoSource
    1)  the “Transfer Rules” tab, what are the fields found in the right column (Assigned InfObjct-field)? And where do the fields you enter in the left column (<b>Communication Str/</b>Transfer rules) eventually go?
    2)  the “DataSource /Trans. Structure” tab, can I always assume that all the fields in the right column (DataSource) came from DS_Test? The left column (Transfer Structure), in my test was exactly the same as on the right. Where do these fields eventually go?
    b) Under “<b>Communication_Struct.”,</b> in the InfoSource
    3. the right column (ISource Fileds) where from those InfoObjects. if I am now creating my InfoSource. Where did they come from?
    4. The left column is “<b>Communication Structure</b>”, which at this point has no InfoObjects, if I move a couple of InfoObjects from the right to the left, where do these Objects in the left eventually go?
    5. what is the relationship between the “Communication Structure” in 4 and 1? Or any relationship between a) and b) as a whole?
    Thanks.

    Hi Caud,
    As Ashish pointed out, communication structure contains fields (infoobjects) that suppose to go to data targets. Which IO in CS to which IO in the data target will go (and what transformation of data may occur) is determined in URs of the data target.
    The transfer structure is the structure in which the data is transported from the source system into BW:
    http://help.sap.com/saphelp_bw33/helpdata/en/3f/0e503c3c0d563de10000000a114084/frameset.htm
    In “Transfer_Structure/Transfer_Rules” in the IS, DataSource /Trans. Structure” tab, right part shows fields in the Datasource, the left part – fields in the transfer structure. There is also a transfer structure in R/3 for a given DS. Transfer structure in BW is created identical to the TS in R/3 during TRs activation.
    During data load data are transferred 1:1 from TS in R/3 to TS in BW.
    TS in BW corresponds to the PSA table structure.
    How data from PSA are transferred to the CS is determined in TRs.   
    The 3rd column (“Field”) (“Transfer Rules” tab, right part (Assigned InfObjct-field)), contains field names of the DS (TS); and the 1st column shows IO in the CS to which the DS field will go. So, it’s a mapping DS filed -> CS field.
    The left part (“Communication str./Transfer rules”) is always identical to the CS content. But the 4th column (“Tp”) shows possible data transformation during transfer from PSA to CS. If this column contains a yellow triangle then there is no transformation (Value of DS field will go to value of CS field). If there is a red cross, it means that no data for this CS field is supplied from a DS. You can click on this yellow triangle and choose: 1). Another field from a DS; 2). Constant; 3). ABAP routine; 4). Formula. So, here you can determine the data transformation. Moreover, there is a possibility to create a start routine (blank sheet icon at the top).
    And finally, here are the answers on your questions:
    Q:
    a)     Under “Transfer_Structure/Transfer_Rules” in the InfoSource
    1) the “Transfer Rules” tab, what are the fields found in the right column (Assigned InfObjct-field)? And where do the fields you enter in the left column (Communication Str/Transfer rules) eventually go?
    A: Right part shows a mapping between DS and CS fields. Left part shows CS fields and data transformation (TRs) during data transfer from TS (PSA) to the CS. These are fields in the CS that will go to data target and which are fed from a TS (DS).
    Q: 2) the “DataSource /Trans. Structure” tab, can I always assume that all the fields in the right column (DataSource) came from DS_Test?
    A: Yes, you are right.
    Q: The left column (Transfer Structure), in my test was exactly the same as on the right. Where do these fields eventually go?
    A: As I described, left and right parts are identical. These fields will go to CS.
    Q: b) Under “Communication_Struct.”, in the InfoSource
    3. the right column (ISource Fileds) where from those InfoObjects. if I am now creating my InfoSource. Where did they come from?
    A: these are fields from an IS template, the name of this template you can see above this right part.  Actually, during IS (CS) creation you can choose different templates and choose fields from them transferring them into the left part.
    Q: 4. The left column is “Communication Structure”, which at this point has no InfoObjects, if I move a couple of InfoObjects from the right to the left, where do these Objects in the left eventually go?
    A: these are fields of CS (left part) and as I said before they will go to data target.
    Q: 5. what is the relationship between the “Communication Structure” in 4 and 1? Or any relationship between a) and b) as a whole?
    A: CS in 4 just shows IOs that will be transferred to data target. CS in 1 also shows how values for CS IOs are to be fed and transformed.
    Best regards,
    Eugene
    Message was edited by: Eugene Khusainov

  • KPI -How does the periodicity works in SM

    Periodicity is @ Context level only? That means we have to define different contexts for weekly &monthly? That doesnu2019t fly good
    How does the periodicity works in SM..data entry as well as frontend display?

    Hi TR,
    When looking at a scorecard, you should see the status for all objectives and KPIs during the same time period. If you look at Revenue KPIs for just one week and Cost KPIs for the whole month, how can you assess how you performed in that month?
    This doesn't mean that the metrics in PAS cannot have different periodicities. They can! But when looking at data in the scorecard these periodicities will be converted to the scorecard periodicity. For example if you have monthly metrics and you are looking at scorecard data quarterly, the scorecard will show you the value for the 3 months of that quarter. Here, you should take care to define the proper time consolidation properties for the metric (it can be SUM, like in costs or revenue, AVERAGE, LAST, FIRST...).
    Likewise, if you have quarterly metrics and you want to see scorecard data monthly, then PAS does a breakdown of the value per months.
    Anyway, if you are looking to setup a weekly scorecard, that will likely include a different set of metrics that a monthly scorecard would. Weekly scorecards will problably include more operational metrics and will lack the strategic focus of scorecards with a broader time scope.
    Regards!
    Ricardo

  • How does SUM actually works

    Hi,
    I'm puzzled by how SUM actually works.
    I've got a table with the following fields:
    SET_OF_BOOKS_ID NOT NULL NUMBER(15)
    SUMMARY_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    DETAIL_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    TEMPLATE_ID NOT NULL NUMBER(15)
    LAST_UPDATED_BY NOT NULL NUMBER(15)
    LAST_UPDATE_DATE NOT NULL DATE
    ORDERING_VALUE NOT NULL VARCHAR2(25)
    Using the below, I was able to get the total value of all the ordering value.
    select sum(ordering_value) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I was happy that I could get the total value but am puzzled as ordering value is of data type VARCHAR2.
    Is sum(ordering_value) a VARCHAR2 or a NUMBER then?
    I did a simple test, inserting the following record:
    insert into gl_account_hierarchies values(1,1024,1,2,3,'11-APR-2002','xyz');
    After committing, I double check by using the following statement:
    select * from gl_account_hierarchies where last_update_date = '11-APR-2002';
    and was able to retrieve the newly inserted record.
    But when I did another check with the following statement:
    select * from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I wasn't able to retrieve the newly inserted record.
    Why is that so? How does SUM actually works? Is the output of SUM a VARCHAR2 or NUMBERIC value?
    thanks in advance!!
    Yu S.S

    SUM() gives a number.
    What you have come across is an implicit data conversion. Basically the SQL parser doesn't reject your query as being syntactically invalid just because you're attempting a mathematical function on a non-numeric column. Instead when you execute your query SQL substitutes this
    select sum(to_number(ordering_value)) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    If you want to check this create a view
    create order_value as select sum(ordering_value) sum_val from gl_account_hierarchies ;
    and then desc it.
    Cheers, APC
    SUM(

  • How does request.setAttribute() works?

    How does request.setAttribute() works?
              Does it append data to http header and forward? Does it set to a memory
              space like session.setAttribute() does?
              Thank you
              Jim
              

              Q. Does it append data to http header and forward?
              No.
              Q. Does it set to a memory space like session.setAttribute() does?
              Yes. So you can set attributes in request scope and use them in the servlets and
              JSPs in the servlet chain via request dispatcher and jsp:include/jsp:forward.
              "Jim" <[email protected]> wrote:
              >How does request.setAttribute() works?
              >Does it append data to http header and forward? Does it set to a memory
              >space like session.setAttribute() does?
              >
              >Thank you
              >Jim
              >
              >
              

  • How does chat applet works?

    how does chat applet works? What specific technologies should i learn to make a chat messaging work?
    thanks in advance for ur help...

    Chat applets work on sockets. Normally there are two parts. One server and one or more clients. The clients connect to the server and any message sent by a client is then distributed by the server to all the other clients.
    Sun's site is incredibly slow tonite so I'll give you a google link
    http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=chatserver+chatclient+java

Maybe you are looking for

  • Budget Query

    I have created 1 PO  on 26.04.2007 i.e.last year.GRN & Invoices have also been prepared. Due to some reasons PO was blocked.Now if am trying to unblock the same PO,I am getting an error message as "Item 010 Fund Centre/commitment item/payment budget

  • Debugging a Transformation

    Greetings to All,      Does anyone know how to run a BW 7.0 transformation through a debugger?       Here's the situation:      I have a transformation with an InfoSet as its source and a cube as its target. When I run the transformation in dev, it c

  • How can I reactivate my phone if I cannot find the person who originally had the phone

    How can I reactivate my phone if I cannot find the person who originally had the phone

  • What was changed in 10.5.6 networking?

    Does anyone know what was changed in OS 10.5.6 networking that would cause all of these problems interfacing with windows?

  • Security Update 2007-008 (10.3.9 Client) went badly!

    Auto updated the Security Update 2007-008 (10.3.9 Client) now my Power PC G4 won't start anymore. It's stuck on "Waiting for Apple File Service" at the startup window. I really don't want to reinstall the whole OS right now.