Create an insertion-ordered hash set using the provided
equals must define a stable equivalence relation, and
hashCode must be consistent with
If you supply one of
you should generally also supply the other.
hashCode functions might not work for all objects.
isValidKey is supplied, it's used to check a potential element
which is not necessarily an instance of
E, like the argument to
contains which is typed as
false, for an object, the
hashCode functions are not called, and no key equal to that object
is assumed to be in the map.
isValidKey function defaults to just testing if the object is an
E, which means that:
LinkedHashSet<int>(equals: (int e1, int e2) => (e1 - e2) % 5 == 0,
hashCode: (int e) => e % 5);
does not need an
isValidKey argument, because it defaults to only
int values which are accepted by both
isValidKey are provided,
isValidKey instead accepts all values.
The default equality and hashcode operations are assumed to work on all
equals is identical,
hashCode is identityHashCode
isValidKey is omitted, the resulting set is identity based,
isValidKey defaults to accepting all keys.
Such a map can be created directly using LinkedHashSet.identity.
external factory LinkedHashSet