Skip to content

matteckert/EnumCollections

Repository files navigation

logo EnumCollections

Port of Java's EnumSet collection to C#

EnumSet

Overview

  • Performance characteristics are similar to the Java's EnumSet.
  • More efficient with Enum types that have less than or equal to 64 values.
  • Static factory methods similar to the Java version are provided: EnumSet.Of(Bird.Stork, ...)

Notes

  1. Enum constants defined with the same value are treated as aliases:

    public enum Bird { 
        BlueJay,        // 0
        Stork,          // 1
        Puffin,         // 2
        SeaParrot = 2,  // 2
        Chicken         // 3
    }
    
    var a = EnumSet.Of(Bird.SeaParrot);
    var b = EnumSet.Of(Bird.Puffin)
    Assert.That(a, Is.EqualTo(b)));
  2. When creating an empty EnumSet, you must specify the type:

    var a = EnumSet.Of<Bird>()

About

Port of Java's EnumSet collection to C#

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages