So i'm trying to make a copy of a vector....

... and it seems that i'm doing something wrong. I need to make a copy of the original vector because I need to clear it before the return statement(which returns a vector) so i'll have a clear vector to work with once the method is called again. I figure i'll just return the copy, but everytime I run my program its output isn't right unless I specifically return the first vector.
I've declared
Vector<Widget> original = new Vector<Widget>();
Vector<Widget> clone = new Vector<Widget>();at the beginning of the class, and put the following at the inside the method of interest, at the end (after the original was filled with elements):
clone = original;
original.clear();
return clone;that didn't work, so I tried this:
clone = (Vector<Widget>) original.clone();
original.clear();
return clone;That didn't work either. Can someone explain to me how this works and what i'm doing wrong?
Thanks.

I apologize... i'm aware that a few students in my class visit this site, and don't want them copying my code.
The code i've posted above is actually modified (changed the variable names), in an attempt to stop this.
Here is the more info:
What i'm trying to do is traverse a binary tree recursively for a (node.data).number that matches the argument the method takes in. The method is supposed to start at the root and add every node's data on the way to (and including) that particular node's data in to a vector, then return that vector.
The nodes have the parameters: (data, parentNode,leftNode, and rightNode) where the leftNode and rightNodes represent the children of the node. The "data" parameter is an object with several other parameters... the only one of interest being "number". The traveler2 variable represents a node that I initialized (as class variables) to the root and will be using to traverse the tree. The Widget vectors clone and original have already been initialized in the class (class variables). The compareTo method was defined in another class, and compares an integer object with a node's data's number, to see if it's equal or not.
public Vector<Widget> route(int widgetNumber)
          Integer wNumber = widgetNumber;
          clone.clear();
          if(wNumber.compareTo((traveler2.data).getNumber()) == 0 && wNumber!= null && traveler2.data != null)
               original.add(traveler2.data);
               traveler2 = root;
          else if(wNumber.compareTo((traveler2.data).getNumber()) == -1 && wNumber!= null && traveler2.data != null)
               original.add(traveler2.data);
               if(traveler2.leftNode == null)
                    traveler2 = root;
               else
                    traveler2 = traveler2.leftNode;
                    route(widgetNumber);
          else
               original.add(traveler2.data);
               if(traveler2.rightNode == null)
                    traveler2 = root;
               else
                    traveler2 = traveler2.rightNode;
                    route(widgetNumber);
          for(int i = 0; i < original.size(); i++)
              Widget fromOriginal = original.get(i);
              clone.add(new Widget(fromOriginal.getNumber(), fromOriginal.getW1(), fromOriginal.getW2(), fromOriginal.getW3(), fromOriginal.getW4(), fromOriginal.getW5()));
          original.clear();
          return clone;
     }The teacher has supplied an application that illustrates the path created when one runs the method. However, no path appears. No console errors either. I'm lost. If I were to take out the "original.clear();" line, and return original instead of clone, the method would work. However when it is called again, there is no way the path can be cleared to create a new one, thus providing an incorrect path (anytime other than the first time it is called).
Please help?
Thanks.
Edited by: klawson88 on Mar 12, 2009 10:24 PM
Edited by: klawson88 on Mar 12, 2009 10:26 PM

Similar Messages

  • Regarding Pages: I can't access the document I was writting on at all. I have tried to send the document to my email, I've tried to make a copy but nothing seems to work, it just shows up blank.

    Regarding Pages: I was writing using the app Pages when I left the page I was writting on but now I can't access it at all. I have tried to send the document to my email, I've tried to make a copy but nothing seems to work. The document still exists and I can see my writting as I can with all other documents but I can't open that page.

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Connect the iPad to your computer and try to get the document via File sharing
    - Try getting the document from iCloud.com if you are using iCloud

  • Scanner failure error message when trying to make a copy

    I have a continual scanner failure message on m y 750 xi when I try to make a copy.  Unit prints OK from my computer, but refuses to just make a simple copy.  I have tried shutting of and resetting and unplugging and all that stuff many times.  The light on the scanner does come on.  Thanks.

    I too am having this problem and have had, for about a week now.
    I've found that by logging off itunes (if I can), closing it down, and then restarting it, sometimes allows it to work for one transaction (say downloading an updated app). After that it's back to the same error.
    Really annoying.

  • Trouble with install disks - is it OK to make a copy of them?

    Finally, I am trying to make a copy of the install disks that came with my MBP. This was recommended in several threads for preserving the original and having backups just in case.
    I used Disk Utility to make a disk image - choosing DVD/CD master, no encryption - as I was instructed on another thread. I made the disk images fine of the 2 disks - they are now saved as disk images in the .cdr format. While I was at it, I made a disk image of the TechTool Deluxe CD that came with my AppleCare.
    When I inserted a CD (and then I tried a DVD) into the slot to Burn the disk image of the first (and then the second) install disk, I got the message that there is not enough room on the disk I am trying to use (for either disk). I had no trouble burning a disk of the TechTool Deluxe - I did that on a CD.
    When I go to Get Info for the disk image for the 2 install disks, it looks like each is no larger than 5 plus GB, which seems strange.
    What am I doing wrong?
    Mrs H

    When you make images of the discs, it is compressed. So when you get info of the image, that is smaller than the actual disc size. You said disc two was 3.97gb but really uncompressed it is likely over 6GB. For both install discs one and two, you need dual-layer DVDs to burn.
    Thanks for your help, mdpeterman.
    I wondered about the compressed issue - but since I chose CD/DVD master, (from Disk Utility Help: "If you want to use the disk image with a third-party application, choose CD/DVD master. The disk image contains a copy of all sectors of the disk, whether they're used or not, and copies them to other CDs or DVDs bit for bit") with no encryption I assumed that the size of the disk image was identical to the original.
    What you say tells me I'm wrong - that even with DVD master bit for bit, the image is compressed. Right?
    I'll get back to you when I have solved this...
    Mrs H
    Mrs H

  • Back up and Restore to make a copy of DB on another server

    I am trying to make a copy of a database on a dev server. I was going to back up the Prod DB on the Prod Server and Restore it on the Dev Server.  When I open the backup dialog, and select a Destination on disk it shows the disk drives on the Prod Server. 
    These are different than the drives I see on the Dev Server.  It doesn't look like I can browse to a directory outside the server.  Don't I need a destination that is available to both Servers? How do I set this up? Can I use my desktop machine?
    Any advice would be appreciated.
    Thanks,
    Mike

    Create a shared folder on dev server and simply use backup statement and provide disk=\\devserver\backup path.
    BACKUPDATABASE Proddb TODISK='\\devserver\backup\Proddb.bak'http://sql-articles.com/articles/general/backup-sql-database-to-remote-location/

  • Hp office jet wireless 6500 will not make a copy has been working fine until today.

    operating system imac has nothing to do with this I am just trying to make a copy.
    Just changed the ink today when the problem started. It still will not make a copy I just get a blank page.
    No changes of any kind.
    no error message.
    Thank you.
    This question was solved.
    View Solution.

    I searched other posts and someone suggested that I go to setup on the front of the printer and then tools. I did a cleaning twice and now it makes copies again. The first time I did the cleaning it still did not work, the second cleaning did it. I would strongly suggest to HP that they address this issue in their troubleshooting docs. They don't even mention not making a copy, they only talk about printing, two diiferent issues. 

  • Make Backup Copy of Installation DVD

    Trying to make backup copy of the SL installation DVD for my current model iMac . But I can't copy to a blank DVD (4.7 GB capacity) because image is 5.74 GB. Should I use a double layer DVD- and if so, what brands will work in the iMac?

    While you're at it, if you have 8-10 GB free on a hard drive, create a partition and use the Restore tab of +Disk Utility+ to copy it there, too.
    Then you can boot up and run from it instead of finding the disc (and it will boot and run much faster, too!).

  • I have a DVD I recorded from my tv.  I am trying to make copies and when I insert the DVD I get a message saying it is blank even though it is not.  My question are: Why does my computer think it's blank? And how can I copy a DVD?

    I have a DVD I recorded from my tv.  I am trying to make copies and when I insert the DVD, I get a message saying the DVD is blank, which it is not.  My questions are: Why does my computer think it's blank?  And how can I copy the DVD providing my computer recognizes there is content on it?
    Thanks, Sheila

    TV video typically is copyrighted content.  We'd be breaking several rules trying to help you.  Good luck!

  • Trying to make a DVD with an old/non-existent version of iDVD!

    Ladies and Gentlemen,
    Please could you help me?
    I work at a school in the UK, and have recently been able to purchase an external Lacie DVD drive, as the school’s computer (currently an iBook G4 with OSX 10.3.2 and a 1GHZ Power PC Processor – 640 MB Memory and a 40 GB HD) wasn’t shipped with one – however, I have a problem…
    Trying to make a DVD that will play in a stand-alone DVD player – I followed the advice in iMovie Help – but was stopped suddenly on finding that I do not have the relevant version of iDVD (which version (if any – I can’t see it anywhere!) was shipped with iMovie 4.0?). Is it possible to download a copy of iDVD 3 or later from anywhere compatible with OSX 10.3.2 and iMovie 4.0?
    The iMovie Help has an additional option to ‘export your movie in a format appropriate for DVD authoring’ which has let me burn the movie as a (name).DV file – but this is not compatible with any DVD player I have tried. I noticed a while ago on this forum that someone was talking about Toast but I do not have this, but I do have Roxio Easy Media Creator 7, which was bundled with the burner – but is only compatible with a PC – would I be able to build a project in iMovie, transfer it to a PC, and use REMC7 to do what toast would?
    Finally, I was wondering if anyone has any experience of using Avid’s free DV software – and if they would recommend it (and also if I would be able to make DVDs with it?).
    Well thanks for reading if you got this far – and I’d appreciate it if you could offer any advice (I know I’ve not been very concise)…
    Kevin.
    iBook G4   Mac OS X (10.3.2)  

    Thanks for the welcome Karsten! I’ve checked the installer disks – which appear to have all the main pieces of software, but not iDVD. If you or anyone knows where it might be hidden that would be great. Thanks for all the other info too!
    Thanks Lennart – I don’t think my computer could support iLife ’05 as it is running Mac OSX 10.3.2 and I’ve just been looking at its system requirements which state it requires 10.3.4 minimum – if you know differently, please let me know. As an alternative I have considered getting iLife ’04, but your comment about iLife ’05 being the first version to support external drives worried me (“iDVD 5 is the first iDVD version that officially supports external burners“ does this mean there is an unofficial option for iLife ‘04? Perhaps a patch similar to the one mentioned by Karsten), does that mean iLife ’04 would not support an external Lacie DVD writer?
    What is the earliest version of Toast I’d be able to use (as a money saving option!)?
    Thank you both, and apoligies for my amateurish questions…
    Kevin.

  • I need to make a copy of my SL installation DVD

    I have SL installed in both my iMAC and my MacBook Pro. However, just for security's sake, I'd like to make a copy of the Snow Leopard installation DVD that Apple had sent me. I tried to do so using Disk Utility under SL, but when it came to actually copy the created image on a blank DVD, the system advised me that I didn't have enough space on my DVD. Are there readily available higher capacity DVD on the market that would fulfill this purpose (Higher than the traditional 4.7 GB ones? I think there are, having made a google search, but is there a specially recommended brand? I don't want a cheap one, since we are talking about an important DVD that may save me lots of trouble in a possible future problem.

    To do so requires a dual-layer DVD-R. I would use a good brand such as Verbatim. Do the following:
    Duplicate a CD or DVD
    1. Insert the DVD/CD;
    2. Open Disk Utility, and select the DVD/CD from the left side list (select the DVD/CD icon on top);
    3. from the DU File menu select New | Disk Image from Disk 1;
    4. Choose to format the disk image as DVD/CD Master, name the disk image and click Save;
    5. When the .cdr file is finished select it with mouse and press COMMAND-I to open the Get Info and check the box to lock the file;
    6. Choose the .cdr file from the left side list, click Burn, and insert a new, blank DVD or CD.

  • I have tried and failed to copy my iTunes library and playlists from my Windows 8 desktop to my Windows 7 laptop using an external hard drive. Can it be done? Help would be appreciated.

    I have tried and failed to copy my iTunes library and playlists from my Windows 8 desktop to my Windows 7 laptop using an external hard drive. Can it be done? Help would be appreciated. I have followed instructions found online but the library of music doesn't pull in.  Thanks!
    Nate

    Migrate an iTunes library from one computer to another
    These are two possible approaches that will normally work to move an existing library to a new computer.
    Method 1
    Backup the library with this User Tip.
    Deauthorize the old computer if you no longer want to access protected content on it.
    Restore the backup to your new computer using the same tool used to back it up.
    Keep your backup up-to-date in future.
    Method 2
    Connect the two computers to the same network. Share your <User's Music> folder from the old computer and copy the entireiTunes library folder into the <User's Music> folder on the new one. Again, deauthorize the old computer if no longer required.
    Both methods should give the new computer a working clone of the library that was on the old one, with ratings, play counts, playlists etc. preserved. As far as iTunes is concerned this is still the "home" library for your devices so you shouldn't have any issues with iTunes wanting to erase and reload.
    I'd normally recommend method 1 since it establishes an ongoing backup for your library and unlike copying with Windows Explorer the process can be resumed if it is interrupted and it will continue to the next item if there are any read/access errors.
    Note if you have iOS devices and haven't moved your contacts and calendar items across then you should create one dummy entry of each in your new profile and iTunes should  merge the existing data from the device.
    If your media folder has been split out from the main iTunes folder you may need to do some preparatory work to make it easier to move. See Make a split library portable.
    Should you be in the unfortunate position where you are no longer able to access your original library or a backup then then seeRecover your iTunes library from your iPod or iOS device for advice on how to set up your devices with a new library with the maximum preservation of data.
    tt2

  • Trying to make a clone backup of my internal HD but my iMac no longer recognizes my external HD.

    Short story: I am trying to make a clone of my internal drive using Super Duper! but the 3 TB La Cie external hard drive I want to copy to isn't being recognized by finder or in disk utility. The external hard drive is powered and attached to the desktop via firewire cable. It was properly formatted and made one seemingly successful backup prior to this attempt.
    Specs: I have a 27 in iMac with 2 GHz Intel Core i7 processor, purchased in late 2009. Running Mac OS 10.6.8 with 8GB RAM.  I have a 2 TB internal HD with only 80 GB available.
    Background: I've had few if any problems with this computer but I'm running out of disc space. It's getting a little sluggish and I find that I am force quitting iPhoto more often than I used to. I was getting ready to put a long overdue (less labor intensive) backup plan in place. I had been using DVDs to back up photos and some documents. My computer crashed last week while working in iPhoto. The screen was speckled and banded and I could not restart.  I was able to boot in safe mode and run disk utility. The verification stopped (corrupted files found) and disk utility recommended repair.  I did a safe mode back up with time machine to the 3 TB ext HD. I tried unsuccessfully to run safe mode with networking to attempt online backup with Crashplan. I read something about installing mac os x on ext HD and then dragging files over to it, but DVD player not functional in safe mode. Then I called Apple support to run what I had done by them and to ask for advice before running disk repair.  We tried a PRAM reset but still couldn't restart in normal mode. He said my safe mode backup should be good and to run the repair, restore if necessary and if that doesn't work bring it to Apple for hardware testing.  I read somewhere that PRAM resets need to be done with a USB (not wireless) keyboard so I tried again doing a few PRAM/NVRAM resets.  No change. Later, maybe even the next day, the screen which had been banded and speckled looked normal again. Not sure why but happy.  I restarted successfully. I ran a time machine backup in normal mode to a 5 TB external HD and wanted to make a bootable clone of my mac HD to the 3 TB ext HD (in place of the safe mode backup). The computer crashed again for a little while and I was eventually able to restart. I downloaded Super Duper! but my mac no longer sees the 3 TB external drive. Maybe I did something wrong when I changed drives in time machine for the last backup?  I'm guessing I could crash again at any moment and would love to get this clone made.

    Yes. Formatted correctly. It' s new ext HD and I made a the first back up on it a few days ago using time machine while my computer was in safe mode. When I was able to restart my computer normally I quickly set up a time machine backup to my larger 5 TB ext drive. Also new and formatted for my mac. I was in a rush to get it going before I left for work so maybe I did something wrong. IDK. I can't remember but it did ask me about switching drives vs setting up. Although I don't see why the computer wouldn't see the drive.
    I did try another firewire cable and no change. Checked connections again.  The HD turns on and the blue light comes on  (it's a La Cie d2 quadra deskdrive)
    Is the SMC reset where you detach devices and restart?  My printer, keyboard and mouse are all wireless and right now I don't have anything else connected.
    I'll try another PRAM reset too.
    *  Question:
    When I connect the 3 TB drive it starts up but I don't see it on my desktop, finder sidebar or in disk utility. If a hard drive starts up but doesn't show up on your computer how do you safely shut it down before disconnecting?  I've been clicking on the desktop and then pressing the eject button on my keyboard just in case.

  • Need to make a copy/clone of a table which has sdo_geometry data type

    Folks,
    We are running Oracle 11gr1 on Suse Linux platform.
    We have a requirement, where we need to make a copy of a table, in the same database but in a difference schema, the source table has about 130 millions rows and also has the sdo_getometry data type.
    I tried materialized view, but MV does not support sdo_geometry data type.
    According to one of my DBAs, doing it via data pump , will take few days, which is not acceptable.
    Is there a way, we can make a copy of this table in the same db ?
    Thanks
    Ashish

    Siva,
    This is not for backup purpose.
    Here is the background information on this requirement.
    I need to have a static copy of a table, which has spatial column, sdo_geometry in it.
    So we can run another application against this table, just read-only, since we need static data, data in the source table changes quite often.
    One of my DBA suggested to have another instance/database, to keep the copy of the source table, I thought idea of having another database just to keep a copy of a table is an over kill.
    That is why I had asked this question and you had provided a viable solution.
    Then we need to refresh this table , with the data (changes) from the source table, maybe once in 2- 3 weeks.
    I tried creating a Materialized view, but it does not support Spatial columns.
    So now I am trying to figure out, the most efficient way to refresh the clone table from the source table.
    Regards,
    Ashish

  • I want to make a copy of all my pictures in iPhoto

    while working on a photo book my events, 242 of them, all got  mixed in just several big events.  I have been trying to create new events mostly of our trips but sometimes the event will appear and sometimes not.  The event will show but with no pictures.  I want to try the iphoto first aid but want to make a backup picture file off site first.  Do I copy the masters or original files.

    Neither. You back up the whole Library.
    Most Simple Back Up:
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex: Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically.
    Example of such apps: Chronosync - but there are many others. Search on MacUpdate or the App Store

  • How to make a copy of DefaultStyledDocument Object for RTF text ?

    Hi All,
    In my application, I need to copy RTF text from Org_Default_Styled_Document to New_Default_Styled_Document (both are independent objects.)
    For this I wrote the below method :
    public DefaultStyledDocument copyRTFStyledDocument(DefaultStyledDocument  Org_Default_Styled_Document)
              DefaultStyledDocument New_Default_Styled_Document = null;
              try
                            // writing RTF byte[] to output stream.
                   ByteArrayOutputStream bOData = new ByteArrayOutputStream();
                   rtfKitEditor.write(bOData, Org_Default_Styled_Document, 0, Org_Default_Styled_Document.getLength());
                            // reading RTF byte[] from input stream.
                   ByteArrayInputStream bIData = new ByteArrayInputStream(bOData.toByteArray());
                   New_Default_Styled_Document = new DefaultStyledDocument();
                   rtfKitEditor.read(bIData, New_Default_Styled_Document, 0);
              }  catch(BadLocationException e)   {
                e.printStackTrace();
              catch(IOException e)        {
                e.printStackTrace();
           return New_Default_Styled_Document;
      }I am able to see an extra 'enter' character (i.e, "\n") added to New_Default_Styled_Document.
    I tried to figure out the problem by digging API classes like RTFEditorKit.java and RTFGenerator.java, I observed that an extra 'enter' character is adding at the below method of RTFGenerator.java
    public void writeRTFTrailer()
        throws IOException
        writeEndgroup();
        writeLineBreak();
    public void writeLineBreak()
        throws IOException
        writeRawString("\n");
        afterKeyword = false;
    }I used
    New_Default_Styled_Document.remove(Org_Default_Styled_Document_Length, 1); to remove the extra 'enter character from New_Default_Styled_Document every time. Its workaround only.
    Can any one please help me how to make a new copy / clone of DefaultStyledDocument ? Is there any alternate solution which does not add any extra character when we make a copy of DefaultStyledDocument ?
    Its very urgent. I am trying a lot.
    Thanks in advance
    Satya.

    You will need to define an Organization hierarchy.
    1. Define your company as a Business Group and define the 3 child companies as Organizations (HR Organizations).
    2. Define Organization Hierarchy with 3 child organizations as child of the Business Group. You can further add organizations as childs to those three in the hierarchy.
    3. Define 3 security profiles (Security > Profile) marking View Employees / Contingent workers / Applications / Contacts as restricted. Click in the Organization Security tab. Select the option of Secure by Organization hierarchy option. Click in Organization hierarchy and select the one defined in step 2. Click in top Organization and select Company 1 / 2 /3 for each of the Security Profile. Check the box Include Top Organization. Also select the check box Restrict on Individual assignments option. Save the security profile(s).
    4. Define 3 HR Responsibilities (e.g. Company 1 HR, Company 2 HR, Company 3 HR). Using system profile HR:Security Profile, attach corresponding security profile to each of the responsibilities. Profile value of HR: Business Group is same for all the responsibilities.
    5. Run the Concurrent Program "Security List Maintenance" for each of the security profile.
    From now, One responsibility can not view data from another Organization and its child Orgs.

Maybe you are looking for

  • Decode function in where clause

    i am developing an sql code that includes decode keyword and in keyword : SELECT NAME FROM T WHERE NO_ID IN DECODE ( var, 1,1, 2,(SELECT ID FROM A)) when, var variable is equal to 2, there will be an error : ora-14027 single row subquery returns more

  • Description required on DOC Planning Your Oracle E-Business Suite Upgrade..

    Hi All Im planing to upgrade Oracle Applications from 11i to 12 i. while reading white paper "Planning Your Oracle E-Business Suite Upgrade from Release 11i to Release 12.1" i want some description on following lines How can we "Develop robust testin

  • Streaming over a network

    Hi All I can stream music from itunes to devices over my house, how can i do teh same for movies.

  • MailBox Move Request Statistics

    Hello, I am performing some mailbox moves on one of our systems here in testing for a migration. I believe I need to increase the number of CPUs on the virtual machine I am using but wanted to ask to be sure. Currently we have one of the return value

  • Purchased item not visible in Mac App Store

    I have tried downloading Mac OS X Mountain Lion from Mac App store...At the end of download..got error "The Application Could not be downloaded"..after full 4.37GB download..huh ! Now it is not found in my purchase list...when I go download link..it