Collections

Discussion in 'Plugin Development' started by number1_Master, Apr 21, 2013.

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

    number1_Master

    I have a basic understand of Maps and List and what not, but I always wonder why there are multiple types of Maps and Lists. What are all the types of Collections out there (HashMap, ArrayList, List, Set, HashSet, etc) and what is the difference between each one? What is each set best in?

    I do know a HashMap implements Map, a HashSet implements Set, and a LinkedList and ArrayList implement a List. I have also read that an ArrayList is more memory-efficient then a LinkedList, however a LinkedList is faster (is this correct?).

    By the way, I do know how to use them. I am not asking how to use them. I'm asking about the different types of collections.

    Thank you!
     
  2. Offline

    Sagacious_Zed Bukkit Docs

  3. Offline

    number1_Master

    Yes, and I am not looking for how they work ... I'm looking for what the different types! Just a brief summary is all I would like. I've Googled it before, and what I remember is what I have already stated above.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Have you read the javadoc for each implementation? They provide a class summary right there. Also the class hierarchy for the interfaces.
     
  5. Offline

    number1_Master

    Its not really a short summary, but whatever.
     
  6. Offline

    Sagacious_Zed Bukkit Docs

  7. Offline

    Tirelessly

    LinkedLists provide faster inserting/removing at indexes, ArrayList has faster get methods.

    HashSet is different from the two as it doesn't allow duplicate entries and doesn't keep it's order.

    HashMaps provide key/value pairing. They do not allow duplicate keys and do not keep order.

    List, Set, and Map are the interfaces for these. They cannot be instantiated, you must provide an implementation.
     
    number1_Master likes this.
  8. Offline

    number1_Master

    Although I was hoping not to read a lot, I'm fine with your post. I've skimmed over the Implementations section and that is more or less what I'm looking for.
    This was the post I was hoping for:
    Thanks Tirelessly
    By any chance, can you clear up what a TreeSet is and what the big difference is between the inner-workings of a List and Set?
     
  9. Offline

    Tirelessly

    List - Keeps order, allows duplicates.
    Set - doesn't keep order in most implementations, doesn't allow duplicates. Faster contains, adding and removing (I believe).

    TreeSet - Orders it's entries by the comparator provided at creation time, or by their compareTo methods. Works much like a Set, otherwise.
     
    number1_Master likes this.
Thread Status:
Not open for further replies.

Share This Page