Query about decrementing a variable.

Hi, all:
I'm writing an agent-based model about battlefield strategies. There's a previous model I'm working off of, which contains a bit of code that I don't understand. It's a hack to remove an element from an arraylist, and I don't think I understand it very well. My model works just fine, but I don't like not understanding WHY this bit of code works the way that it does. I've read tutorials about incrementing/decrementing, but I still don't quite get what's going on here. The code is to remove instances of the Soldier class that have "died" and whose unique identifiers have been added to an arraylist called "killEmAll" based on probabilities located elsewhere in the model. Here's the relevant loop:
          for (int j = 0; j < soldierList.size(); j++) {
               Soldier soldier = soldierList.get(j);
               solID = soldier.getID();
               if (killEmAll.contains(solID)) {
                    soldierList.remove(soldier);
                    --j;//this is kludgy. Why does it work?
                    world.putObjectAt( soldier.getX(), soldier.getY(), null );
          }What exactly is going on with that "--j" thing? Why does having it/not having it in the code result in different behavior in my model?

soldierList.remove(soldier);
This line removes an element from your list. So, now the size of the list is decremented by 1 and hence you decrement the value of 'j' also...
Otherwise, you will miss an element.
e.g. You have 10 soldiers in the list.
Now j=0; you take soldierList(0) and remove it. Now the element in soldierList(1) is moved up to 0th place. If you do not decrement 'j', in the next loop, j will become 1 and it will miss the 0th element in the list.... hope it helps...:)

Similar Messages

  • Web Template with Query Views not showing Variable Screen

    Hi, I have a Web Template using 3 Query Views based on a single query.  The Query has 2 mandatory variables (CALMONTH and VERSION).  When I execute the Web Template it does not prompt with the Variable Screen, and presents the report with the Variables that were in place when the view was saved/created.  I'd like the Variables to appear.
    1. Is this the correct behavior? 
    2. Is there any documentation that might describe this behavior.
    3. Should I just copy the query and create 3 queries instead?
    Note: I did a search in SDN and found lots of similar threads, but nothing exact.  Also, I know about forcing the variable screen, but I thought I shouldn't have to do this.
    Thanks!

    k forget the view, when you run the main query... do you get a pop up for variable screen,. yes or no?
    if you dont then try to run another query and see if you get the variable screen as well. if you dont then its a bug. if you do then something is wrong in your query and its having an issue, but if you do get the screen on your query then it is a setting in your web template not in your query.
    you can also try to run the query in RSRT backend ...

  • Can I put a SQL query into a bind variable and then use it to output report

    Hi,
    Can I put a SQL query into a bind variable and then use it to output report?
    I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
    select * from (:P1_TEXT);
    Do you think it is possible to do that? Any known limitations for APEX in this area?
    Thanks a lot,
    Angela

    You can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
    You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
    Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
    Tyler

  • Query about local storage

    Hi,
         i had a query about local storage.
         I've a machine that hosts weblogic and tangosol. i've an ejb that accesses a distributed cache i.e NamedCache cache = CacheFactory.get("MyCache")
         i modified tangosol-coherence.xml and set local-storage to false ( for distributed cache) and replaced the file in coherence.jar.
         i'm using an overflow scheme and the back map uses a disk scheme.
         i also start a separate standalone instance of tangosol and i set the system property of local storage to true for the standalone instance.
         i start the standalone instance first and then weblogic.
         The idea is ensure that the tangosol instance in weblogic or the weblogic JVM should not participate in storing data (hence local storage false).
         only the JVM for the standalone instance should store data (hence local storage true -system property).
         i wanted to know whether the property "local-storage" is pertinent to a member(machine) or to a JVM?
         the reason for this doubt: as i'm using a disk scheme, tangosol creates a file for an overflow (e.g lh014402~.tp). i can see two such files when ideally i would have wanted only one for the tangosol instance.
         -rw-r--r-- 1 zephyr users 8364032 2005-06-23 17:02 lh014402~.tp
         -rw-r--r-- 1 zephyr users 8364032 2005-06-23 17:02 lh014403~.tp.
         can you please let me know if we can configure tangosol in such a way that we can two separate instances running with local stroage false for one and true for the other?
         Awaiting your reply
         Thanks
         Vinay

    I would suggest leaving the default 'local-storage' value set to 'true' in the tangosol-coherence.xml and just use the JVM argument to control the local storage of each individual node. Then start the stand alone instance normally (I assume you are using the com.tangosol.net.DefaultCacheServer) and start the WebLogic instance with the following:
         java [...] -Dtangosol.coherence.distributed.localstorage=false [...]
         Hope this helps.
         Later,
         Rob Misek
         Tangosol, Inc.

  • Query output into ODI variable

    Hi,
    I want to take the output (multiple rows and multiple columns) into an ODI variable of Text type.
    I have created the variable and put the query and set the variable type as Text type. But when I send the value of this variable to other variable, it comes as blank.
    Can anyone tell me how can I do that
    Thanks in advance
    Arun

    Hello Neha,
    Though i have been working with APDs since some time. But havent actually been involved in designing one. But you could find many documents for the APD on web. And as far as i know, you will need a program to save file from APD.
    I have a document which explains how you can use APD in  process chain. can forward you the same if you want.
    I am sorry as i wasnt of much help for you, as i havent worked on similar requirement before, but this thing just striked in my mind.
    Regards,
    Anuj

  • Question about using constant variables in Forms

    As I am still very new to Forms, please forgive my ignorance if the answer to my question is very simple. I am trying to figure out how to use constant variables within my Forms application. For example, if I want to setup return code constants for the application (mind me, these are examples):
    RC_SUCCESS CONSTANT PLS_INTEGER := 1;
    RC_FAILURE CONSTANT PLS_INTEGER := 0;
    RC_YEAR_DATA_NOT_FOUND := 50;
    Then in a module I created, if I wanted to check the return code against one of the constants I would do:
    DECLARE
    rc PLS_INTEGER;
    BEGIN
    GET_YEAR_DATA('2000', rc);
    IF rc = RC_YEAR_DATA_NOT_FOUND THEN
    -- Do some error handling
    END IF;
    END;
    I know that you can declare constants within individual procedures or packages but I can't see to find information on how to do this globally for the application. I've read about using global variables within Forms but the CHAR data type only and the fact the value can be changed doesn't really fit for this purpose. Am I missing something? Is there a config file or something for the webserver that can be used to set these up??
    Any help would be appreciated.
    Thanks

    To declare constants create a Package-Specification in a pll and deifne all your constants there, something like:
    PACKAGE PK_CONSTANTS IS
      RC_SUCCESS CONSTANT PLS_INTEGER := 1;
      RC_FAILURE CONSTANT PLS_INTEGER := 0;
      RC_YEAR_DATA_NOT_FOUND := 50;
    END;Then attach that pll to all your forms-modules, and use it like
    IF rc = PK_CONSTANTS.RC_YEAR_DATA_NOT_FOUND THEN
    END IF;A word about exceptions or errors: In my eyes its clearer (and in case of exceptions even better) to raise an exception than to hide it behind return-codes.

  • Big Troubles on designing Query about special customers' counting

    Hello buddies:
    I meet a problem on designing Query about special customers' counting. Let me describe the requirment first.  I want to create a query with BEX , and there is a key figure with very special logic.
    That is: to list the counts of the customers which has more than one sales records in a time period from sales data. 
    For example :
    when the user excute the query , he or she must input a time period ( 2007.01~2007.03 e.g)
    then the query output as follow:
    District          Cust-sount
    North-Zone       100
    South-Zone      120
    The Main trouble are :
    1. Threr are no document number in the detail of sales data document records. so I could not count the sales times with document number.
    2. The time period is not fixed value, it depends on the user's input, so I can not define the counting logic in the update rule or in the query with fixed time period.
    Anybody who met similar requirement pls show me your hand and give your solutions, thanks very much.
    Jason

    Hi,
        Your solution sounds a good way to count the distinct customers. but in my case, one salse line item must not be recognize as one sales record, instead,  one customer's all sales line items occurs in one day must be  recognize as one sales record ( or we say that one sales behavior).
    for example:
    customer     product    quantity   date
    cust001       prod001        10       2007.06.06
    cust001       prod002        20       2007.06.06
    the two line items above means one sales record for the customer "cust001".
    so I could not simply use the CKF : (( Counter ) *FV2 ) > 1 .
    Best Regards,
    Jason

  • Query about licensing Jdeveloper

    Dear Friends,
    I have a query about licensing of Jdeveloper development tool. I understand that Jdeveloper is Free tool.That is we do not require license to use Jdeveloper for development as well as production.
    Recent I heard that Jdeveloper is free only if we purchase Oracle Application Server. Is it correct ? Does one need to purchase Jdeveloper license if it is being deployed on any other App. server eg. Jboss etc ?
    Can anyone throw light on the same ?
    Many thanks,
    Vaij

    Hi,
    JDeveloper is free! Oracle ADF - the binding layer - ADF BC, and ADF Faces need an OracleAs licence
    Frank

  • Crystal Reports with BEx Query using Custom Exit Variable

    Hi,
    We have BW BEx Query using Customer User Exit variable to derive  the Fiscal Week for Last Year (called it VAR2) based on another user input variable Current Fiscal Week (called it VAR1).
    VAR2 is derived from VAR1 in CMOD via some codings and thus it DOES NOT have the "Variable is Ready for Input" flag ticked in the BEx. VAR1 is user input variable, so it has "Variable is Ready for Input" flag ticked in the BEx.
    When we create a Crystal Reports with the BEx Query using variable VAR2, and when we run it we got an error message saying "Failed to execute query; '[]<java.lang.UnsupportedOperationException: No Selection State Support!ZP_MI_LYPUBWEEK>'. Redesign your query or contact the data source maintainer to solve the problem".  (note: ZP_MI_LYPUBWEEK is VAR2 in this case).
    Could anyone please assist? Surely, CR supports BEx customer user exit variables like the above, right?. I also refer to the forum below as it seems to have a similar issue (except mine with an error message), but it does not provide a solution in it.
    Crystal Reports with BEx Query using Custom Exit Variable
    Thanks,
    Andy

    Hi Vibhav,
    We have the SAP Crystal Reports for Enterprise XI4.0 Version 14.0.0. Not sure if SP0 or other SP, got to check with Basis Team later.
    We tried that "mandatory" option and did not work either.
    Anyway, SAP has now come back again saying it is something they will fix it in next release/version. We got a phone call from them and a reply below to our OSS.
    23.08.2011 - 08:20:49 CET - Info for Customer by SAP  
    I have raised this issue on the Idea#s Place as an enhancement request
    on the below link:
    https://cw.sdn.sap.com/cw/ideas/5586
    This ER contains the information of including the customer exit
    variables in the report without checking the #input for ready# option.
    This ER can be considered for being implemented in the future
    versions. You can refer to SAP Note: 1515837 - How To: Enhancement
    Request Process - "Idea Place" for more information regarding the Idea
    Place.
    Cheers,
    Andy

  • New issue in R 12.1.3 in AP while query about inovice was recorded in AP

    i record new invoice in ap on release R 12.1.3 and when query about it on invoice form the error appeare was it
    forms
    FRM-40735:POST-QUERY trigger raised unhandled exception ORA-04063
    how can someone help us

    Hi,
    Please see these docs.
    R12:Getting FRM-40735 Post-Query Trigger On Quering Invoice [ID 1209736.1]
    After Applying Patch APXINWKB.fmb Is Not Working [ID 1159124.1]
    R12.1.1 APXINWKB Invoice Workbench Form Comes Up With 'ORA-01403' [ID 949942.1]
    12.1.1: FRM-40735: Post-Query Trigger Raised Unhandled Exception ORA-04063 [ID 1077613.1]
    Query on Invoices, Getting "FRM-40735: POST-QUERY trigger raised unhandled exception ORA-4063" [ID 1076609.1]
    Thanks,
    Hussein

  • I have one query about table entries.

    i have one query about table entries.
    suppose  for particular table we maintained   5 entries in dev server. actaully in the dev we have only these 5 entries.
    In production we have 200 entries actually.
    If we move the cts from  dev  to production ,we will get 205 entries right
    please help me in this.

    If i understood correctly, It is a Z table and you have done some changes in DEV system. If you move this to Production, it wont effect the production entries.
    There are 2 different ways you can trnasport a Table. 1. with Table entries 2. Without table entries.
    If you transport with Table entries then the DEV entries in this case 5 will be moved to PRODUCTION totaling 205.
    If you transport without table entries, then in Production you will find only 200 entries.

  • Query about the DR -Standby

    Hi Support,
    I have a query about the DR -Standby:
    1) Is FAL_CLIENT and FAL_SERVER parameter mandatory in both Primary and standy node?
    2) How many standy by we can create for primary node?
    Thanks

    Dear Prashanth,
    Quantity of 3 is rejected so you blocked it? why you want to bring it again to Quality? Use of putting in block is as follows:
    Since quantity of 3  is rejected  and need to be kept aside you are blocking the stock, the purchase person will send back this material to vendor directly from block stock (MBRL or MIGO). This is best practice.
    There can be other situation that your vendor came to your place and done rework om that 3 blocked items and you are satisfied with the quality then you can use respective movement for transferring from block to unrestricted, if you want lot to be generated then assign 08 insp type and do inspection.
    Hope this will help you better.
    Best Regards,
    Shekhar

  • Query about the "User Decision

    Hi,
    I have a query about the u201CUser Decisionu201D, Suppose I have received the 10 quantity and lot get created for 10. At time of UD (QA11) I put 7 quantities in unrestricted and 3 in blocked stock .what we generally use to do with that block stock? Whether we again transfer it to quality stock (Movement 349)? Or move directly to unrestricted (movement: 343).
    I tried to move the blocked stock in u201Cquality stocku201D in transaction MB1B with movement 349 but it had given error u201CChange the inspection stock of material 9112223334A in QM onlyu201D. In QM how to transfer the blocked stock in quality stock?
    Regards,
    PK

    Dear Prashanth,
    Quantity of 3 is rejected so you blocked it? why you want to bring it again to Quality? Use of putting in block is as follows:
    Since quantity of 3  is rejected  and need to be kept aside you are blocking the stock, the purchase person will send back this material to vendor directly from block stock (MBRL or MIGO). This is best practice.
    There can be other situation that your vendor came to your place and done rework om that 3 blocked items and you are satisfied with the quality then you can use respective movement for transferring from block to unrestricted, if you want lot to be generated then assign 08 insp type and do inspection.
    Hope this will help you better.
    Best Regards,
    Shekhar

  • Query about multiple connection pools under one database

    Hi,
    I have s query about connection pool, now we have a requirement,
    we have two schemas in one db, some data store in one schema, some in another schema,
    all tables are the same, but data is different, we want to retrive all data under two schemas,
    so we need two connection pools under one database,
    I have set two system DSN, and each connection pool was mapping to one DSN,
    but after I importing tables into RPD, when I view data, there is a dialog let me select connection pool. so If this, when we drag columns in answer, it will definitely get wrong.
    so how to realize this function about multiple connection pools under one database and we can get data normally.

    Hi,
    Try this step
    1)Better to create two different DSN for the same database with different user id and password
    2)now create multiple connection pool in the same database in u r RPD physical layer .
    also refer this link : for imporving performance
    http://obiee101.blogspot.com/2009/01/obiee-multiple-connection-pools.html
    http://gerardnico.com/wiki/dat/obiee/connection_pool
    Thanks
    Deva

  • Query about account hierarchy

    i want a query about account hierarchy
    like if i have asset 1000
    fixed asset 1100
    land 1110
    i want the result from query:
    asset 1000
    fixed asset 1100 1000
    land 1110 1100
    the last column is parent

    Try this
    SELECT ffv.flex_value, maptl.parval
      FROM apps.fnd_flex_values ffv,
           (SELECT ffvc.flex_value chval, ffvh.parent_flex_value parval
              FROM apps.fnd_flex_values ffvr1,
                   apps.fnd_flex_values ffvr2,
                   apps.fnd_flex_values ffvc,
                   apps.fnd_flex_value_hier_all ffvh
             WHERE ffvh.child_flex_value_low = ffvr1.flex_value
               AND ffvh.child_flex_value_high = ffvr2.flex_value
               AND ffvc.flex_value_id BETWEEN ffvr1.flex_value_id
                                          AND ffvr2.flex_value_id
               AND ffvr1.flex_value_set_id = :val_set_id
               AND ffvr2.flex_value_set_id = :val_set_id
               AND ffvc.flex_value_set_id = :val_set_id
               AND ffvh.flex_value_set_id = :val_set_id) maptl
    WHERE ffv.flex_value = maptl.chval(+)
    AND ffv.flex_value_set_id = :val_set_id
    ORDER BY ffv.flex_valueThis takes value set id as an input parameter.
    HTH

Maybe you are looking for

  • Release Build FAIL (but debug build works perfectly)

    Hi to all. I've a serious problem with making a release build of my project. Here the error screenshot: The debug build works perfectly I searched in the all hard drives for a "bin-release" folder, but it does not exists. How i can make a release bui

  • Performance degradation in Data Integrator Designer with Multi-user mode

    Post Author: ccastrillon CA Forum: Data Integration We are developing an information system based on a DataMart populated with data using ETL processes built with Data Integrator. We are three people developing and when we work at the same time we be

  • Output of Billing Document

    I have a problem with the printing of a billing document. I di set up the output determination of a billing document, but when I try and print, the Issue Output To window pops up with the Print Preview button and the print button. When I click on the

  • Validating the Business Rule  Essbase Error(1200315):

    When i Execute the BR FIX([v_Year],[v_Scenario],"Working", "USD","EUR", "HSP_InputValue",@LEVMBRS("Datasource", 0)) /* @ANCESTORS ("Products"); @IDESCENDANTS ("Entities");*/ AGG ("Products","Entities"); ENDFIX; It is Successful. But when i Change the

  • Receiving someone else's scam mail?

    Got the FBI scammers email item with attachment, responded as well as bounced it and got the non delivery message etc but soon later get a couple more different odd emails with the same? attachment. Then notice that all of them weren't even addressed