Copy small array from cyclical queue

Hi,
I would like to know how to create a small array from a bigger one when the bigger one is cyclical. The problem is that i'm copying the values with Arrays.copyOfRange(array,from,to) until I end up to the final of the queue where it falls in a ArrayIndexOutOfBoundsException
Example:
cyclical_queue: [ 34 23 2 3 4 5]
if small_array has to be [4 5 34] i cannot use copyOfRange since it would end up in Arrays.copyOfRange(cyclical_queue,4,1) -> ArrayIndexOutOfBoundsException
P.S. I am trying to do it without loops since performance is important in my program
Thanks in advance for any help,
Rodo

Rodo1983 wrote:
I would like to know how to create a small array from a bigger one when the bigger one is cyclical. The problem is that i'm copying the values with Arrays.copyOfRange(array,from,to) until I end up to the final of the queue where it falls in a ArrayIndexOutOfBoundsExceptionYou can't use Arrays.copyOfRange for this if the array you're copying wraps around the end of the queue.
P.S. I am trying to do it without loops since performance is important in my programDon't bother. Looping isn't inefficient, and besides, I'm almost positive Array.copyOfRange() uses loops. Just start copying at the beginning index, wrapping to zero if you get to the end, and stop when you get to the ending index.

Similar Messages

  • How do I copy an array from a website to Excel using Firefox

    Was running Firefox on Windows Vista. I could copy an array from finance.yahoo.com into an Excel spreadsheet by selecting the array with control key down then clicking on edit - copy selected cells, then pasting into an Excel sheet. I only had to tell it the upper left cell and the whole array went in properly
    Now trying to do the same thing on a new machine running Windows 7, but the "copy selected cells" option is not available in the edit menu. Is there a way to copy an array with Firefox and Windows 7? These are big arrays. One cell at a time is out of the question.

    Try this Add-on --> https://addons.mozilla.org/en-US/firefox/addon/dafizilla-table2clipboard/
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *'''''Adobe PDF Plug-In For Firefox and Netscape''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • How to read flushed cluster array from input queue?

    Hi! I'm new to LabView. Can someone please help me?
    I want to use a subvi to read a queue which I created in another vi. The created queue holds an array of clusters that I want to unbundle in a for loop in the reading vi. But the output of the flush queue function is a string array (since the subvi has no info on what sort of queue is being input).
    I can't connect the unbundle function to a string input; can I use the type cast function to force the flush output to be a cluster? Or is there a better way to do this?
    And if so, what is the string constant I need to attach to the "type" input in the type cast function?
    And also, I'm told that the cluster is kind of like a "struct"; so is there a way to n
    ame it so that other vi's know what it is(i.e. type cast)?
    jen

    I did look at the help examples, but I couldn't find one that was sending the queue from one vi to another(well, not any that I could understand), and that was really my problem.
    I did get the thing to work when it was all in one vi.
    You bring up an interesting point about "dequeue" and "flush". Perhaps I am mistaken, but my reasoning for using flush rather than dequeue was the following:
    I am using the queue as a data buffer. I need the queue to hold a few minutes of data. This data is dumped to file upon fault event, i.e. it tells me what was going on right before the fault occurred. I need that queue to dump the data and then immediately turn around and start filling up again. I felt that holding on to the queue reference in the save-to-file routi
    ne (which involves lots of potentially slow hard disk access) might cause the object to lock and hence not be able to save right away. I don't know how LabView does threading, but if I was writing the threading routine, I would lock any object which was being executed upon in a routine to prevent data collision.
    Of course, this begs the question: does LabView lock all objects in a subroutine that is executing? Or just in the part which is unresolved? or does it lock objects at all? Perhaps I should flush the queue outside of the subroutine anyway, so that the subroutine can happily munch on the flushed array while my queue goes back to the business of collecting data?
    Am I way off base in how the threading works?
    Thanks!
    jen

  • How can I copy a photo from iphoto to PReview to make it smaller for uploading to a site that requires a smaller image?

    How can I copy a photo from iphoto to PReview to make it smaller for uploading to a site that requires a smaller image?

    I don't think you need Preview.
    Select the image and use File->export and you have full control over the size and compression.

  • Getting all values from a queue

    Hi all,
    I have a queue as follows:
    [123] - intital Context
    [sollinger Str]
    [123] - CC
    [Solinger Str]
    [123] - Final context
    An image of the queue looks as follows:
    [http://i42.tinypic.com/hsj052.jpg]
    Iam getting this queue in a userdefined function. I want to get or copy all the values from this queue to a new array as follows without any contexts.
    That is, I want to have a queue as follows from the above queue.
    [123]
    [sollinger Str]
    [123]
    [Solinger Str]
    [123]
    How could that be done...
    Thanks
    P

    Hi guys...thanks 1 more thing
    If My inbound queue "a" is as follows:
    SUPRESS
    AP
    YG
    LF
    contextChange
    YG
    LF
    Final Context
    In my Queue "b" which is as follows
    SUPRESS
    123
    sollinger...
    123
    Sollinger...
    123
    FinalContext
    My requirement is in my "b" queue , I want to put a CC as follows by using a  standard node function if possible
    SUPRESS
    123
    sollinger...
    123
    contextChange
    Sollinger...
    123
    FinalContext
    IF THAT dont work Inside my UDF I want to put thE CC for the b queue.
    How will the loop behave then?
    What will be passed to my input queue "a" and "b" when execute "all values on context" is set.
    "a" has a context and "b" doent have one.
    My UDF
    public static void Test(String[] a,
                                           String[] b,
                                           ResultList result,
                                           Container container){
    //Contains no context change
        String b[] = {ResultList.SUPPRESS,"12","sollinger","12","sollinger","12",
                      ResultList.CC};
    I make the following steps
    copy to an arraylist. add a context change in between.
    copy back to string b.

  • Need to take the N-th element from a queue

    hello everyone!
    I have a problem, i don't know how to take ony one element from a queue...
    Indeed, i need to take only the 3rd element of a queue but i don't know how to do that... so i though maybe i can change it as an array (with the vi "flush queue") and then take the 3rd element of this new array but same problem, i don't know how to manage that!
    please help me, i have been trying to solve this problem all day long
    thank you very much!
    Yanis

    I am not sure if there is a more elegant solution but what I have done in the past in similar situations was to get all elements of the queue with the queue status. Then I would flush the queue and pop any elements I wanted back on the queue while removing the items I needed/wanted. As I say, this is not the most elegant but it is a tried and true method. If your elements are fairly small and you don't have lots of elements on the queue the performance hit is not too terrible.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Error while copying a page from one application to another application

    Hi All
    I am using Oracle Apex 4.0
    I getting the error ORA-06502 Pl/Sql Numeric error character string buffer too small when i copying a page from one application to another application.
    Thanks & Regards
    Srikkanth.M

    I'm having the same issue. How did you solve this?

  • How can I copy cell formatting from one range to another?

    How can I copy cell formatting from one range to another, including text fonts, colours, borders, etc., so that, for example, I can reuse a formatted reconciliation table again in different parts of a sheet?

    Hi George,
    Wayne found the Spinning Beachball of Death, and you will find it too.
    Numbers is not good at handling large datasets. Might I suggest that you group your data into smaller sets (each month, perhaps?) and save each group in a separate Numbers document. Numbers will not link between documents, but you could have a summary Table within each document. Then comes the "clunky" bit of copying all those summary tables into a master document where you do the final processing of the data.
    Regards,
    Ian.

  • Problems during copying music files from iTunes 10.6.1 to iPhone

    1st problem
    In new iTunes 10.6.1 on my MBP when copying music on iPhone if during copying add additional musical files in queue, copying of files from the previous queue stops. In the previous iTunes version of such problem didn't arise. Whether there is a solution of this problem?
    2nd problem
    In older version of iTunes i could adding new music files to my iphone with drag and drop from Finder. Now i must add files in iTunes library and then from library drag and drop files to iphone. How to solve this problem?

    You would have to purchase 10.6 (Snow Leopard) and install it, assuming your computer is compatible.

  • How can I copy a picture from Iphoto to a text document?  Currently when I drag and drop the picture is truncated.

    hello Apple community.
    How can I copy a picure from Iphoto to a blank text document(not Word, but text doc)? Currently when I do this, the picture is truncated. This is more difficult than using a PC! there has to be a better way to copy pictures or share pictures!
    Thank you,

    Hello,
    thank you for your reply.
    I am using the TextEdit on Mac as I do not have Word. When I paste an Iphoto, the picture is truncated horizontially, so you only see part of the picture.
    Yes, the picture is small enough to fit on the page.
    Regards,
    Celina

  • Cases where messages are not being consumed from a queue

    MQ 4.0
    I have a cluster of 3 brokers. Java clients use RANDOMIZE to connect to the cluster of brokers. Message selectors are not used. My consumers are all synchronous, and connection.start() is called prior to calling MessageConsumer.receive().
    What I have seen on random occassions are messages not being consumed from the queue. The problem seems to be sporadic.
    I was thinking that the reason it is sporadic is because of the RANDOMIZE configuration of the client connetion / object-store.
    That is, there is a possibility for the following to happen:
    1) There were messages produced on a queue on broker A, but before these messages were consumed, all the consumers have been shutdown. Thus, the messages on queue stayed on broker A .... and have not been copied / clustered to the other brokers in the cluster ( As per online documentation, a queue is "copied" to other brokers only when there is a consumer for that queue on the other brokers ).
    2) Then the client applications started up produced and consumers again. This time, the producers were all connected to broker B, and all consumers for the queue were also connected to broker B.
    3) Because there are no other consumers for the queue on the other brokers, the messages in the queue on broker A are never consumed.
    Can someone confirm that this is a possibility ?

    Well ... it does seem to be the case.
    I changed the object-store so that instead of using RANDOMIZE for imqAddressListBehavior, it uses PRIORITY. Therefore, all clients ( producers and consumers ) will connect to only 1 broker out of the 3 in the cluster.
    After restarting all JMS clients with the new imqAddressListBehavior, there were messages in various queues in the other brokers that were not being consumed, because there are no longer any consumers on any of the other brokers.
    All the messages in that broker that all JMS clients connect to are being consumed ...
    Except for about 6 messages that stays in the queue for whatever reason. All consumers receiving with receive( 10000 ), and after consuming all messages above the 6, it returns without any more messages in the queue.
    Well ... so much for cluster of brokers. I'll have to think of an alternative.

  • How can I send and receive a message from  a queue using standalone program

    Hi,
    I want to write a standalone Java program which has to post a message to a queue and receive a message from a queue thats specified as a replyto queue.I want to have my application to be completely standalone without the need of a Application server.What all the Jars do I need to include in the application.My aim is to have the application standalone and portable so that the application runs on any machine that has a JRE.
    Thanks in advance,
    Prathima

    Hi,
    You can get quite simple standalone MQ Java programs from this site http://www.capitalware.biz/mq_code_java.html.
    Also regarding the jars required for your application depends on the API being used. If you use MQI API few jars are required and if you decide to use JMS API you'll require few other jars. But you got to either install Websphere MQ Java Client, which will copy the jars to the respective location, or you can choose to copy the jars from some other machine manually.
    Eventually, all the jars related to MQI and JMS API will reside under /usr/mqm/java/lib/ or /var/mqm/java/lib/ UNIX Environment. And in case of WINTEL, you should find the jars under C:\Program Files\IBM\WebSphere MQ\Java\lib.
    Trust it clarifies...
    Naren

  • Copying the value from a cell in the SQL results?

    I run an sql query. The results are returned in a results window. I would like to copy the value from this cell
    and paste it into an sql query. How can I do this? I can copy and paste a value from a cell in the view of the data in
    a table, but not from the test results. How do I do this? Is there a setting I need to change?

    I usually do this kind of operations and I've never had any issues, the procedure is as simple as CTRL-C in the results grid, with the required column/columns selected and CTRL-V in the worksheet or anywhere else.
    If you still have issues please post your
    - SQLDeveloper version
    - Java Version
    - OS
    - Database Version
    and if you can a small test case.

  • Reading Data from a Queue - Store in Fast Loop, Display in Slow Loop

    Here's my BD below.  I am queueing data in a faster loop (either 100 ms or 50 ms) and sending that data to a 250 ms loop.  I need to be able to display the data in the slower loop (so that the FP doesn't have to update every 50 ms).
    Problem I'm having:  How do I empty the data?  It builds and builds and eventually I'm looking at a chart that has data that's 1 minute old.  I've tried writing my own flush code (attached).  I've tried to use variables to pass data and use an array to parse...not working.  Any help would be appreciated.
    Nathan - Certified LabVIEW Developer
    Solved!
    Go to Solution.
    Attachments:
    FlushQueuebyNathan.vi ‏21 KB

    If you need all of the data to go into the chart, I would use the flush queue and write to the chart in a FOR loop (autoindexing with the elements array from the flush queue).  You may set the Defer Front Panel Updates before the FOR loop and reset it after, but I'm not sure that will buy you that much.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Programmatically create array from common cluster items inside array of clusters

    I have seen many questions and responses on dealing with arrays of clusters, but none that discuss quite what I am looking for. I am trying to programmatically create an array from common cluster items inside array of clusters. I have a working solution but looking for a cleaner approach.  I have an array of clusters representing channels of data.  Each cluster contains a mixture of control data types, i.e.. names, types, range, values, units, etc. The entire cluster is a typedef made up of other typedefs such as the type, range and units and native controls like numeric and boolean. One array is a “block” or module. One cluster is a channel of data. I wrote a small vi to extract all the data with the same units and “pipe” them into another array so that I can process all the data from all the channels of the same units together.  It consists of a loop to iterate through the array, in which there is an unbundle by name and a case structure with a case for each unit.  Within a specific case, there is a build array for that unit and all the other non-relevant shift registers pass through.  As you can see from the attached snapshots, the effort to add an additional unit grows as each non-relevant case must be wired through.  It is important to note that there is no default case.  My question:  Is there a cleaner, more efficient and elegant way to do this?
    Thanks in advance!
    Solved!
    Go to Solution.
    Attachments:
    NI_Chan units to array_1.png ‏35 KB
    NI_Chan units to array_2.png ‏50 KB

    nathand wrote:
    Your comments made me curious, so I put together a quick test. Maybe there's an error in the code (below as a snippet, and attached as a VI) or maybe it's been fixed in LabVIEW 2013, but I'm consistently getting faster times from the IPE (2-3 ms versus 5-6ms for unbundle/index). See if you get the same results. For fun I flipped the order of the test and got the same results (this is why the snippet and the VI execute the tests in opposite order).
    This seems like a poster child for using the IPES!  We can look at the index array + replace subset and recognize that it is in place, but the compiler is not so clever (yet!).  The bundle/unbundle is a well-known "magic pattern" so it should be roughly equivalent to the IPES, with a tiny penalty due to overhead.
    Replace only the array operation with an IPES and leave the bundle/unbundle alone and I wager the times will be roughly the same as using the nested IPES.  Maybe even a slight lean toward the magic pattern now if I recall correctly.
    If you instantly recognize all combinations which the compiler will optimize and not optimize, or you want to exhaustively benchmark all of your code then pick and choose between the two to avoid the slight overhead.  Otherwise I think the IPES looks better, at best works MUCH better, and at worst works ever-so-slightly worse.  And as a not-so-gentle reminder to all:  if you really care about performance at this level of detail: TURN OFF DEBUGGING!

Maybe you are looking for