IN: int a, int b; OUT:Vector filled with numbers ranging from a to b

Hello,
is there any method to fill in a vector with numbers ranging from a value "a" to value "b"? Of course it can be done using a for-loop, but I was wondering if there is not a simpler way to do it. Thanks for your advices.
Example:
INTPUT:
int a = 4;
int b = 9;
Vector seq = new Vector();
seq.setSize(b-a);
OUTPUT:
pseudocode: seq = {4,5,6,7,8,9};

Darryl.Burke wrote:
Hmmm.. what happens when the other methods of AbstractList are invoked on an instance of IntRangeList? Wouldn't you need to override pretty nearly all the methods for consistency? And some methods, like remove and set, would have to throw a UnsupportedOperationException.If you read the API documentation of AbstractList then you could find out that you could implement a fully functional, fully compliant (unmodifiable) List implementation by just providing size() and get(int). All other accessor methods (including subList() and iterator()) will be using those two methods and fully work.
Writing a loop to populate a simple ArrayList would be trivial by comparison :-)Indeed, but if it's needed often and with big ranges, then there's no loss in using this implementation.
db
edit In fact, extending AbstractList appears irrelevant as none of the features of AbstractList are used. The IntRangeList, in fact, is-NOT-a AbstractList but just fakes it in respect of the 2 methods overridden in your code sample.What? All the features are used. Read the API doc. If I handn't extended AbstractList, but instead implemented List directly, then I'd have to implement all the methods myself (including an Iterator, which, while trivial in this case, can be non-fun to implement correctly).

Similar Messages

  • Recently, when I create a new album (untitled), it immediately fills with picture either from the album above it or, if I have a Faces collection open, with the pictures from that collection. Why and how do I fix it?

    Recently, when I create a new album (untitled), it immediately fills it immediately fills with picture either from the album above it or, if I have a Faces collection open, with the pictures from that collection. Why and how do I fix it?

    When a new album is created it will fill with whatever is in the right hand window,  If you're in the Events or Photos mode it will contain all photos in the library.  Yes, strange behavior.
    OT

  • System Log file filled with arp message from teamed nics

    Hello,
    We are running a Win2k3 server with dual nics teamed to one IP address. All of our Mac's system logs are being filled with the following message:
    Mar 28 12:48:58 Son-of-Spacedog kernel[0]: arp: 192.168.200.50 moved from 00:04:23:b9:00:4a to 00:04:23:b9:00:4b on en0
    This is repeated over and over. Is there any way to get the Mac's to stop generating this message? Is the fix for this on the server side or on the Mac side? From what I have seen online in other forums, this started happening with Panther.

    There are actually several different types of NIC Teaming Modes:
    Adapter Fault Tolerance (AFT) - provides automatic redundancy for a server's network connection. If the primary adapter fails, the secondary adapter takes over. Adapter Fault Tolerance supports two to eight adapters per team. This teaming mode works with any hub or switch, and all team members must be connected to the same device.
    Switch Fault Tolerance (SFT) - provides a failover relationship between two adapters when each adapter is connected to a separate switch. Switch Fault Tolerance supports two adapters per team. This feature works with any switch. Spanning Tree Protocol (STP) must be enabled when you create a team in SFT mode.
    Adaptive Load Balancing (ALB) - provides load balancing for transmission traffic and adapter fault tolerance. You can also enable or disable receive load balancing (RLB) in ALB teams. This teaming mode works with any switch.
    Fast EtherChannel/Link Aggregation - provides increased transmission and reception throughput in a team of two to eight adapters. This mode also includes adapter fault tolerance and load balancing (only routed protocols). This requires a switch with Link Aggregation or FEC capability.
    Gigabit EtherChannel/Link Aggregation - is the gigabit extension of the FEC/Link Aggregation/802.3ad: static mode. All team members must operate at gigabit speed.
    IEEE 802.3ad: dynamic mode - creates one or more teams using dynamic Link Aggregation with same-speed or mixed-speed adapters. Like the static Link Aggregation modes, Dynamic 802.3ad teams increase transmission and reception throughput and provide fault tolerance. This mode requires a switch that fully supports the IEEE 802.3ad standard.
    Now, most likely, somewhere on the network a server is configured for ALB or AFT, and these are the most common methods of NIC teaming (Sadly, the XServes do not). They also do not require any certain type of switch, but they do require STP (Spanning Tree Protocol) to be turned off to function most effectively, or you will see errors on the network like the ones you are seeing in your log. Most managed switches come with STP turned on by default, so you will need to check ALL switches (as the errors will cascade throughout the network) to see if it STP is turned on. Most people do not use STP any more (it basically allows ports on one switch to appear as on another switch), so see if you can turn it off. That should stop the error messages.
    -MacBoy in SLC
    PowerMac G5 Dual 2.0 GHz   Mac OS X (10.4.6)  

  • Formel Variable - how to fill with Customer Exit from control table

    Hello Experts,
    I have create in BEx-Analyser a formel Variable ZEXRATE1 filled through Customer Exit. In BW I had a "control tabel" with keyfigures.
    In the query definition I have include 0FISCPER, 0FISCVARNT and 0VTYPE. This
    are the keys which should give the values for the selectstatement to select my keyfigure from the "control table" to fill ZEXRATE1.
    If it possible to do with Customer Exit (CMOD -> RSR00001 -> ZXRSRU01) or do I have to implement a Bapi. Perhaps someone can give me a code example.
    Regards Dieter

    Hi,
    Code may look like this
    WHEN 'ZEXRATE1'.
    check i_step = 2.
        LOOP AT I_T_VAR_RANGE INTO L_S_RANGE.
          CASE L_S_RANGE-IOBJNM.
            WHEN 'ZFISCPER'. GV_ZFISCPER = L_S_RANGE-LOW.
            WHEN 'ZFISCVARNT'. GV_ZFISCVARNT =  L_S_RANGE-LOW.
            WHEN 'ZVTYPE'. GV_ZVTYPE =  L_S_RANGE-LOW.
          ENDCASE.
        ENDLOOP.
        SELECT SINGLE RATE into INTO GV_RATE
                  FROM ZTABLE
                  WHERE 0FISCPER = GV_ZFISCPER
                  AND   0FISCVARNT = GV_ZFISCVARNT
                 AND 0VTYPE = GV_ZVTYPE   .
    Assumptions : ZTABLE name of control table
                          ZFISCPER name of variable represents fiscal period
                          'ZFISCVARNT' name of variable representing fiscal year variant 
                          'ZVTYPE'. name of variable representing value type
    Hope that helps.
    Regards
    Mr Kapadia
    Assigning points is the way to say thanks in SDN.

  • Pre-fill Office documents with SAP data from WebDynPro screens

    I have a requirement to have Word/Excel type file templates that we can open and have pre-filled with data attributes from SAP objects.
    I know that we can do this relatively easily from within the SAP GUI in transactions such as SCASE etc... but our solution needs to have this type of functionality invoked from WebDynPro screens that are delivered through the Portal.
    We have looked at Adobe Document Services which will give us the fucntionality as described, but because of licencing constraints we are unable to use ADS at this stage.
    Does anyone have any knowledge or ideas on how we may achieve pre-filling of Word templates etc. from WebDynPro screens?

    Paul,
      Did you figure out how to do this? We have a very similar requirement now. Appreciate any suggestions you may have.
    Thanks
    Madhu

  • Reports / intranet/ In some detail,  the user will input a date range from and 2 and will out put the records in the int

    Hello there,
    I am totally green in web development.
    my goal is to, for the user will input a date range from and
    to and will out put the records in the intranet when they press a
    button.
    However, the good news is: I have experience in programming.
    I have written applications for desktop in VB>NET and I
    understand RDBMS /sql concepts .
    But CF and WEB development is new to me.
    My current projects involves in connecting to DB and testing
    it. (it works fine)
    And outputting reports by to a intranet page. (records)
    i need help on how to start this asap. I will even do some
    practice at home.
    Tools I have at work
    • Development server(test)
    • Home site.
    • Toad for db connection.
    • Html reference guide
    • Cf dummies book.
    How can start my projects.
    (ex. Create cf, outputpage?)
    seriously, I am new to this.
    Thanks.

    Well, I had a really nice response with some concepts and
    ideas for you to practise on etc, but these dumb forums timed out
    and I lost it all
    If you want to pop me an email we could probably do a few
    exercises together that way - or even by MSN Messenger if you want.

  • Can't convert int to int[]    URGENT!

    HI list!
    Here is the code part I have:
    /** Holds the permutated groups which are arrays of integers. */
    Vector v;
    if(arg.length<3) System.exit (0); //Need at least 3 arguments
    elements=new int[arg.length-1]; //Create array to hold elements
    /* Copy the arguments into the element array. */
    for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);
    groupsize=Integer.parseInt(arg[0]); //Get the number in each group.
    calc(groupsize,elements.length); //Find out how many permutations there are.
    v=permutate(groupsize,elements); //Do the permutation
    for(i=0;i<v.size();i++) { //Print out the result
    elements=(int[]) v.get(i);
    System.out.println("");
    for(j=0;j<elements.length;j++) System.out.print(elements
    [j]+" ");
    System.out.println("\nTotal permutations = "+v.size());
    and the error I get is:
    Permutate.java:26: Incompatible type for =. Can't convert int to int[]. for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);

    elements=(int[]) v.get(i);
    The above statement is illegal. Its not possible to
    use an array type in casting at all.
    Basically you are trying to do a kind of multiple
    casting, which is not possible.
    You might want to store vectors in vector v instead of
    arrays in vector v. Its better to do this.There's nothing wrong with the line
    elements = (int[]) v.get(i);
    assuming the returned object from the vector is in fact an array of int. Even then, it is a runtime exception condition not a compile-time error.
    Using arrays is perfectly valid where you know the size of the array at creation and do not need to resize it during use... The arrays are fast and compact. This is however not a comment on the approach taken in this case but merely an observation that arrays are not always an inferior choice to one of the collection classes.
    Now put up your dukes... ;)

  • StringBuffer delete (int start, int end) is too slow - HELP!!

    I've traced a performance problem to one line of code: a StringBuffer "delete (int start, int end)" call.
    My StringBuffer contains a lot of data, maybe 500,000 characters. My code loops, searching for a particular character (the search is fast, btw). When that particular character is found, I want to delete that character plus the characters following it. My code looks something like:
    int pos;
    while ((pos = myStringBuffer.toString().indexOf('~')) != -1)
         myStringBuffer.delete(pos, pos + 3);I'm 100% sure the bottleneck is the delete call. If I change the code to the following, where I've commented out the delete, it loops the same number of times and runs lightning-fast:
    int pos = 0;
    while ((pos = myStringBuffer.toString().indexOf('~', pos)) != -1)
         pos++;The loop, and therefore the delete method, will be executed thousands of times. To give you some idea of the poor performance I'm seeing, the first code (with the delete) takes more than 10 minutes to run, while the second code (without the delete) takes less than one-tenth of one second.
    Any suggestions? Thank you.

    Thanks for all the help! da.futt's solution works perfectly: 65,000 times through the loop in about one-tenth of one second. Problem solved.
    We're still on Java 1.3.1 (large company = slow to upgrade), so I can't even remove toString(). I wonder how many "small" performance problems we have (and are unaware of) that could be addressed by upgrading?
    My first posting here and a positive result. I'm not a Java expert, but neither am I a rookie. I'll be back to try and help others as I've been helped here.
    Thanks again.

  • Question about public void characters(char []ch, int start, int length) thr

    Can anyone tell me how you would keep all the characters from within one pair of tags together each time characters() is called?
    the character() method doesn't read all the character data at once, and i would like to create a buffer of what it has read.
    thank you.

    I recommend using getNodeName and/or/combination
    with
    getNodeValue to get the strings.i have tried using a buffer, and i have got that to work!
    At long last I am seeing the string I would like to see as it is in the xml file!
    thank you for your help
    here is an example of my code:
    private boolean isDescription = false;
    StringBuffer sb = new StringBuffer();
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
         if(localName.equals("description")) {
              sb = new StringBuffer();
              isDescription = true;
    public void characters(char []ch, int start, int length) throws SAXException {
         if(isDescription == true) {
              String desc = new String(ch, start, length);
              sb.append(desc);
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
         if(localName.equals("description")) {
              isDescription == false;
              System.out.println(sb.toString());
    }

  • How to user bufferedreader.read(char[] cbuf,int off,int len)

    how to user bufferedreader.read(char[] cbuf,int off,int len)?
    can you give me an sample code? i dont understand the use of offset here... thanks!

    The offset simply gives you the ability to read in data starting at some point in the buffer other than the first character.
    If, for example, you are reading from some stream that is being filled slower than you are reading, then you can write a read loop that will fill the buffer with successive reads - the first at character 0, then next offset past the end of the first set of data, etc.

  • Puzzel- Method to optimize int[ ][ ]of int[ ][ ]'s

    I'm righting a class that takes an int[][], initially filled with 0 or null. A rectangular block is added to the int[][] with a value of 1 - 9. Another rectangular block is added to the int[][] with a different value from the first, usually the next int (2). The current setting is
    final static int width = 47;
    final static int height = 3800;
    public int[][] grid = new int[47][3800];
    I have a method addBlock(int blockWidth, int blockHeight) which adds a block to the grid. However it doesn't properly optimize the grid to fit the most efficient number of blocks. It simply adds a block to the top left corner of the grid (where the top left is grid[0][0]) and checks to make sure the next block does not overflow the width bound of 47. If it does it simply places the block at the first available grid where the grid value = 0 and does not overflow the bounds. It doesn't check to make sure that it isn't overriding other blocks, and it doesn't move existing block to make room for new blocks.
    What I am looking for is a way to keep individual blocks together. There could come a situation where two blocks with the same value touch. In this case what would happen?
    Also how do you move blocks once they have been added to the grid?
    Finally, is there an existing algarythm for doing a best fit on a grid of grids?
    Suggestions, other places to look, code, websites to check or any valuable information would be greatly appreciated.
    If needed I could post the existing source, which stacks the grids from the upper left corner and works down. I have a viewer written already which reads in an int[][] and displays it in 9 colors, however I can easily expand the color recognition to as many colors as needed.

    Hi again,
    even if the sequential adding of block will not lead to an optimized layout of the templates on the bolt, we can improve the algorithm given by robert19791 - starting from the top left position of the bolt working towards the right bottom we can say the following:
    The top-left corner of each rectangle is on the right or bottom edge of another rectangle except for the first one added. So, when we search for a position, we will do it along these edges of all the rectangles added before. The test, if it fits in a certain position, can be done with an intersection check with all other already added rectangles, which right or bottom edges are not left or top of the tested position. Ofcourse the rectangle to add must be inside the bolt.
    This will reduce the postions to check and also give a solution for the overlapping problem Robert has mentioned. In those cases where the fit test fails, it should be tested, how large the overlapping area is - if it is not so big, it is perhaps a good idea to shift the rectangle, which would be overlapped otherwise. During such a shift operation the rule of the top-left-corner sitting on the right or bottom edge of another rectangle can be broken, instead the rule is, that an edge is in contact with another rectangle's edge.
    Ok, this for now
    greetings Marsian

  • Public int indexOf(int ch, int fromIdx) doesn't work for some decimal value

    I have tested two strings below. These two string are identical, except the first string has a char 'ƒ, which has a decimal value of 131. And the second string has a char 'À', which has a decimal value of 192. I am expecting the same output, which is 11, but I got -1 for the test I did using the first string. In the API for public int indexOf(int ch, int fromIndex), values of ch is in the range from 0 to 0xFFFF (inclusive). It is highly appreciated if anyone could provide any insights on why -1 returned when the first string is tested. Thank you in advance.
    String strHasDecimal131 = "Test value ƒ, it has a decimal value of 131";
    String strHasDecimal192 = "Test value À, it has a decimal value of 192";
    int badDecimal = 131;
    int idxBadDecimal = strHasDecimal131.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal -1
    int badDecimal = 192;
    int idxBadDecimal = strHasDecimal192.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal: 11

    Thank you everyone for your inputs. Following are the print statements and the output: for character 'ƒ' and ' À':
    System.out.println((int)'\u0083' + ", " + (int)'\u00C0' + " print decimal value" );
    Output: 131, 192 print decimal value
    System.out.println((char)'\u0083' + ", " + (char)'\u00C0' + " print character value" );
    Output: ?, À print character value
    According to Latin-1 Supplement table, the first char in the output would have the appearance of ƒ, instead it has the appearance of ?
    System.out.println( (int)'ƒ' + ", "+ (int)'À' + " print integer value");
    Output: 402, 192 print integer value
    I also have tried to print out the decimal value of following char: € &#65533; ‚ ƒ „ … † ‡, according to Latin-1 Supplement table, these char has decimal value of 128 through 135 and hex value 0x0080 through 0x0087. And the output from java println is: 8364 65533 8218 8222 8230 402 8224 8225.
    System.out.println((int)'€' + " " + (int)'&#65533;' + " " + (int)'‚' + " " +(int)'„' + " " + (int)'…' + " " +(int)'ƒ' + " " + (int)'†' + " " + (int)'‡' );
    As I did before, I print out character of decimal value of 128 through 135
    System.out.println((char)128 + " " + (char)129 + " " + (char)130 + " " +(char)131 + " " + (char)132 + " " +(char)133 + " " + (char)134 + " " + (char)135 );
    Output: ? ? ? ? ? ? ? ?
    Not sure why java prints character for decimal value of 128 through 159 differently from what appears in the Latin-1 Supplement table. Any of your inputs are appreciately.

  • Driver not support createStatement(int resultSetType, int resultSetConcurrency)

    I am using Weblogic 5.1 for development and would like to use resultset for
    updating
    when I call 'createStatement(int resultSetType, int resultSetConcurrency)'
    Error message prompt out that the driver does not support such method
    I am using weblogic.jdbc20.oci.Driver & weblogic.jdbc.mssqlserver4.Driver
    for testing
    Can some body help me
    regards,
    Fannie

    Right, this method is not implemented by weblogic driver. You should get a
    message like,
    "This JDBC 2.0 method is not implemented" from
    weblogic.jdbc20.oci.Connection or weblogic.jdbc20.mssqlserver4.TdsConnection
    "Fannie" <[email protected]> wrote in message
    news:3b563e73$[email protected]..
    I am using Weblogic 5.1 for development and would like to use resultsetfor
    updating
    when I call 'createStatement(int resultSetType, int resultSetConcurrency)'
    Error message prompt out that the driver does not support such method
    I am using weblogic.jdbc20.oci.Driver & weblogic.jdbc.mssqlserver4.Driver
    for testing
    Can some body help me
    regards,
    Fannie

  • Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content?

    Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content? By anyone, I mean someone who can download and use the free Adobe Reader, on either a Mac or PC. I have Acrobat Pro, and would like to be able to create forms that can not only be filled out and printed, but saved and emailed, which is not an option with the forms I have created to date. They can be filled out, but not saved, with Adobe Reader.
    TIA,
    Nancy

    To do what Dave indicated you need to do, it depends on what version of Acrobat you have:
    Acrobat 8: Advanced > Enable Usage Rights in Adobe Reader
    Acrobat 9: Advanced > Extend Features in Adobe Reader
    Acrobat 10: File > Save As > Reader Extended PDF > Enable Additional Features
    Acrobat 11: File > Save as Other > Reader Extended PDF > Enable More Tools (includes form fill-in & save)
    I wonder what it will be next time?

  • My Firefox crashes every time I open it and none of the steps in the database solve the problem. My crash signature is PaintFrame(nsIRenderingContext*, nsIFrame*, nsRegion const&, unsigned int, unsigned int)

    I tried opening it in safe mode and none of the other help tips in the database on firefox crashes when I open it apply to me. I also ran a couple of virus programs to check for any infections and found nothing. I had been having issues with java previous to firefox beginning to crash. So I attempted to uninstall java from my computer but it did not help.
    My crash signature is PaintFrame(nsIRenderingContext*, nsIFrame*, nsRegion const&, unsigned int, unsigned int) and a search of this term on Mozilla Support pulled up no results.
    I'm not terribly knowledgeable with programming so any suggestions would help!

    I read online about a "clean reinstall" of firefox which seems to have worked! They should include direction on this on their page: https://support.mozilla.com/en-US/kb/Firefox+crashes+when+you+open+it

Maybe you are looking for

  • How to recover files which are  desapeared with a replacement of a folder

    Hi, i will make a stupid question/ where are my files gone when i replaced a folder with a new one with the same name. Can i recover them? Thank you for answer!

  • Office Admin Templates

    Not sure if I should be posting this here or in a Group Policy forum; however, I'll try here first (apologies if I am wrong) I've applied the Office 2010 and Office 2013 Admin Templates to the PolicyDefinitions directory on our network When I go to s

  • Gallery freezing

    I have only had my phone since the end of December and it has recently started to freeze whenever I open the Gallery to view photos. I will open the gallery, it will start populate and then will stop. I can't get out of the application, close it or d

  • I lost my i-tunes online purchase after upgrade to snow leopard...

    Hi I lost my i-tunes online purchases after upgrade to snow leopard... Is there any way to retrieve them? Thanks

  • Declaring an array that is populated with a for loop

    Hi Guys, i have an array declared like this at the top of my class: private int [] longTable     ={16,17,18,19,20,21,22}; It gets accessed from within methods in the same class. I want to extend this array to go from 16 up to 124 in increments of 1,