Putting items into hashmap and treemap

Hi all, this is my first time posting here, I tried doing a search but i didn't find what i was looking for so i hope someone out there and help me out~
Anyways, my question is that howcome when I am putting entries into either of these maps, the times for entry acutally gets faster as more entries are entered??
For instance, in my hashMap, it took approximately 8 seconds to enter 1447 entries, but when i am entering in 23042 entries, it takes just a bit over 1 second?
Does it have soemthing to do with how the methods in hashMap takes on constant time (O(1)) ?
the same thing happens for HashMap, but the time cost is (O(log n)) for putting entries so i am not sure how to explain this..
I hope someone understands my question, thanks in advance!

8 seconds for 1400 entries sounds VERY long.
In any case, earlier chunks may take longer due to VM startup or hotspot warmup overhead. Resizing the backing store, GC, VM acquiring more memory, OS giving CPU time to other proesses, etc., could all throw off your timing.
I got the following results:
HashMap:
first 350,000: 1 s
next 300,000: 1 s
next 250,000: 1 s
TreeMap:
First 100,000: 1 s
Next 50,000: 3 s
Next 100, 000: 2 s
Next 50,000: 1 s
Next 50,000: 1 s
and so on--generally 1 or 2 seconds per 50,000
import java.util.*;
public class MapTiming {
  public static void main(String[] args) throws Exception {
    Map<Integer, Integer> hm = new HashMap<Integer, Integer>();
    Map<Integer, Integer> tm = new TreeMap<Integer, Integer>();
    long start;
    start = System.currentTimeMillis();
    for (int ix = 1; ix <= 1000000; ix++) {
      hm.put(ix, ix);
      if (ix % 50000 == 0) {
        long end = System.currentTimeMillis();
        System.out.println("HashMap " + ix + ": " + ((end - start) / 1000) + " sec.");
    start = System.currentTimeMillis();
    for (int ix = 1; ix <= 1000000; ix++) {
      hm.put(ix, ix);
      if (ix % 50000 == 0) {
        long end = System.currentTimeMillis();
        System.out.println("TreeMap " + ix + ": " + ((end - start)/ 1000)+ " sec.");
:; java -cp classes MapTiming
HashMap 50000: 0 sec.
HashMap 100000: 0 sec.
HashMap 150000: 0 sec.
HashMap 200000: 0 sec.
HashMap 250000: 0 sec.
HashMap 300000: 0 sec.
HashMap 350000: 1 sec.
HashMap 400000: 1 sec.
HashMap 450000: 1 sec.
HashMap 500000: 1 sec.
HashMap 550000: 1 sec.
HashMap 600000: 1 sec.
HashMap 650000: 2 sec.
HashMap 700000: 2 sec.
HashMap 750000: 2 sec.
HashMap 800000: 2 sec.
HashMap 850000: 2 sec.
HashMap 900000: 3 sec.
HashMap 950000: 3 sec.
HashMap 1000000: 3 sec.
TreeMap 50000: 0 sec.
TreeMap 100000: 1 sec.
TreeMap 150000: 4 sec.
TreeMap 200000: 4 sec.
TreeMap 250000: 6 sec.
TreeMap 300000: 7 sec.
TreeMap 350000: 8 sec.
TreeMap 400000: 11 sec.
TreeMap 450000: 12 sec.
TreeMap 500000: 14 sec.
TreeMap 550000: 14 sec.
TreeMap 600000: 16 sec.
TreeMap 650000: 18 sec.
TreeMap 700000: 19 sec.
TreeMap 750000: 21 sec.
TreeMap 800000: 22 sec.
TreeMap 850000: 25 sec.
TreeMap 900000: 25 sec.
TreeMap 950000: 26 sec.
TreeMap 1000000: 29 sec.

Similar Messages

  • Is there a software that will allow DVD video to put inserted into computer and uploaded into Mac iMovie?

    Is there a software that will allow DVD video to put inserted into computer and uploaded into iMovie on my MacBook Pro?

    Check out this user tip and see if it helps.
    https://discussions.apple.com/docs/DOC-3951

  • I have put epubs into ibooks and i would like to know how i can then export them to an email or dropbox?

    I have put epubs into ibooks and i would like to know how i can then export them to an email or dropbox?

    You will have to go via your computer's iTunes. Connect the iPad to your computer's iTunes and do File > Devices > Transfer Purchases in iTunes (that should copy epubs and/or PDFs that are in the iBooks app, not just actual ibooks), and if using a Mac with Mavericks or Yosemite on it then do File > Move Books From iTunes in its iBooks app. You can then email them or add them to Dropbox from your computer.

  • I recently created a new folder, dragged some items into it, and found that the entire contents of my desktop appeared to be in there as well. This happens every time I make a new folder. Any suggestions?

    I recently created a new folder on my MacBook, dragged some items into it, and found that the entire contents of my desktop appeared to be in the folder as well. This happens every time I make a new folder. Any suggestions?

    Csound1 What Ive been trying to explain is that I have been running bootcamp, I open the app where the first screen is the introduction, i hit continue, the first time I select "download the latest windows support software fromm Apple" then I return and instead select "Install Windows 7." Then hit continue. The third screen is where I "Create a Partition for Windows" I set Windows to 80 gigs then hit INSTALL. As stated before Bootcamp cannot find the install drivers saying "The installer disc could not be found." My windows software is on a USB drive not a disc, I tried using a virtual disc reader to make it appear that the windows software was running on a disc, still no luck. What I would like to know is how to install windows on bootcamp.

  • HT1212 My 7 year pls has forgotten her passcode for her iPod touch. I have put it into recovery and through iTunes tried to restore. But it will only let me also try to update it with iOS 6.1.3 which no longer allows the bypass of the passcode. Can anyone

    My 7 year old has a passcode on her iPod touch. She forgot it, after multiple attempts at what it could have been, it comes up with disabled etc.....I have tried it in recovery and hooking it up to iTunes (which the device has been previously synced up to) to restore. But the problem I am having is it only gives me the option to update also, to iOS 6.1.3 with the new bug fix which it won't allow you to bypass the passcode. It gets a little into the downloading, turns the iPod on and then asks for the passcode to continue?! I am at a loss as to what to do now, as every forum says put it in recovery and restore. I can't use the 'find my iPhone' app as the iPod is offline. I've tried it on a laptop not prev synced up to and get the same problem. Has any one got any ideas!

    Try disabling the computer's antivirus and firewall.
    - Next try the manual install method of:
    iDevice Troubleshooting 101 :: iPhone, iPad, iPod touch
    Place the iPod in recovery mode after the firmware download is complete and then restore using the instructions in the article. Sometimes recovery mode timeouts and returns to disabled before the firmware download is complete.
    - Then try on another computer

  • Before i updated to ios6 i took off all my apps into iTunes and then when i went to put them back in on my ipod it says " 'app name' failed to install" anyone know whats wrong?

    before i updated to ios6 i took off all my apps and put them into iTunes and then when i went to put them back in it says syncing like normal then when i look on my ipod it says " 'app name' failed to install" anyone know whats wrong?

    In iTUnes 7....
    Connect the ipod. On the ipod summery page hit the "Music" tab. Set it to "Auto update select" and check the playlist you want on the ipod then hit "Apply" in the bottom righthand corner

  • Apple Software Update HP 2.12 Freezes At "Moving Items Into Place"

    This morning Software Update notified me of a printer software update, namely HP 2.12. I quit all other applications and commenced with the update. It made it to "moving items into place" and then froze. I waited for 20 to 30 minutes and there was no progress on the installation past that point. I waited a little longer and then did a hard restart and tried again. Same results except this time I left it for several hours. I had to hard restart again and then downloaded the update manually to install it thinking that there was a problem with Software Update itself. The updater has frozen at the same place. I am working on a Macbook early 2008 running 10.7.5 with 4 GB 667 MHz DDR2 SDRAM. Does anyone have any recommendations on how to deal with the problem? Thank you.

    Irelander,
    Glad to hear you are back up and running. Please let us know ASAP if you run into further problems.
    Best of Luck!
    I work with HP but my posts and opinions are my own.

  • Placing library item into page

    This script for placing library item into page and applying object style to the item. In line 16, script shows that "assets" property does not support. Please resolve this.
    if (app.documents.length==0){
        alert("Please open the Document");
        exit();
    if (app.libraries.length==0){
        alert("Please open the Library");
        exit();
    app.findTextPreferences=app.changeTextPreferences=null;
    app.findTextPreferences.appliedParagraphStyle="MN";
    var myfound=app.activeDocument.findText();
    alert(myfound.length);
    for(i=0; i<myfound.length; i++){
    var mylib=app.libraries.assets.itemByName("Box").placeAsset(myfound[i].insertionPoints[0]);
    var mymove=myfound[i].move(LocationOptions.atBeginning, mylib.insertionPoints[0])
    mylib.appliedObjectStyle="MN_Obj";

    To make that work, you have to address an open library (line 16).
    app.libraries describes the collection of all open libraries, not a distinct one.
    If only one library is open you could address the one with its index:
    app.libraries[0]
    If you already know the name of the library or better, the exact path of the library, you can:
    1. Make sure to open it
    2. Call it by its name
    Let's assume you know the name and you know that the asset you want to place is stored inside, you could do it this way:
    app.libraries.itemByName("TheNameOfTheLibrary").assets.itemByName("Box").placeAsset(
    /*Wherever you want*/
    Now, what will this line return?
    A library object? Hardly. So be cautious with using a variable name like "mylib".
    According to documentation it is returning an Array, and we can assume, that in this array is the object that is placed out of the library. Your asset stored in the library which goes by the name of "Box". Whatever that is.
    If you want to find out, you can use the following, more descriptive variable: "myPlacedAsset". That sounds more neutral.
    var myPlacedAsset = app.libraries.itemByName("TheNameOfTheLibrary").assets.itemByName("Box").placeAsset(
    /*Wherever you want*/
    Using the ESTK (ExtendScript Toolkit) together with $.writeln() can write the true nature of the placed asset to your JavaScript Console:
    $.writeln(myPlacedAsset.constructor.name);
    is informing you what kind of object "myPlacedAsset" really is. If indeed it is an Array, you could look for its length. If its length is "1", you get to the "heart" of your placed object by:
    $.writeln(myPlacedAsset[0].constructor.name);
    Or by that more inquisitory question:
    $.writeln(myPlacedAsset[0].getElements()[0].constructor.name);
    If your array is of a greater length, you have to loop through this array and question every single object!
    Before testing, exchange my comment "/*Wherever you want*/" with the code you like to use: Obviously the first insertion point of your found text. Hold on! This will backfire to you, because every time you place one instance of the asset you will add a character to your found text and shift the original insertionPoint. Better loop from back to forth or do the search from back to forth.
    Adobe InDesign CS6 (8.0) Object Model JS: Text
    Please, try that and report back…
    (Isn't noone reading the documentation these days?)
    Indesign JavaScript Help
    Adobe InDesign CS6 (8.0) Object Model JS: Table of Contents, Libraries Suite
    Adobe InDesign CS6 (8.0) Object Model JS: Library
    Adobe InDesign CS6 (8.0) Object Model JS: Asset
    Adobe InDesign CS6 (8.0) Object Model JS: Asset
    Uwe

  • HT4847 How do I put my iPhone stored items into my iCloud storage?i have bought an upgrade but none of my phones stored items have moved to iCloud.i can't download new update from apple. due to not enough and yet iCloud space is empty??please help thanks

    How do I put my iPhone stored items into my iCloud storage?i have bought an upgrade but none of my phones stored items have moved to iCloud.i can't download new update from apple. due to not enough and yet iCloud space is empty??please help I don't know what I doing all I know is my phone is iPhone 4 and I can't update it. My phone on contract with t-mobile . Thanks

    You can't have content in iCloud without having it on your phone, you will need to look at deleting items from your device that you don't need. Movies and TV shows from iTunes are possibly a good start because they tend to be large and can be redownloaded at a later date.

  • Putting Apps into new computer and new Itunes, Aithorization dosnt work.

    I just got a new mac and I wanted to snyc my ipod. Using an external hardrive i have already put all my music on but i didnt put on my apps because there wasnt enough space. Now when I snyc my touch it comes up with the sign "would you like to transfer purchased items into itunes" of course I click yes, then it goes on. At this point I should mention I have already authorized my computer for music and apps. When the snycing starts it suddenly stops and says that it cant import the apps because my computer is not authorized, even though it is. to make it worse, the first time i snyced after authorizing the computer 6 apps made it but the rest said my com needed to be authorized. I dont wanna have to lose all those apps (56 in total alot i know) so CAN ANYONE HELP!!!!!!

    This is the process I would have recommended:
    Backup your library using this User Tip.
    Deauthorise the old computer if you won't be using it for iTunes.
    Restore the library into the music folder on the new computer.
    Install iTunes and sign in to your account.
    For the "restore" process you can either just copy the backed up iTunes folder into the new computer or install and set up SyncToy to manage the transfer. If you install iTunes before restoring the library then you should delete/rename the existing empty iTunes library in your profile's music folder first.
    Reconnecting an old iOS device backup set into a new iTunes installation is actually quite tricky, but provided the library has been properly conserved it is an unnecessary step. A library transferred as outlined above will be the same library the device was previously synced with, albeit on a different computer/operating system, and there should be no problem syncing media or apps. Info content such as calendar and contacts may need a little more care to make sure the same applications have as used previously have been installed and their data restored to them.
    tt2

  • Putting multiple items into a single column in a datagrid

    Okay,
    So I can put information into a datagrid, I can select a row
    and make sure that it populates that row. I can even make it hit
    that specific row and column.
    How do I got about having several different buttons all
    writing in the same column? And perhaps even ordering it? i.e. The
    column would look like this: buttonOneInput, buttonTwoInput,
    buttonThreeInput etc etc
    I'd also like to sort the way this information goes in (just
    being able to sort by alpha right now would be fine, but better yet
    if I could sort it so button one always was in the front, button
    two always in the middle, button three always in the end)
    The end application of this is that I need to populate a
    datagrid with several different button groups, there are 5 groups,
    each group contains about 10 buttons. The groups need to appear in
    a specific order in the datagrid, and I need to be able to add as
    many button's information to the grid as possible.
    After this stuff all goes in, I need to get it back out too.
    I think I'll be able to figure that part out.
    Now, I know this is a lot of stuff. I don't even know if it's
    possible, but it seems like it should be, I've been trying to
    figure it out all day to no avail.
    Any tips / suggestions / code snippets / links to tutorials
    would be helpful.
    Thanks.

    Well, specifically. They're binded data (swfs) I need the
    ability to add as many of these as possible to a datagrid. I'll be
    extracting them and using them in a list.
    So to break it down, I've got a bunch of different strings I
    need to add to a datagrid item. I need to add these in the proper
    order. I then need to pop them back out to a list (I know how to do
    this part).
    Basically what I'm going on right now, is I'm calling a
    flashfile.source from a selected item. Then I'm adding it into a
    datagrid, I just need to know how to add it in without destroying
    the current items.
    Would something work where I'd ask for the current data
    datagrid.selectedItem.column and then also add the new data work?
    Thanks for your help miaomm, I'd really appreciate some code
    showing this .

  • Put some data form the databse of SQL Server into SAP and auto general PR?

    Dear all,
            Can you tell me how I can put some data from the databse of SQL Server into SAP and auto general PR?
    Best regards,
    Merryzhang
    Edited by: merry zhang on Feb 4, 2009 9:10 AM

    Hi Zhang,
    If i have understood your question properly, I guess you wanted to create Purchase Requistion automatically right?
    Then you have lots of option simpilest one would be create a couple of Z table with all the fields that you require for header and Item.
    create a Program and use BAPI function module to create the PR by reading the values from those Z tables. after creation delete the contents from the table. Schedule this program in Background periodically like everyday or weekly once however you would like it to be. So once the table has contents in it and when the program runs it will create the PR's (Purchase Requisition).
    You can also use a workflow with the Z table. Once the Z table is filled you can trigger a workflow based on the Table change. I'm not sure like how to do it but I nkow that this process can also be used.
    Hope this might have thrown some light upon.
    Thanks,
    Prashanth

  • I am trying to put music into my 3rd gen ipod touch and older ipod shuffle but they do not show up on Itunes when i connect them,what could be the problem?

    i am trying to put music into my 3rd gen ipod touch and older ipod shuffle but neither are popping up on itunes, what could be the problem?

    See
    iOS: Device not recognized in iTunes for Windows
    - I would start with
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or              
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    However, after your remove the Apple software components also remove the iCloud Control Panel via Windows Programs and Features app in the Window Control Panel. Then reinstall all the Apple software components
    - New cable and different USB port
    - Run this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    Also see:
    iPod not recognised by windows iTunes
    Troubleshooting issues with iTunes for Windows updates
    - Try on another computer to help determine if computer or iPod problem

  • I'm using Windows 8.  I have 2 folders in my videos library - movies and personal videos.  When I try to import a movie into iTunes, it puts it in the Home Video section and if I import a personal video, it puts it into the home video section.  what up?

    Im using Win8.  I originally had all my ripped movies in a movie folder listed in the videos library.  This imported into iTunes movies with no issue.  I later added a second folder t my library - personal videos where i put all my home videos.  I was able to import this into iTunes and it showed up in "Home Movies" - very cool and exactly what I wanted.  Now, if I add a new ripped movie and put it in my movie librairy and try to import it into iTunes, it places it in Home Movies.  And if I put a new personal video, it will also import into iTunes under 'Home Video?.  What is going on here??  Any help would be greatly appreciated - it seems like this is a bug in iTunes 11.

    I thank you for the response.  Apple does some assinine things sometimes and this is one of them.  Ask the planet the difference between a movie and a home video and with the exception of Apple, you'd get 100% consenus on the what difference is.  A home video is something that I shoot, like my kids birthday party.  A movie is something I urchased either via download or a DVD that I ripped.  Unbelievable!   The fact that Apple has chosen not to distinguish based upon which folder I tell it is Movies and which folder is Home Videos is really hard to fathom - sounds like something Windows would do. I find it funny that in my iTunes movies sub-section of the movies section, the movie icons have a cloud icon in upper right corner to distinguish it as bought from Apple iTunes versus no cloud icon for movies that I have ripped - so the distintion was already made and clearly visible.  Now - everything just defaults to "home videos" if I try to import a new ripped DVD - why even bother to have this distinction on the iTunes bar?  WOW!
    As for your direction, I do not understand what you are telling me - what Media Kind and what Options tab are you referring to?  I see no Options tab in iTunes.  Right licking on the movie icon does not yield media kind or options as well.  Gping to the source file does not yield these options either.
    Thanks again for your help.
    Clay

  • How do I get the pictures folders in photoshop 7 out of My window XP computer and put them into my new computer windows 8 photoshop12

    How do I get the pictures folders in photoshop 7 out of My window XP computer and put them into my new computer windows 8 photoshop12

    I am so sorry for you and your situation. Were you using iCloud photostream?
    Otherwise I do not see any chance for your precious photos.
    Congrats anyway on the little darling!

Maybe you are looking for

  • Return multiple values from a web method??

    Hi, I am wondering if it's possible for a web method to return multiple values to a client. I know each web method can return only one value of a given data type. I am looking for something like ref or out keyword in C#. If it's not available, is the

  • How do i contact apple to make a complaint

    Im currently travelling around australia but im from the uk..i have only been in australia for 3 days and my phone has stopped working, it would not turn on. I ook it into an apple store in bondi, i had to wait 2 hours for an appointment, at the appo

  • Dynamic column Name# Contains Invalid Characters. Bind_table() fails

    Hi WD experts, I have tried to use the bind_table() on a dynamically generated table. Now it happens that this dynamic table contains  columns like NAME# . This gave rise to a dump : The Name NAME# Contains Invalid Characters. Valid Characters are A-

  • Graphics for 24P

    Is there an effective way to create graphics in Motion for 24P footage that doesn't look like video graphics? For example, I want to create a lower third for an interview shot in 24P. When I use LiveType, the lower third background and text look like

  • Safari Losing Internet Connection

    We are using Safari 5.0.5 and are having intermittent problems with it holding its wifi connection. Other computers (including an IPad 1) have no problem maintaining the signal, and the computer with this problem (a Macbook) is able to access mail an