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 Details

    • CachedPair

      public CachedPair(T1 a, T2 b)
      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.
      Overrides:
      hashCode in class com.oracle.labs.mlrg.olcut.util.Pair<T1,T2>
      Returns:
      A 32-bit integer.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class com.oracle.labs.mlrg.olcut.util.Pair<T1,T2>