From ArrayList to HashMap

Discussion in 'Plugin Development' started by Moon_werewolf, Sep 26, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Moon_werewolf

    In my plugin nanobot (that is a world editor plugin) i use a ArrayList to store all blocks that my plugin as scanned and then a HashSet to what coordinates that been scanned so i don't scan the same block twice. now i maybe need to add a other ArrayList for my new save format

    I'm planing of useing HashMap<String,NanoMemmory> to see what blocks have been scanned and to save there information the only problem with that is the editing code i have then, now i just loop threw it


    Code:
    while(!isCompleted() && hasTimeLeft())
    {
    nanoMemmory.get(progress).run();
    progress++;
    }
    hasTimeLeft() is a function that stops the loop for one one second after very 250ms so the server don't freeze or lags then the block are being edited the problem i have with using a HashMap is if would do that how do i start from where i left off? i can't remove the block after being scanned for some of them i need later i don't know about clone() and keep in mind that that HashMap could contain 500 000 blocks
     
  2. Converting an arraylist to a hashmap is probably not a very good idea. Considering you are only holding 1 data type where a hashmap maps values to keys which requires 2 values.
     
  3. Offline

    Moon_werewolf

    but i have a HashSet with the exact same amount of elements the ArrayList
     
  4. You said hashmap, not hashset. If it's a hashset then just iterate through the array list and add each component to the hashset
     
  5. Offline

    K900

    If it's a hashset, you should use Collections.copy() and DO NOT iterate.
     
Thread Status:
Not open for further replies.

Share This Page