Package org.tribuo.util.infotheory.impl
Class CachedPair<T1,T2>
java.lang.Object
com.oracle.labs.mlrg.olcut.util.Pair<T1,T2>
org.tribuo.util.infotheory.impl.CachedPair<T1,T2>
- Type Parameters:
T1
- The type of the first object.T2
- The type of the second object.
- All Implemented Interfaces:
Serializable
public class CachedPair<T1,T2>
extends com.oracle.labs.mlrg.olcut.util.Pair<T1,T2>
A pair of things with a cached hashcode.
The cache is calculated on construction, and the objects inside the pair are thus expected to be immutable. If they aren't then the behaviour is undefined (and you shouldn't use this class).
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
Overridden hashcode.static <T1,
T2> ArrayList<CachedPair<T1, T2>> zipArraysCached
(ArrayList<T1> first, ArrayList<T2> second) Takes two arrays and zips them together into an array of CachedPairs.Methods inherited from class com.oracle.labs.mlrg.olcut.util.Pair
getA, getB, toString, zipArrays
-
Constructor Details
-
CachedPair
Constructs a CachedPair.- Parameters:
a
- The first element.b
- The second element.
-
-
Method Details
-
zipArraysCached
public static <T1,T2> ArrayList<CachedPair<T1,T2>> zipArraysCached(ArrayList<T1> first, ArrayList<T2> second) Takes two arrays and zips them together into an array of CachedPairs.- Type Parameters:
T1
- The type contained in the first array.T2
- The type contained in the second array.- Parameters:
first
- An array of values.second
- Another array of values.- Returns:
- The zipped array.
-
hashCode
public int hashCode()Overridden hashcode. Uses the cached value calculated on construction. -
equals
-