Sets

hex.pm versionBuild Status

Well-structured Sets for Elixir, offering a common interface with multiple implementations with varying performance guarantees that can be switched in your configuration.

By default, Sets ships with:

Protocols and behaviours

All sets that are part of Sets implement the following protocols:

Creating your own Sets implementation:

If you want to create your own Sets implementation, create a module+struct that at least:

Implementing the other protocols and behaviours listed in the Protocols section is very helpful as well, as it is possible that certain other libraries expect a set implementation to work with them.

Examples

    iex> Sets.new([1,2,3,4])
    #Sets.Implementations.GbSet<[1, 2, 3, 4]>

    iex> Sets.new([1,2,3,4], implementation: Sets.Implementations.Ordset)
    #Sets.Implementations.Ordset<[1, 2, 3, 4]>

    iex> Sets.new([1,2,3,4], implementation: MapSet)
    #MapSet<[1, 2, 3, 4]>

    iex> Sets.union(Sets.new([1,2]), Sets.new([1]))
    #Sets.Implementations.GbSet<[1, 2]>

Installation

The package can be installed by adding sets to your list of dependencies in mix.exs:

def deps do
  [
    {:sets, "~> 0.1.0"}
  ]
end

Documentation can be found at https://hexdocs.pm/sets.