Class CustomSet<T>

java.lang.Object
net.sf.saxon.expr.sort.CustomSet<T>
Type Parameters:
T - The type of the entries in the set

public class CustomSet<T> extends Object
A mutable set implementation using a custom equality matcher, to avoid having to wrap each entry in a wrapper object to achieve customised equality testing.

Note: this doesn't implement java.util.Set<T>. This is to save the effort of implementing methods like size() and iterator() that aren't required for our use cases. These methods could easily be added without changing the basic design.

  • Constructor Details

    • CustomSet

      public CustomSet(EqualityMatcher<T> matcher)
      Create an empty set using the supplied equality matcher
      Parameters:
      matcher - the function used to compare items for equality
  • Method Details

    • add

      public boolean add(T value)
      Add a value to the set
      Parameters:
      value - the value to be added.
      Returns:
      true if the value is newly added, that is, if it was not already present
    • contains

      public boolean contains(T value)
      Ask if a value exists in the set
      Parameters:
      value - the requested value
      Returns:
      true if it exists