/** * A hash instance for a vector-3. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-3. */ public static <A> Hash<V3<A>> v3Hash(final Hash<A> ea) { return streamHash(ea).contramap(V3.toStream_()); }
/** * A hash instance for a vector-2. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-2. */ public static <A> Hash<V2<A>> v2Hash(final Hash<A> ea) { return streamHash(ea).contramap(V2.toStream_()); }
/** * A hash instance for a vector-6. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-6. */ public static <A> Hash<V6<A>> v6Hash(final Hash<A> ea) { return streamHash(ea).contramap(V6.toStream_()); }
/** * A hash instance for a vector-8. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-8. */ public static <A> Hash<V8<A>> v8Hash(final Hash<A> ea) { return streamHash(ea).contramap(V8.toStream_()); }
/** * A hash instance for a vector-4. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-4. */ public static <A> Hash<V4<A>> v4Hash(final Hash<A> ea) { return streamHash(ea).contramap(V4.toStream_()); }
/** * A hash instance for a vector-5. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-5. */ public static <A> Hash<V5<A>> v5Hash(final Hash<A> ea) { return streamHash(ea).contramap(V5.toStream_()); }
/** * A hash instance for the {@link Tree} type. * * @param ha A hash for the elements of the tree. * @return A hash instance for the {@link Tree} type. */ public static <A> Hash<Tree<A>> treeHash(final Hash<A> ha) { return streamHash(ha).contramap(Tree.flatten_()); }
/** * A hash instance for a vector-7. * * @param ea A hash for the elements of the vector. * @return A hash instance for a vector-7. */ public static <A> Hash<V7<A>> v7Hash(final Hash<A> ea) { return streamHash(ea).contramap(V7.toStream_()); }
@Override public final int hashCode() { return Hash.streamHash(Hash.<A>anyHash()).hash(this); }
public static <A> Hash<Set<A>> setHash(final Hash<A> h) { return hash(s -> streamHash(h).hash(s.toStream())); }
public static <A> Hash<Seq<A>> seqHash(final Hash<A> h) { return hash(s -> streamHash(h).hash(s.toStream())); }
public static <K, V> Hash<TreeMap<K, V>> treeMapHash(final Hash<K> h, final Hash<V> v) { return hash(t -> streamHash(p2Hash(h, v)).hash(t.toStream())); }
/** * A hash instance for the {@link TreeZipper} type. * * @param ha A hash for the elements of the tree zipper. * @return A hash instance for the {@link TreeZipper} type. */ public static <A> Hash<TreeZipper<A>> treeZipperHash(final Hash<A> ha) { Hash<Tree<A>> th = treeHash(ha); Hash<Stream<Tree<A>>> sth = streamHash(treeHash(ha)); Hash<Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>> tsp = streamHash(p3Hash(streamHash(treeHash(ha)), ha, streamHash(treeHash(ha)))); return hash(as -> { final int p = 419; int r = 239; r = p * r + th.hash(as.focus()); r = p * r + sth.hash(as.lefts()); r = p * r + sth.hash(as.rights()); r = p * r + tsp.hash(as.parents()); return r; }); }
/** * A hash instance for the {@link Zipper} type. * * @param ha A hash for the elements of the zipper. * @return A hash instance for the {@link Zipper} type. */ public static <A> Hash<Zipper<A>> zipperHash(final Hash<A> ha) { Hash<Stream<A>> sh = streamHash(ha); return hash(as -> { final int p = 419; int r = 239; r = p * r + sh.hash(as.lefts()); r = p * r + ha.hash(as.focus()); r = p * r + sh.hash(as.rights()); return r; }); }