Queue or array which is better?

I need a array of clusters to be stored for which the length is not defined. I will update, Add new element to it.
Array or queue can be used to store the clusters. Which one would be better to use in terms of memory usage, fast execution and other performance parameters.
I have some other doubts also. 
Consider an array of 8 elements. When an new element is added to the array using 'insert into array', 
whether a new copy of 9 elements will be created? or 9th element will be linked after the 8th element (like linked lists)? or something else happens?
If a new copy is created, what happens to old 8 elements in the memory, whether that memory will be freed or kept as such?
The same doubt in case of queue also...
Thanks in advance.. 
Solved!
Go to Solution.

In your case, you want to use a queue. 
An array is stored in RAM in consecutive memory locations. When increasing the size of the array, the data structure is increased in size and often entirely moved to a place where it can all fit. If you are resizing an array inside a fairly fast loop, the performance hit would be noticeable.
A Queue is able to place individual elements in their own address chunks in RAM and is much more performance-friendly.
- Cheers, Ed

Similar Messages

  • Array of structures - two ways to approach - which is better?

    Folks - I've been trying to create an array of structures,
    but I bumped into problem that lead me to an example that is
    completely different. I'm trying to figure out which is valid. In
    general, it comes down to this:
    (1) myStructure
    .firstName
    vs
    (2) myStructure.firstName
    The problem with the first is that I can't find a way to
    discover the size of the array, which leads me to suspect this is
    not a valid method. The problem with the second is that you must
    redefine the structure for EACH array element, which seems like it
    would add a lot of overhead.
    Any advice? Sample code attached.
    Thanks!
    ************* Sample (1) **************
    <CFSET sCust=StructNew()>
    <CFSET vCustCount = #rsMailAuth.recordcount#>
    <CFSET i = 0>
    <CFOUTPUT QUERY="rsMailAuth">
    <CFSET i = i+1>
    <CFSET sCust.userId
    = #rsMailAuth.userId#>
    <CFSET sCust.validEmailSource =
    #rsMailAuth.validTcEmails#>
    <CFSET sCust.authKeyword
    = #rsMailAuth.tcEmailKeyword#>
    <CFSET sCust.authKeywordLoc =
    #rsMailAuth.tcEmailKeywordLoc#>
    </CFOUTPUT>
    ************* Sample (2) **************
    <cfset strTest = arrayNew(1) >
    <cfset strTest[1] = structNew() >
    <CFLOOP INDEX = "i" FROM="1" TO="5" >
    <cfset strTest
    = structNew() >
    <cfset strTest.id = i>
    <cfset strTest
    .name = "[email protected]">
    </CFLOOP>
    <cfoutput>#arrayLen(strTest)#</cfoutput>

    Sorry - simple english...
    I am collecting a series of emails from a pop email server.
    As I parse these into the individual parts (subject, body, from,
    etc) I want to stuff them into a structure. each email would be a
    new index. so, the 2nd email 'from' info would go into
    myStructure.from[2] or myStructure[2].from.
    I know there are lots of ways around this, I just have a
    natural predisposition to use structures when possible as it makes
    it easier for me to keep track of things and makes it easier to
    follow the code.
    I can make either of these work, I'm just not sure if they
    are valid in the world of coldfusion8.

  • Which is better for newbies?

    Which is better for newbies, Jgrasp or Netbeans? I need something that explains errors more thoroughly than Jgrasp.

    Here's my code with 3 errors. Now bear in mind that my program has compiled completely and ran correctly up to this method. All I'm trying to do with this method is get the average of all grades in a multi-array. I researched and found some code that was similar to what I needed to do but it's not working out yet. All other methods in my program work perfectly but I can't get this one to compile.
    public double getMean(int allGrades[][])
              int total = 0;
              for (int grade : allGrades)
              total += grade;
         System.out.println("Total is "+getMean(grades));     
              return total/allGrades.length;
    } // end class GradeBookGradebook.java:100: illegal start of type
              return total/allGrades.length;
              ^
    Gradebook.java:100: <identifier> expected
              return total/allGrades.length;
              ^
    Gradebook.java:100: <identifier> expected
              return total/allGrades.length;
              ^
    3 errors

  • Bitmap Sheets - tiled or single row - which is better?

    For alot of my animated sprites, I wrote a little program to read in all the bitmap data, crop the images and output a single sprite sheet of all the bitmaps, plus the "array" data needed to find and copy out the specified frame.
    This has proven to save both memory and preformance when dealing with large numbers of frames
    However, when I look at several example of how other people do sprites sheets, their final sheet is always tiled
    So if I have an animated sequence of 60 frames, (assuming that each source bitmap is, 50x100 and there is no cropping to be done) I would end up with something like this:
    Bitmap: Size = 3000x100;
    TopLeftCornerArray = [[0,0],[50,0],[100,0]...[2950,100]];
    Is there any difference between doing that, instead of creating a sheet bitmap, that was say 10 frames per row over 6 rows giving me a bitmap that was 500,600?
    I mean, both bitmaps are made up of 300,000 pixels regardless...
    I was just wondering if there was a good reason for not putting them all on a single line.

    I am "gridding" it, for the most part, as 50% of all my images are blockish anyway, so there is no real "cramming" needed.
    The rest are characters, and unfortunately, due to the way they were rendered and created by the artists, (which was originally build for director) and they had wonky registration points, writing my own allowed me to programmatically calucate where those registration points would have been in director and output that data as part of my frame arrays (which I call "center point offset") while still cropping the images to their smallest size.
    I am not "cramming" it like in the texture packer is doing, but given the irregular shapes of most of the character frames anyway, there would be some sort of wasted alpha anyway... so while it's true, using a program like that (and I am actually looking into it), would probably result is slightly smaller images in the end, being able to do the programmatic custom stuff outwieghed the advantage of saving a few hundered pixels per sheet.
    But just to make things easier to code, I did it in a long single row instead of tiling.
    For example, one of my sheets consists of a "spinning coin". every frame is always 56 pixels in height. only the width of the frame changes based on the width of the coin itself. the vast majority of my sources do this. so with 30 frames, so when I built the sheet, I crop the images and I end up with a final bitmap about 1100 pixels in width, and 56 in hieght, and it's packed just as good as any other prog.
    From a programmatic point of view, there is no difference between a single or or multiple rows, but given how memory problems for ios are a nightmare, and performance is a pain, I wasn't sure if there was some "unknown and undocumented reason" why tiled vs single row would be better.

  • Which is better ? for loop or iterator ??

    Hi,
    I have one array list having more than 100 objects in it.
    I have two way to ietrator.
    1.
    for(int i=0; i<list.size(); i++)
    Object o = list.get(i);
    2.
    Iterator i = list.getIterator()
    while(i.hasNext())
    Object o ...
    which is better in performance ??

    Well okay. It's an easy optimization but I guess Sun
    doesn't want to "bail out" people who don't know
    their data structures.It won't always be optimal, though. If you use
    iterators and don't iterate the whole way through
    every time, it would degrade performance. It's hard
    for them to make assumptions about how you will
    access the data. So you punish people who do use it
    properly if you do that.I don't know. The optimization I suggested is isolated to random accesses in the linked list only. Say you access index 5. The node pointer corresponding to 5 is stored and if the next access is index 6 the node pointer you're looking for is pointer.next. There's no need to walk the list from the beginning.

  • Which is better to install Oracle 11g database based on ASM or Filesystem

    We will install 2 sets of Oracle 11.2.0.3 on Redhat Linix 5.6 and configure Data Guard for them further -- one will be a primary DB server, the other will be a physical standby DB server. The Oracle DB stoage is based on SAN Array Disk with 6TB size. Now there are two options to manage the DB datafiles:
    1. Install Oracle ASM
    2. Create the tranditional OS filesystem
    Which is better? in the past, our 10g data guard environment is not based on Oracle ASM.
    Someone think if we adopt the oracle ASM, the shortcomings are :
    1. as there is one more instance that will consume more memory and resource.
    2. as the ASM file system cannot be shown out on the OS level directly such as "df" command, the disk utilization monitor job will be more difficult. at least it cannot be supervised at OS level.
    3. as the DB bshoule be done the daily incremental backup (Mon-Sat) to Local Backup Drive. the bakup job must be done by RMAN rather than user-managed script.
    Who can provide some advices? Thanks very much in advance.

    user5969983 wrote:
    We will install 2 sets of Oracle 11.2.0.3 on Redhat Linix 5.6 and configure Data Guard for them further -- one will be a primary DB server, the other will be a physical standby DB server. The Oracle DB stoage is based on SAN Array Disk with 6TB size. Now there are two options to manage the DB datafiles:
    1. Install Oracle ASM
    2. Create the tranditional OS filesystem
    Which is better? in the past, our 10g data guard environment is not based on Oracle ASM. ASM provides a host of new features ito data management, and performance - to the extent that you can rip out the entire existing storage system, replace it with a brand new storage system, without a single second of database downtime.
    Someone think if we adopt the oracle ASM, the shortcomings are :
    1. as there is one more instance that will consume more memory and resource.Not really relevant on 64bit h/w architecture that removes limitations such a 4GB of addressable memory. On the CPU side... heck, my game PC at home has a 8 core 64bit CPU. Single die and dual core CPUs belong to the distant past.
    Arguing that an ASM instance has overheads would be silly. And totally ignores the wide range of real and tangible benefits that ASM provides.
    2. as the ASM file system cannot be shown out on the OS level directly such as "df" command, the disk utilization monitor job will be more difficult. at least it cannot be supervised at OS level.That is a A Very Good Thing (tm). Managing database storage from o/s level is flawed in many ways.
    3. as the DB bshoule be done the daily incremental backup (Mon-Sat) to Local Backup Drive. the bakup job must be done by RMAN rather than user-managed script.
    rman supports ASM fully.
    I have stopped using cooked file systems for Oracle - I prefer ASM first and foremost. The only exceptions are tiny servers with a single root disk that needs to be used for kernel, database s/w, and database datafiles. (currently these are mostly Oracle XE systems in my case, and configured that way as XE does not support ASM and is used as a pure cost decision).

  • Which is better to use: BEx query or Web Application as an iView in portal?

    Hi gurus!
    Are there any experienced opinions, which is better - publish a BEx query in portal or publish a BEx Web Application in portal? Is it easier to alter the layout attributes etc. if I create a BEx Web Application first before publishing?
    What is the way of fixing for example filter item height if I publish BEx query in portal - is there a Web Application that it uses anyhow which I can fix? Or can I use in that case iView -properties in portal?
    Thankful for advice
    Sari

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Which is better??????

    which is better?Dam really confused which speaker to buy??
    i currently have a creative m2600.but am not getting enough performance or that feel while watching movies like avatar,step up 3 etc......so am planning to buy a 5.1.......not planning but i have decided to buy a 5.1....so..
    which is better? the 6160 or 6060 or 6100.
    which of these will provide me relly great exprience while playing games and most importantly while whatching hd movies and while listening to music.......
    and other than this what i have to ask is...what is this "db" in speakers. i mean while looking at a speaker specs we can see it..like 65db,85db,75db..etc........
    and when i compared specs of the three speakers i mentioned above i saw that the 6160 has low "db"........why is that?

    The specs is just a guide, you won't be able to tell the slight difference in db using just your ears. Besides, it is just a comparison between the level of a music to the level of background noise, it does not necessary mean which speaker sounds better. If possible, please make a trip to your local electronics store and try out the speakers system yourself.

  • Which is better, Photoshop or Corel?

    Which is better, Photoshop or Corel? I am finding the best one to use for my website [link removed]. Let me know your opinion. Tks all.

    Thank you! I am trying to find the best one for the site [Link removed].
    I used to use Corel before, but now, I am trying to use Photoshop.
    Tk you anyway
    [Removed link]
    Message was edited by: sinious

  • Which is better software for brochures and PDF forms ? Photoshop or InDesign ?

    Which is better software for brochures and PDF forms ? Photoshop or InDesign ? and why ?

    If you are going to be making a lot of brochures, with photos, you probably want both. Photoshop to edit the photos, and InDesign to assemble and layout images with text.

  • Which is better an android or apple

    Which is better getting an android smart phone or an Apple I Phone?

    As the poster Horses 547 said its a matter of personal preference. However I own and use both. Printing via air print is smooth and easy on an iphone. Printing on a android phone is iffy and tedious and you will have to find an app to print since there is no native app to do so. I purchased http://www.printhand.com which costs around $12 from the app store. but it is in my opinion the best printing app out there for android. I use it on my android tablet as well and its great. This company is the maker of the print app on iphones.
    The iphone is a little harder to put your own ringtone on the device. However very easy from the Itunes you put on your computer and hook into.
    Another thing an iphone does is if you use their cloud service or pay for a song it is available on all your ios devices. Iphone, ipad, or ipod or up to five computers registered through itunes on those computers.
    Google play music also can sync with all your android devices.
    Iphone don't have external Micro SD card slots, so the storage on the phone is all you have.
    Iphones use imessage which does not count against your text allotment  to another iphone or ipad user. it send regular text to non iphone users.
    Another thing is Face Time but I found a better program called oovoo at http://www.oovoo.com or in the Google Play Store for free.
    Iphones are paper thin but I have an android that has a larger view area and is also paper thin and light. Depending on the android phone it may have a removable battery, whereas iphones are sealed as are some new androids. I have found the sound for music better on my iphone, and videos are crystal clear. Again on some better androids the music and video is comparable .
    There is really not many differences but it up to the user.
    One last good thing is iphones are updated via Apple, no long waits for OS updates like is done with Android devices, and android devices on Verizon.

  • Which is better for doing animation? Flash 4, 5, MX, CS, or others?

    Which is better for doing animation? Flash 4, 5, MX, CS, or
    others?
    I am used to using brush function more conveniently in Flash
    4 than the other versions I ve tried. However, Flash 4 doesn't have
    pen tool.
    Free News Reader
    http://put.hk
    http://put.hk/reader/forums.macromedia.com/macromedia.flash.html

    1Evan2Wing3 wrote:
    > Which is better for doing animation? Flash 4, 5, MX, CS,
    or others?
    >
    > I am used to using brush function more conveniently in
    Flash 4 than the other versions I ve tried. However, Flash 4
    doesn't have pen tool.
    all pretty identical tho I would go with cs, just because I
    like the GUI much
    more than other versions...
    Best Regards
    Urami
    "Never play Leap-Frog with a Unicorn."
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Which is better for bulk message scenario in sap xi RFC or Proxy

    which is better for bulk message scenario in ( RFC or Proxy ) ?
    Edited by: prabhatxi on Aug 6, 2010 4:44 PM

    Proxy will alwaays be better option in this case, as it is adapter less framework, and communication happens directly with XI central integration engine. So it is always fast communication and gives good performance.
    But still you should consider other factors, you may consider using RFC as well, as sometime we go for RFC/IDOC as this are the standard interfaces already available rather than creating structure...
    May be you can share more info on what type/volume data are you planning to send via XI?
    Hope this cleart your doubt..
    Divyesh

  • Which is better - Add a dimension or create more members in an existing

    Which is better - Add a dimension or create more members in an existing dimension?
    We are trying to figure out which can give us better performance in terms of calculations and retrieving reports - to add another dimension (entity/country) or add about 500-800 more members in an existing location/division dimension?
    Thank you!

    If you have BSO cube i would recommend to add in the same dimension where as ASO you can add members in a new dimension. Adding a new dimension is like creating a new cube you have to change each and every single calc scripts,report scripts,FR reports,Webforms and your rule files .... all the dependencies has to be changed manually . I think 500 members in the exsting BSO dimension will not impact the calc or retrieval times that much .

Maybe you are looking for

  • Install windows RT on ARM Processor (Tegra 3 processor)

    Hi, I wondering whether I can install windows RT on any off the ARM processor hardware (OUYA gaming console) and I am trying to install it on the below configuration. Specifications: Tegra3 quad-core processor 1GB RAM 16GB of internal flash storage H

  • Problem with Periods' point of view on Financial Reporting Studio

    Hy all, i have a problem on some reports: i fix Periods' Point of View on Financial Reporting Studio signing in with Admin user. I do this to let other users see just a part of the dimension structure on workspace,but when i open workspace signing in

  • Change owner of HP eprint enabled printer

    I was forced to change my Google account name (it was an old account) when I signed up for Google  for Education. The old account was deleted and this was the account that was associated with my HP e printer. I cannot access the printer via a Chromeb

  • No Audio on AVI Files

    When I play my AVI movie files from my Casio Exilim camera on Quicktime, I can only see the video with no audio. But I can hear the audio on my PC with Windows Media player if I put them on a flash drive and transfer them to my PC. Is there a codec o

  • Image / Adjustments: Brightness/Contrast. Why is it crap now?

    Ever since we got CS3, I have to hit the "Legacy" button in the Brightness/Contrast to get decent results. I just tried again WITHOUT using the Legacy button to enhance a scan a little. I brightened it up a few notches and then dragged the contrast b