Stack implementation peforming badly.

I have a lot of data points (x and y co-ordinates) which will be added to a stack and popped off as necessary.
Initially i implemented the stack using an ArrayList however when profiling my program i have found that the 'new' operation involved when adding an element to the stack was my program's bottle-neck. So i implemented my own stack based on two integer arrays.
I thought that this would be much faster as there was no creation of new objects, however this was not the case... infact it performed almost ten times as worse then before.
Is there something inherently slow/incorrect with my stack implementation?
code is as follows:
     class MyStack
          int[] x;
          int[] y;
          int index;
          public MyStack()
               x= new int[1024];
               y= new int[1024];
               index=0;
          public int size()
               return index;
          public void add(int x1,int y1)
               if (index==x.length)
                    int[] temp= new int[2*x.length];
                    System.arraycopy(x,0,temp,0,x.length);
                    x=temp;
                    temp= new int[2*y.length];
                    System.arraycopy(y,0,temp,0,y.length);
                    y=temp;
               x[index]=x1;
               y[index]=y1;
               index++;
          public int getX()
               return x[index-1];
          public int getY()
               return y[index-1];
          public void remove()
               index--;
     }

Is this viable? as the stack is not firstly popluated
before pop operations are peformed, i.e. push and pop
operations can and do happen at any time. This would
mean that the timing of the stack until it reaches
"steady-state" will be by its nature much more than
the push and pops after.Yes it would, but then you will get a feeling for what takes time in your stack, internal restructuring or the actual stack operation. You can make an artificial test. First make N (quite large) pushes, so the stack grows, and time that, then make the same number of alternating push/pop operations, so the size won't change, and time that. The difference basically is the internal restructuring of the stack.
I'd say this will show that the second phase has become much faster now that you don't have to do create two new Integer objects for each push. If you can anticipate the stack-size you should make it that big from the start.

Similar Messages

  • Need help on implementing the BADI ME_GUI_PO_CUST

    Hi All,
    As per my requirement I need to do Enhancement for Unloading point field on PO.This filed will get all the department numbers applicable for the site on the line item.
    For this I need to Implement the BADI BADI ME_GUI_PO_CUST.
    The Method which needs to be Implemented is : TRANSPORT_TO_DYNP.
    Instructions have been given for the Screen design.
    Can anyone help me (with the sample code how) to Implement this method of the BADI in SE19.
    This BADI method is taking a view as an Input and I am not understanding how to proceed.
    Thanks and Regards,
    Smriti Singh

    Hi,
    my suggestion is to check the standard documentation of the interface IF_EX_ME_GUI_PO_CUST.
    After that you can check the method IF_EX_ME_GUI_PO_CUST~TRANSPORT_TO_DYNP in the example implementation class CL_EXM_IM_ME_GUI_PO_CUST.
    Usefull links:
    [Re: Implementing badi ME_GUI_PO_CUST;
    [Re: ME21N - PO Enhancement using BADI;
    Kind Regards.
    Andrea

  • Problem in Implementing Filter BADI

    Hi Experts ,
               I have a problem in Implementing Standard BADI  OIJ_NOMIT_VALIDATION , this one is a Filter BADI , with Filter type OIJ_NOMITEM_CHCK . i created a implementation ZOIJ_NOMIT_VALIDATION with filter ZOIJ_NOMIT and write code in method VALIDATE . But this is not triggered. Any additional configuration needed for this ?
    Point will be awarded .
    Thanks and regards
    Renjith MP

    Hi Ranjit,
                  After implementing the Filter BADI.You can define the Filter type <b>attributes</b> section.
    Regards

  • How to Implement Screen BADI

    Dear All,
    Can any one help me in providing step by step procedure to implement SCREEN BADI. Kinly provide workable code
    Thanks in advance

    John
    I dont think any BADI available to change the logo.
    You can add your own logo to the login page as below.
    1. In SE80 select Internet service and choose BBPGLOBAL.
    2. Then navigate to Theme 99-->MIME Objects -->Images --> Start.
    3. Add your custom logo file there.
    4. Then navigate to Theme 99 --> HTML Templates --> Login.
    5. Open the source code of Login page and search for the logo which you want to replace with your new logo. ex. ~name="images/start/logo.gif". Look for suitable code where you want to add your logo.
    6. Comment that line and add new line with your new logo file in the image path.
    With this custom logo get displayed in the login page.
    PS : Reward points if helpful.
    Regards
    Jagadish

  • Implementation of BADI BBP_ECS_PO_OUT_BADI in SRM. and BBP_PO_INBOUND_BADI

    Hi All,
    Facing a problem in BADI can u please help me out...
    I am implementing sourcing dashboard.
    I am facing problem while implementing the badi BBP_ECS_PO_OUT_BADI in SRM. and BBP_PO_INBOUND_BADI in R3.
    i have written following code in BBP_ECS_PO_OUT_BADI in SRM
    method IF_EX_BBP_ECS_PO_OUT_BADI~BBP_B46B_PO_OUTBOUND.
    data : ls_item type BBP_PDS_PO_ITEM_D.
    data : w_customer_fields type BBPS_IF_CUSTOMER_FIELDS_PI.
    move 'POITEM' to w_customer_fields-refobject.
    move 'CATALOGID' to w_customer_fields-fieldname.
    move ls_item-catalogid to w_customer_fields-container.
    append w_customer_fields to ct_bapi_customer_fields.
    endmethod.
    i have created field zsrmcatalogid field in R3 in EKPO table.and i am now implementing the Badi in R3 for BBP_PO_INBOUND_BADI .....in extended classic scenario.
    i have written following code in R3 BADI
    method IF_EX_BBP_PO_INBOUND_BADI~BBP_MAP_BEFORE_BAPI.
    data : wa_customer_fields type bbps_if_customer_fields,
    wa_bapi_te_mepoitem type bapi_te_mepoitem,
    wa_bapi_te_mepoitemx type bapi_te_mepoitemx,
    wa_extensionin type bapiparex.
    data : txt_960(960) type c.
    read table bbp_customer_fields into wa_customer_fields with key
    refobject = 'POITEM' fieldname = 'CATALOGID'.
    if sy-subrc eq 0.
    move wa_customer_fields-container TO
    wa_bapi_te_mepoitem-zsrmcatalogid.
    wa_bapi_te_mepoitemx-zsrmcatalogid = 'X'.
    endif.
    clear txt_960.
    clear wa_extensionin.
    write wa_bapi_te_mepoitem to txt_960 left-justified.
    wa_extensionin-structure = 'BAPI_TE_MEPOITEM'.
    wa_extensionin-valuepart1 = txt_960(240).
    wa_extensionin-valuepart2 = txt_960+240(240).
    wa_extensionin-valuepart3 = txt_960+480(240).
    wa_extensionin-valuepart4 = txt_960+720(240).
    append wa_extensionin to bapi_extensionin.
    clear txt_960.
    clear wa_extensionin.
    write wa_bapi_te_mepoitemx to txt_960 left-justified.
    wa_extensionin-structure = 'BAPI_TE_MEPOITEMX'.
    wa_extensionin-valuepart1 = txt_960(240).
    wa_extensionin-valuepart2 = txt_960+240(240).
    wa_extensionin-valuepart3 = txt_960+480(240).
    wa_extensionin-valuepart4 = txt_960+720(240).
    append wa_extensionin to bapi_extensionin.
    endmethod.
    But its not working...
    The PO details are not passed from SRM to R3.......
    Can anybody help me regarding how to debug the BADI in R3.
    Thanks in Advance...

    Hi Ravi,
    I never tried those BADIs to pass CUF fields.
    But here an attempt to understand it.
    First, have you maintained the mandatory R/3 CUF mapping table BBP_CUFMAP ?
    Your SRM BADI is not correct, because you don't populate enough data.
    There is a particular logic for ct_bapi_customer_fields (look at R/3 mapping in LBBP_BAPI_POF04, called before the R/3 BADI).
    Following fields must be populated:
    - REFOBJECT: ok with POITEM
    - FIELDNAME: dummy name (CATALOGID) or real R/3 field (zsrmcatalogid)? --> used in mapping table BBP_CUFMAP to get the R/3 field
    - REFFIELD1: missing: put PO_ITEM ?
    - REFVAL1  : missing: put the PO item number (numc 5)
    - CONTAINER: ok with final value we want to pass
    I think that if SRM BADI and the R/3 mapping table are populated correctly, the fields are transfered to R/3 PO item without additionnal coding on R/3 BADI side.
    The R/3 BADI goal is not to create BAPI_EXTENSIONIN. This is done by the Form MAPPING_CUSTOMER_FIELDS of include LBBP_BAPI_POF04.
    Later on, the custom fields of BAPI_EXTENSIONIN are transfered automatically to EKPO fields via a move-corresponding.
    In the way you coded R/3 BADI, you by-pass the Form MAPPING_CUSTOMER_FIELDS, to populate the BAPI_EXTENSIONIN by yourself.
    This could work like this, but you missed one info: the PO item number (missing in SRM BADI) !!!
    For debugging, what additional details do yo need ?
    Rgds
    Christophe

  • Error in private methods when implementing a BAdI

    Hi,
    I implemented a BAdI and added some custom private methods in my implementing class. When I looked at the object list, my private methods are marked with a color red circular shape, which I guess it means those have error. But, when I tried to activate and test the BAdI, it works fine. Any idea why it marks my private methods as error? Am I missing something here?

    it denotes Accessibility / Visibility of those  methods .
    regards
    Prabhu

  • How to create implementation for BADI BADI_SD_SALES_ITEM

    Hi all,
    When i try to create a implementation for BADI it erorrs out saying "its for intenal use". Is there any way i can still go ahead and create a implementation for this BADI BADI_SD_SALES_ITEM.
    Thanks in advance.

    Hello Jayakumar,
    The BADI <b>BADI_SD_SALES_ITEM</b> is designed as internal BADI; the implementation can only be done, if the BADI is set to external.  The property of a BADI is stored in the table <b>sxs_attr</b>. The flag <b>internal</b> must be cleared to use the BADI as external. The following short program will show you an example:
    report  z_xpra_upd_badi_def.
    data: gt_prot          type table of sprot_u,
          gs_prot          type sprot_u,
          gv_simulate      type xflag.
    * Constant Definitions for Protocoll:
    constants:
          gc_error_fatal   value 'E',      " Error message with stop_upgrade
          gc_error         value 'P',      " Error message: no prod use!
          gc_success       value space,    " Success
          gc_info          value space,    " Info
          gc_warning       value 'W',      " Warning
          gc_lv_error      type n value 2, " Level for type 'E'
          gc_lv_add_error  type n value 2, " Level for additional info
          gc_lv_warning    type n value 2, " This could be either 2 or 3
          gc_lv_success    type n value 3, " Success only at 3
          gc_lv_info       type n value 4, " Info-messages only at 3 or 4
          gc_lv_debug      type n value 4. " Additional info for yourself
    start-of-selection.
      gv_simulate = space.
      perform bc_action using 'BADI_SD_SALES_ITEM'
                               gv_simulate.
    * Finally, the transport protocol will be added:
      call function 'TR_APPEND_LOG'
        tables
          xmsg   = gt_prot
        exceptions
          others = 5.
      call function 'TR_FLUSH_LOG'.
    * END OF PROGRAM
    *&      Form  bc_action
    *       Function description/flow
    *       Used global variables:
    *       Read/Write
    form bc_action using li_badi_def   type sxs_attr-exit_name
                         li_simulate   type xflag.
      data: ls_sxs_attr type sxs_attr.
      select single * into ls_sxs_attr
             from sxs_attr client specified
             where exit_name = li_badi_def.
      if sy-subrc = 0.
        if not ls_sxs_attr-internal is initial.
          if gv_simulate is initial.
            clear ls_sxs_attr-internal.
            update sxs_attr client specified
            from ls_sxs_attr.
          endif.
          if sy-subrc = 0.
            perform bc_append_log using gc_lv_success
                                        gc_success
                                       '5@'
                                       '000'
                                        li_badi_def
                                        text-001
                                        sy-dbcnt
                                        space.
          else.
            perform bc_append_log using gc_lv_error
                                        gc_error
                                       '5@'
                                       '000'
                                        li_badi_def
                                        text-002
                                        sy-subrc
                                        space.
          endif.
        else.
          perform bc_append_log using gc_lv_success
                                      gc_success
                                     '5@'
                                     '000'
                                      li_badi_def
                                      text-003
                                      space
                                      space.
        endif.
      else.
        perform bc_append_log using gc_lv_success
                                    gc_success
                                   '5@'
                                   '000'
                                    li_badi_def
                                    text-004
                                    space
                                    space.
      endif.
    endform.                    "ACTION
    *&      Form  bc_append_log
    *       Function description/flow
    *       Used global variables:
    *       Read/Write
    form bc_append_log using li_level    type sprot_u-level    " Level
                             li_severity type sprot_u-severity " Severity
                             li_ag       type sprot_u-ag       " Message-ID
                             li_msgnr    type sprot_u-msgnr    " Messagenumb
                             li_var1
                             li_var2
                             li_var3
                             li_var4.
      clear gs_prot.
      gs_prot-level    = li_level.
      gs_prot-severity = li_severity.
      gs_prot-langu    = sy-langu.
      gs_prot-ag       = li_ag.
      gs_prot-msgnr    = li_msgnr.
      gs_prot-newobj   = space.
      gs_prot-var1     = li_var1.
      gs_prot-var2     = li_var2.
      gs_prot-var3     = li_var3.
      gs_prot-var4     = li_var4.
      append gs_prot to gt_prot.
    endform.                    " bc_bc_append_log
    This report can be used as <b>XPRA</b> run; for this you need to assign this report in a transport with property object type <b>XPRA</b>. After importing the transport the report will be started automatically.
    Please handle this proposal solution carefully.
    Best regards,
    Kurt.

  • Issues while creating implementation for BADI  "ME_PROCESS_PO_CUST"

    Hi Group,
    I have issues while creating implementation for  BADI "ME_PROCESS_PO_CUST".
    I tried to create implementation for the above mentioned BADI but, I was getting an error like this:
    "Interface implementation IF_EX_ME_PROCESS_PO_CUST does not exist".
    I want to implement this BADI and so, ideas/views at the earliest will be appreciated.
    Please let me know how to overcome this error.
    Thanks,
    Vishnu.

    Hi,
    Have you activated the class which is implementing the interface? (in transaction SE19 you should see class name)
    Best regards,
    Wojciech

  • Check active implementation in badi

    Hi Expert,
    Pl's let me know how to I check active implementation in badi in ECC6.0.
    I have tried to find the solution by using  call function 'SXC_EXIT_CHECK_ACTIVE' , as used in previous version of the server.
    But this is not helping me out.
    Kindly let me know if there exists a way to check the active implementations in badi.
    Tx
    Kshitija

    Can you not do this from SE19?  If you know the BADI definition name just do an F4 on the implementation, and put in the definition name, and select Active Only option, and you should see the list.
    Albert

  • Implementing INVOICE_UPDATE badi

    Hello,
    I have to implement INVOICE_UPDATE badi for tranzaction MIRO in order to prevent posting an invoice in certain conditions. So, I will use the method CHANGE_BEFORE_UPDATE, I do my check, but how can I prevent the posting? What statement to use in order that the user to be informed that that specific invoice cannot be posted?
    Thank you!

    Hello Marian
    I am not sure if method CHANGE_BEFORE_UPDATE is the right one because it does contain neither an "error flag" parameter nor an exception.
    I assume that method <b>CHANGE_AT_SAVE</b> will be more useful to you because it has an exception (<b>ERROR_WITH_MESSAGE</b>) that you can raise.
    Regards
      Uwe

  • Implementation for BADI - /SAPAPO/ADVX

    Hi,
    I have created and activated an implementation for the BADI /SAPAPO/ADVX for the method USER_EXIT_MACRO. But this implementation is not triggering when i execute a macro in Transaction /SAPAPO/SDP94. Could you please let me know how to achieve this? (I am implementing this BADI to display the Units in SUOM instead of Base UOM).
    Do we have any other BADI for changing the stock from UOM to SUOM?
    Thanks,
    Rajinikanth

    Hello Experts,
             I have created one Z class in which i am using the methods of BADI /sapapo/advx , i have hard coded my macro id ,layout id and view id so that it will execute my code on execution of that particular macro.now my problem is how to read the data for particular keyfigure from the internal tables of this interface.i am not getting how to read te data and process it.
    please help me on this.
    Regards,
    Saurabh Kulkarni

  • Error in jsr180 sip stack implementation in WTK2.5.2?

    Hi,
    I encountered error in the SIP stack implementation used in the WTK2.5.2.
    When I create a SIP message and fill all the header and add to the request a Route header
    when the created message is sent to the next hop it is send according to the Request URI
    value but not the Route header.
    I try to register my application and force SIP proxy by inserting Route header.
    This done according to RFC 3261 where Route header forces the sip transation to
    forwarded according to the 'highest' value.
    Waiting for Your feedback
    Kind regards
    Tomasz

    I am having exactly the same problem!!!!
    In fact I developed days ago an application with SUBSCRIBE and NOTIFY messages, with the J2ME client as the receiver of NOTIFY requests... the requests arrived, but the responses, once sent, never get to the NOTIFY sender.
    I asked this same question in the following forum:
    http://forum.java.sun.com/forum.jspa?forumID=82
    but at this moment nobody replies...
    Today I was checking the SIPDemo implementation in SWTK2.5, and what was my surprise when I worked out that the implementation gave the same problem... I have tried several settings modifications in the SWTK preferences and settings, but no success.
    Please, is anybody aware of how to resolve this problem??, I really need the answer.
    Ashgar... do you know where can the problem be??

  • Solman configuration before new SP stack implementation

    Hello!
    Solman SP Stack was updated to 18 (without configuration).
    Need I configure SolMan before new stack implementation? Could I do it after import?
    I used solman maintenance optimizer earlier to approve support packages...
    regards,
    Tonya

    You can configure before or after - just make sure that any transports that you create when doing your configuration are released prior to doing the EhP1 Upgrade and you shouldn't have any problems.

  • Implementing a BADI user exit

    Hi
    I am totally new to BADI's. Now I have a specific requirement in which I need to implement BADI User Exit /SAPAPO/PPM_CALC. Method  =  CALC_BUCKET_CONS. 
    In the User Exit, remove the Splits from the PP/DS Model when the conversion to the SNP Model occurs
    Can you please guide me how to proceed briefly.. points for all helpful answers

    Hi
    Following Steps:
    1. Execute Business Add-In(BADI) transaction SE18
    2. Enter BADI name i.e. BADI_MATERIAL_CHECK and press the display
    button
    3. Select menu option Implementation->Create
    4. Give implementation a name such as Z_BADI_MATERIAL_CHECK
    5. You can now make any changes you require to the BADI within this
    implementation, for example choose the Interface tab
    6. Double click on the method you want to change, you can now enter
    any code you require.
    7. Please note to find out what import and export parameters a
    method has got return the original BADI definition
    (i.e. BADI_MATERIAL_CHECK) and double click on the method name
    for example within BADI_MATERIAL_CHECK contract is a method
    8. When changes have been made activate the implementation
    Some useful URL
    http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    <b>good link to understand and work</b>
    http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    Badihttp://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
    http://support.sas.com/rnd/papers/sugi30/SAP.ppt
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
    http://members.aol.com/_ht_a/skarkada/sap/
    http://www.ct-software.com/reportpool_frame.htm
    http://www.saphelp.com/SAP_Technical.htm
    http://www.kabai.com/abaps/q.htm
    http://www.guidancetech.com/people/holland/sap/abap/
    http://www.planetsap.com/download_abap_programs.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
    /people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series
    /people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework
    http://esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    http://esnips.com/doc/365d4c4d-9fcb-4189-85fd-866b7bf25257/customer-exits--badi.zip
    http://esnips.com/doc/3b7bbc09-c095-45a0-9e89-91f2f86ee8e9/BADI-Introduction.ppt
    http://help.sap.com//saphelp_470/helpdata/EN/eb/3e7cee940e11d295df0000e82de14a/frameset.htm
    check this links are u can easily to work .............
    look second highlighted document is good.
    if its useful reward me .
    thanks
    suresh

  • Difference between Enhancement Implementation and BadI Implementation

    What is the difference between Enhancement Implementation and BadI Implementation?

    Hi Rajendra Prasad,
    Enhancement spot : It is the point where you can add your code. It can have multiple implementations. All the implementations can active at a time but the sequence of executions of the implementations can be anything.
    (or)
    Enhancement points are regions where can insert our code to suit customer needs...Spots are subsets of points and created inside these points..for an enhancement point multiple active spots can exist.
    For enhacement-sections : the main idea is to provide a spot to customise the existing process..eg:SAP has done a select criteria..but you need to filter it more by adding a where condition..in that case SAP suggests using Enhancement sections..At any time the first active enhancement section works...even if multiple sections are created(though ideally multiple sections are not allowed to be created)..if you do the procedure below you can see that enhancement-section when a spot is created for it...the code in the parent section is copied and given in the editable mode
    Creating spots implementations for points/sections are given below................................................................
    to Create a spot in the standard code...click on the spiral icon..screen changes to a different color...place cursor on ENHANCEMENT-POINT/ENHANCEMENT-SECTION keyword of the spot you require to create implementation for...righ click -> "enhancement implementation -> "create" -> a table control comes -> at the bottom "CREATE" button to be clicked" ...give a name and text in customer name space and save -> select the same name just given in the table control ..press 'Tick' .....you will get a space where code can be written..write the code.....save and activate
    Also check the following blogs on enhancement framework
    /people/thomas.weiss/blog/2006/01/24/what-the-new-enhancement-framework-is-for-150-its-basic-structure-and-elements-for-beginners
    The new Enhancement Framework Part 2 - What Else You Need to Know Before Building an Enhancement
    How To Define a New BAdI Within the Enhancement Framework - Part 3 of the Series
    How to implement a BAdI And How to Use a Filter - Part 4 of the Series on the New Enhancement Framework
    Source Code Enhancements - Part 5 of the Series on the New Enhancement Framework
    Please go through this link also.
    implicit enhancement and explicit enhancement
    Reward points if it helps you
    Cheers,
    Swamy Kunche

Maybe you are looking for