Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. UnOrdered SET

UnOrdered SET

Scheduled Pinned Locked Moved Java
question
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saadullah Bhutto
    wrote on last edited by
    #1

    hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)

    L T J B 4 Replies Last reply
    0
    • S saadullah Bhutto

      hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      by definition. sometimes an order is irrelevant to a collection, then use a set. It is like a mathematical set (remember Venn diagrams?). without any order, adding and removing items can be very fast operations. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      1 Reply Last reply
      0
      • S saadullah Bhutto

        hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)

        T Offline
        T Offline
        TorstenH
        wrote on last edited by
        #3

        as Luc says, it's so by definition. the Interface Set[^] is an extension to the interface Collection. And a Collection is unsorted - so it's most likely an inherited behavior.

        regards Torsten When I'm not working

        1 Reply Last reply
        0
        • S saadullah Bhutto

          hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          As a guess, most collections do not need to be ordered. Thus ordering is something that is best done by adding it to a collection when needed. Also if collections started out ordered then attempting to make them unordered, for performance reasons, would probably be hard if possible at all. So better if everything started out unordered.

          1 Reply Last reply
          0
          • S saadullah Bhutto

            hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)

            B Offline
            B Offline
            bennis98
            wrote on last edited by
            #5

            It is because, there is a SortedSet in java.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups