Class OrderedSet<T>

All Implemented Interfaces:
Serializable, Iterable<T>, ICollection<T>, InvariantCheckable, ISet<T>, IStreamable<T>, Mapped<T,T>, SplitableIterable<T>

@Immutable public class OrderedSet<T> extends AbstractSetUsingMap<T> implements Serializable
ISet implementation built on top of an ordered set. During iteration elements are returned in the same order they were inserted into the set. Performance is slower than hash or tree sets but should be sufficient for most algorithms where insert order matters.
See Also:
  • Method Details

    • of

      public static <T> OrderedSet<T> of()
    • builder

      @Nonnull public static <T> ISetBuilder<T> builder()
    • deleteAll

      @Nonnull public ISet<T> deleteAll()
      Specified by:
      deleteAll in interface ICollection<T>
      Specified by:
      deleteAll in interface ISet<T>
      Returns:
      an equivalent collection with no values
    • setCollector

      @Nonnull public java.util.stream.Collector<T,?,ISet<T>> setCollector()
      Description copied from interface: ISet
      Returns a Collector that creates a set of the same type as this containing all of the collected values inserted over whatever starting values this already contained.
      Specified by:
      setCollector in interface ISet<T>
    • create

      protected ISet<T> create(IMap<T,Boolean> map)
      Description copied from class: AbstractSetUsingMap
      Implemented by derived classes to create a new instance of the appropriate class.
      Specified by:
      create in class AbstractSetUsingMap<T>
    • emptyMutableSet

      protected Set<T> emptyMutableSet()
      Description copied from class: AbstractSet
      Implemented by derived classes to create a new empty Set
      Specified by:
      emptyMutableSet in class AbstractSet<T>