Skip to content

Commit

Permalink
EnumSet.with() overloads.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Jan 10, 2025
1 parent 893aeee commit 1487c39
Showing 1 changed file with 131 additions and 0 deletions.
131 changes: 131 additions & 0 deletions src/main/java/com/github/tommyettinger/ds/EnumSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,137 @@ public static EnumSet with (Enum<?> item) {
set.add(item);
return set;
}
/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @param item3 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2, Enum<?> item3) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
set.add(item3);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @param item3 an Enum item
* @param item4 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2, Enum<?> item3, Enum<?> item4) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
set.add(item3);
set.add(item4);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @param item3 an Enum item
* @param item4 an Enum item
* @param item5 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2, Enum<?> item3, Enum<?> item4, Enum<?> item5) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
set.add(item3);
set.add(item4);
set.add(item5);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @param item3 an Enum item
* @param item4 an Enum item
* @param item5 an Enum item
* @param item6 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2, Enum<?> item3, Enum<?> item4, Enum<?> item5, Enum<?> item6) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
set.add(item3);
set.add(item4);
set.add(item5);
set.add(item6);
return set;
}

/**
* Creates a new EnumSet that holds only the given items, but can be resized.
* @param item0 an Enum item
* @param item1 an Enum item
* @param item2 an Enum item
* @param item3 an Enum item
* @param item4 an Enum item
* @param item5 an Enum item
* @param item6 an Enum item
* @return a new EnumSet that holds the given items
*/
public static EnumSet with (Enum<?> item0, Enum<?> item1, Enum<?> item2, Enum<?> item3, Enum<?> item4, Enum<?> item5, Enum<?> item6, Enum<?> item7) {
EnumSet set = new EnumSet();
set.add(item0);
set.add(item1);
set.add(item2);
set.add(item3);
set.add(item4);
set.add(item5);
set.add(item6);
set.add(item7);
return set;
}

/**
* Builds an EnumSet that contains the unique elements from the given {@code array} or varargs.
Expand Down

0 comments on commit 1487c39

Please sign in to comment.