4 Replies Latest reply: Nov 23, 2007 2:51 PM by 807600 RSS

    ArrayList to hashset ordering problem

    807600
      Hi there,
      I have an arraylist with repeated values in, so i copy the values into a hashset, to get rid of duplicates. However, when the values are copied into the hashset it is done so that they are not in the order they appear in the arraylist.
      The array list looks like this:
      item 1
      item 1
      item 2
      item 2
      item 2
      item 3
      item 3
      item 3
      but the hashset comes out:
      item 1
      item 3
      item 2

      Does anyone know another data structure that can be used to get rid of duplicates, or a way to modify the hashset so that it maintains the correct order?
      Thanks
      beccy