// Path: src/main/java/org/paukov/combinatorics3/EmptyGenerator.java
// static <T> EmptyGenerator<T> emptyGenerator() {
//   @SuppressWarnings("unchecked")
//   EmptyGenerator<T> g = (EmptyGenerator<T>) EMPTY;
//   return g;
// }


import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.paukov.combinatorics3.EmptyGenerator.emptyGenerator;
/*
 * Combinatorics Library 3
 * Copyright 2009-2016 Dmytro Paukov d.paukov@gmail.com
 */
package org.paukov.combinatorics3;



public class PermutationGenerator<T> {

  final Collection<T> originalVector;

  PermutationGenerator(Collection<T> originalVector) {
    this.originalVector = originalVector;
  }

  public static <T> boolean hasDuplicates(Collection<T> collection) {
    if (collection.size() <= 1) {
      return false;
    }
    Set<T> set = new HashSet<>(collection);
    return set.size() < collection.size();
  }

  public IGenerator<List<T>> simple() {
    return new SimplePermutationGenerator<>(originalVector, false);
  }

  public IGenerator<List<T>> simple(TreatDuplicatesAs treatAsIdentical) {
    return new SimplePermutationGenerator<>(originalVector,
        TreatDuplicatesAs.IDENTICAL.equals(treatAsIdentical));
  }

  public IGenerator<List<T>> k(int length) {
    return new KPermutationGenerator<>(originalVector, length, false);
  }

  public IGenerator<List<T>> k(int length, TreatDuplicatesAs treatAsIdentical) {
    return new KPermutationGenerator<>(originalVector, length,
        TreatDuplicatesAs.IDENTICAL.equals(treatAsIdentical));
  }

  public IGenerator<List<T>> withRepetitions(int permutationLength) {
    return originalVector.isEmpty()
// Path: src/main/java/org/paukov/combinatorics3/EmptyGenerator.java
// static <T> EmptyGenerator<T> emptyGenerator() {
//   @SuppressWarnings("unchecked")
//   EmptyGenerator<T> g = (EmptyGenerator<T>) EMPTY;
//   return g;
// }


// Path: src/main/java/org/paukov/combinatorics3/PermutationGenerator.java
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.paukov.combinatorics3.EmptyGenerator.emptyGenerator;

/*
 * Combinatorics Library 3
 * Copyright 2009-2016 Dmytro Paukov d.paukov@gmail.com
 */
package org.paukov.combinatorics3;



public class PermutationGenerator<T> {

  final Collection<T> originalVector;

  PermutationGenerator(Collection<T> originalVector) {
    this.originalVector = originalVector;
  }

  public static <T> boolean hasDuplicates(Collection<T> collection) {
    if (collection.size() <= 1) {
      return false;
    }
    Set<T> set = new HashSet<>(collection);
    return set.size() < collection.size();
  }

  public IGenerator<List<T>> simple() {
    return new SimplePermutationGenerator<>(originalVector, false);
  }

  public IGenerator<List<T>> simple(TreatDuplicatesAs treatAsIdentical) {
    return new SimplePermutationGenerator<>(originalVector,
        TreatDuplicatesAs.IDENTICAL.equals(treatAsIdentical));
  }

  public IGenerator<List<T>> k(int length) {
    return new KPermutationGenerator<>(originalVector, length, false);
  }

  public IGenerator<List<T>> k(int length, TreatDuplicatesAs treatAsIdentical) {
    return new KPermutationGenerator<>(originalVector, length,
        TreatDuplicatesAs.IDENTICAL.equals(treatAsIdentical));
  }

  public IGenerator<List<T>> withRepetitions(int permutationLength) {
    return originalVector.isEmpty()
        ? emptyGenerator()