Package fj
Class Hash<A>
- java.lang.Object
-
- fj.Hash<A>
-
public final class Hash<A> extends java.lang.ObjectProduces a hash code for an object which should attempt uniqueness.
-
-
Field Summary
Fields Modifier and Type Field Description static Hash<java.math.BigDecimal>bigdecimalHashA hash instance for theBigDecimaltype.static Hash<java.math.BigInteger>bigintHashA hash instance for theBigIntegertype.static Hash<java.lang.Boolean>booleanHashA hash instance for thebooleantype.static Hash<java.lang.Byte>byteHashA hash instance for thebytetype.static Hash<java.lang.Character>charHashA hash instance for thechartype.static Hash<java.lang.Double>doubleHashA hash instance for thedoubletype.private F<A,java.lang.Integer>fstatic Hash<java.lang.Float>floatHashA hash instance for thefloattype.static Hash<java.lang.Integer>intHashA hash instance for theinttype.static Hash<java.lang.Long>longHashA hash instance for thelongtype.static Hash<Natural>naturalHashA hash instance for theNaturaltype.static Hash<java.lang.Short>shortHashA hash instance for theshorttype.static Hash<java.lang.StringBuffer>stringBufferHashA hash instance for theStringBuffertype.static Hash<java.lang.StringBuilder>stringBuilderHashA hash instance for theStringBuildertype.static Hash<java.lang.String>stringHashA hash instance for theStringtype.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <A> Hash<A>anyHash()A hash that usesObject.hashCode().static <A> Hash<Array<A>>arrayHash(Hash<A> ha)A hash instance for theArraytype.<B> Hash<B>contramap(F<B,A> g)Maps the given function across this hash as a contra-variant functor.static <A,B,C>
Hash<Either3<A,B,C>>either3Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc)static <A,B>
Hash<Either<A,B>>eitherHash(Hash<A> ha, Hash<B> hb)A hash instance for theEithertype.inthash(A a)Compute the hash of the given value.static <A> Hash<A>hash(F<A,java.lang.Integer> f)Construct a hash with the given hash function.static <A> Hash<List<A>>listHash(Hash<A> ha)A hash instance for theListtype.static <A> Hash<NonEmptyList<A>>nonEmptyListHash(Hash<A> ha)A hash instance for theNonEmptyListtype.static <A> Hash<Option<A>>optionHash(Hash<A> ha)A hash instance for theOptiontype.static <A> Hash<P1<A>>p1Hash(Hash<A> ha)A hash instance for a product-1.static <A,B>
Hash<P2<A,B>>p2Hash(Hash<A> ha, Hash<B> hb)A hash instance for a product-2.static <A,B,C>
Hash<P3<A,B,C>>p3Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc)A hash instance for a product-3.static <A,B,C,D>
Hash<P4<A,B,C,D>>p4Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd)A hash instance for a product-4.static <A,B,C,D,E>
Hash<P5<A,B,C,D,E>>p5Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he)A hash instance for a product-5.static <A,B,C,D,E,F$>
Hash<P6<A,B,C,D,E,F$>>p6Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf)A hash instance for a product-6.static <A,B,C,D,E,F$,G>
Hash<P7<A,B,C,D,E,F$,G>>p7Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf, Hash<G> hg)A hash instance for a product-7.static <A,B,C,D,E,F$,G,H>
Hash<P8<A,B,C,D,E,F$,G,H>>p8Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf, Hash<G> hg, Hash<H> hh)A hash instance for a product-8.static <I,A>
Hash<Result<I,A>>resultHash(Hash<A> ha, Hash<I> hi)A hash instance for theResulttype.static <A> Hash<Seq<A>>seqHash(Hash<A> h)static <A> Hash<Set<A>>setHash(Hash<A> h)static <A> Hash<Stream<A>>streamHash(Hash<A> ha)A hash instance for theStreamtype.static <A> Hash<Tree<A>>treeHash(Hash<A> ha)A hash instance for theTreetype.static <K,V>
Hash<TreeMap<K,V>>treeMapHash(Hash<K> h, Hash<V> v)static <A> Hash<TreeZipper<A>>treeZipperHash(Hash<A> ha)A hash instance for theTreeZippertype.static <A> Hash<V2<A>>v2Hash(Hash<A> ea)A hash instance for a vector-2.static <A> Hash<V3<A>>v3Hash(Hash<A> ea)A hash instance for a vector-3.static <A> Hash<V4<A>>v4Hash(Hash<A> ea)A hash instance for a vector-4.static <A> Hash<V5<A>>v5Hash(Hash<A> ea)A hash instance for a vector-5.static <A> Hash<V6<A>>v6Hash(Hash<A> ea)A hash instance for a vector-6.static <A> Hash<V7<A>>v7Hash(Hash<A> ea)A hash instance for a vector-7.static <A> Hash<V8<A>>v8Hash(Hash<A> ea)A hash instance for a vector-8.static <A,B>
Hash<Validation<A,B>>validationHash(Hash<A> ha, Hash<B> hb)A hash instance for theValidationtype.static <A> Hash<Zipper<A>>zipperHash(Hash<A> ha)A hash instance for theZippertype.
-
-
-
Field Detail
-
booleanHash
public static final Hash<java.lang.Boolean> booleanHash
A hash instance for thebooleantype.
-
byteHash
public static final Hash<java.lang.Byte> byteHash
A hash instance for thebytetype.
-
charHash
public static final Hash<java.lang.Character> charHash
A hash instance for thechartype.
-
doubleHash
public static final Hash<java.lang.Double> doubleHash
A hash instance for thedoubletype.
-
floatHash
public static final Hash<java.lang.Float> floatHash
A hash instance for thefloattype.
-
intHash
public static final Hash<java.lang.Integer> intHash
A hash instance for theinttype.
-
longHash
public static final Hash<java.lang.Long> longHash
A hash instance for thelongtype.
-
shortHash
public static final Hash<java.lang.Short> shortHash
A hash instance for theshorttype.
-
bigintHash
public static final Hash<java.math.BigInteger> bigintHash
A hash instance for theBigIntegertype.
-
bigdecimalHash
public static final Hash<java.math.BigDecimal> bigdecimalHash
A hash instance for theBigDecimaltype.
-
stringHash
public static final Hash<java.lang.String> stringHash
A hash instance for theStringtype.
-
stringBufferHash
public static final Hash<java.lang.StringBuffer> stringBufferHash
A hash instance for theStringBuffertype.
-
stringBuilderHash
public static final Hash<java.lang.StringBuilder> stringBuilderHash
A hash instance for theStringBuildertype.
-
-
Method Detail
-
hash
public int hash(A a)
Compute the hash of the given value.- Parameters:
a- The value to compute the hash value for.- Returns:
- The hash value.
-
contramap
public <B> Hash<B> contramap(F<B,A> g)
Maps the given function across this hash as a contra-variant functor.- Parameters:
g- The function to map.- Returns:
- A new hash.
-
hash
public static <A> Hash<A> hash(F<A,java.lang.Integer> f)
Construct a hash with the given hash function.- Parameters:
f- The function to construct the hash with.- Returns:
- A hash that uses the given function.
-
anyHash
public static <A> Hash<A> anyHash()
A hash that usesObject.hashCode().- Returns:
- A hash that uses
Object.hashCode().
-
eitherHash
public static <A,B> Hash<Either<A,B>> eitherHash(Hash<A> ha, Hash<B> hb)
A hash instance for theEithertype.- Parameters:
ha- Hash the left side ofEither.hb- Hash the right side ofEither.- Returns:
- A hash instance for the
Eithertype.
-
either3Hash
public static <A,B,C> Hash<Either3<A,B,C>> either3Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc)
-
resultHash
public static <I,A> Hash<Result<I,A>> resultHash(Hash<A> ha, Hash<I> hi)
A hash instance for theResulttype.- Parameters:
ha- Hash theResultvalue.hi- Hash theResultremainder.- Returns:
- A hash instance for the
Resulttype.
-
validationHash
public static <A,B> Hash<Validation<A,B>> validationHash(Hash<A> ha, Hash<B> hb)
A hash instance for theValidationtype.- Parameters:
ha- Hash the failing side ofValidation.hb- Hash the succeeding side ofValidation.- Returns:
- A hash instance for the
Validationtype.
-
listHash
public static <A> Hash<List<A>> listHash(Hash<A> ha)
A hash instance for theListtype.- Parameters:
ha- A hash for the elements of the list.- Returns:
- A hash instance for the
Listtype.
-
nonEmptyListHash
public static <A> Hash<NonEmptyList<A>> nonEmptyListHash(Hash<A> ha)
A hash instance for theNonEmptyListtype.- Parameters:
ha- A hash for the elements of the non-empty list.- Returns:
- A hash instance for the
NonEmptyListtype.
-
optionHash
public static <A> Hash<Option<A>> optionHash(Hash<A> ha)
A hash instance for theOptiontype.- Parameters:
ha- A hash for the element of the optional value.- Returns:
- A hash instance for the
Optiontype.
-
streamHash
public static <A> Hash<Stream<A>> streamHash(Hash<A> ha)
A hash instance for theStreamtype.- Parameters:
ha- A hash for the elements of the stream.- Returns:
- A hash instance for the
Streamtype.
-
arrayHash
public static <A> Hash<Array<A>> arrayHash(Hash<A> ha)
A hash instance for theArraytype.- Parameters:
ha- A hash for the elements of the array.- Returns:
- A hash instance for the
Arraytype.
-
zipperHash
public static <A> Hash<Zipper<A>> zipperHash(Hash<A> ha)
A hash instance for theZippertype.- Parameters:
ha- A hash for the elements of the zipper.- Returns:
- A hash instance for the
Zippertype.
-
treeZipperHash
public static <A> Hash<TreeZipper<A>> treeZipperHash(Hash<A> ha)
A hash instance for theTreeZippertype.- Parameters:
ha- A hash for the elements of the tree zipper.- Returns:
- A hash instance for the
TreeZippertype.
-
treeHash
public static <A> Hash<Tree<A>> treeHash(Hash<A> ha)
A hash instance for theTreetype.- Parameters:
ha- A hash for the elements of the tree.- Returns:
- A hash instance for the
Treetype.
-
p1Hash
public static <A> Hash<P1<A>> p1Hash(Hash<A> ha)
A hash instance for a product-1.- Parameters:
ha- A hash for the first element of the product.- Returns:
- A hash instance for a product-1.
-
p2Hash
public static <A,B> Hash<P2<A,B>> p2Hash(Hash<A> ha, Hash<B> hb)
A hash instance for a product-2.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.- Returns:
- A hash instance for a product-2.
-
p3Hash
public static <A,B,C> Hash<P3<A,B,C>> p3Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc)
A hash instance for a product-3.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.- Returns:
- A hash instance for a product-3.
-
p4Hash
public static <A,B,C,D> Hash<P4<A,B,C,D>> p4Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd)
A hash instance for a product-4.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.hd- A hash for the fourth element of the product.- Returns:
- A hash instance for a product-4.
-
p5Hash
public static <A,B,C,D,E> Hash<P5<A,B,C,D,E>> p5Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he)
A hash instance for a product-5.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.hd- A hash for the fourth element of the product.he- A hash for the fifth element of the product.- Returns:
- A hash instance for a product-5.
-
p6Hash
public static <A,B,C,D,E,F$> Hash<P6<A,B,C,D,E,F$>> p6Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf)
A hash instance for a product-6.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.hd- A hash for the fourth element of the product.he- A hash for the fifth element of the product.hf- A hash for the sixth element of the product.- Returns:
- A hash instance for a product-6.
-
p7Hash
public static <A,B,C,D,E,F$,G> Hash<P7<A,B,C,D,E,F$,G>> p7Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf, Hash<G> hg)
A hash instance for a product-7.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.hd- A hash for the fourth element of the product.he- A hash for the fifth element of the product.hf- A hash for the sixth element of the product.hg- A hash for the seventh element of the product.- Returns:
- A hash instance for a product-7.
-
p8Hash
public static <A,B,C,D,E,F$,G,H> Hash<P8<A,B,C,D,E,F$,G,H>> p8Hash(Hash<A> ha, Hash<B> hb, Hash<C> hc, Hash<D> hd, Hash<E> he, Hash<F$> hf, Hash<G> hg, Hash<H> hh)
A hash instance for a product-8.- Parameters:
ha- A hash for the first element of the product.hb- A hash for the second element of the product.hc- A hash for the third element of the product.hd- A hash for the fourth element of the product.he- A hash for the fifth element of the product.hf- A hash for the sixth element of the product.hg- A hash for the seventh element of the product.hh- A hash for the eighth element of the product.- Returns:
- A hash instance for a product-8.
-
v2Hash
public static <A> Hash<V2<A>> v2Hash(Hash<A> ea)
A hash instance for a vector-2.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-2.
-
v3Hash
public static <A> Hash<V3<A>> v3Hash(Hash<A> ea)
A hash instance for a vector-3.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-3.
-
v4Hash
public static <A> Hash<V4<A>> v4Hash(Hash<A> ea)
A hash instance for a vector-4.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-4.
-
v5Hash
public static <A> Hash<V5<A>> v5Hash(Hash<A> ea)
A hash instance for a vector-5.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-5.
-
v6Hash
public static <A> Hash<V6<A>> v6Hash(Hash<A> ea)
A hash instance for a vector-6.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-6.
-
v7Hash
public static <A> Hash<V7<A>> v7Hash(Hash<A> ea)
A hash instance for a vector-7.- Parameters:
ea- A hash for the elements of the vector.- Returns:
- A hash instance for a vector-7.
-
-