Class OrderedHashSet<E>

java.lang.Object
de.tomatengames.util.data.OrderedHashSet<E>
Type Parameters:
E - The type of elements in this set.
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class OrderedHashSet<E> extends Object implements Set<E>
A set that maintains the insertion order of its elements. This class is a wrapper around an OrderedHashMap where each element is used as a key.

New elements are added to the end of the ordered set. Adding an element that is already present does nothing, its position is kept.

Since:
1.8
  • Constructor Details

    • OrderedHashSet

      public OrderedHashSet()
      Creates an empty ordered hash set.
    • OrderedHashSet

      public OrderedHashSet(Collection<? extends E> elements)
      Creates an ordered hash set containing all elements from the specified collection. The elements are added in the order they appear in the collection.
      Parameters:
      elements - The collection of elements to add to this set.
  • Method Details