Class Refs

java.lang.Object
convex.core.data.Refs

public class Refs extends Object
Static utilities for working with Refs
  • Constructor Details

    • Refs

      public Refs()
  • Method Details

    • visitAllRefs

      public static void visitAllRefs(Ref<?> root, Consumer<Ref<?>> visitor)
      Visit all Refs in a tree of Refs, in depth first order. Requires O(1) stack, O(n) time and O(depth) memory.
      Parameters:
      root - Root of Ref tree to visit
      visitor - Visitor function to call for each Ref
    • visitNonEmbedded

      public static void visitNonEmbedded(ACell a, Consumer<Ref<?>> visitor)
      Visit all non-embedded children of a Cell. Recursively checks embedded children.
      Parameters:
      a - Cell within which to visit children.
      visitor - Visitor instance
    • checkConsistentStores

      public static void checkConsistentStores(Ref<?> root, AStore store)
      Checks the complete tree of Refs is consistent with the given store
      Parameters:
      root - Root of Ref tree to visit
      store - Store to check consistency with
    • getRefTreeStats

      public static Refs.RefTreeStats getRefTreeStats(Ref<?> root)
      Gets statistics for a tree of Refs
      Parameters:
      root - Root node of Ref Tree
      Returns:
      Stats object
    • accumulateRefSet

      public static Set<Ref<?>> accumulateRefSet(ACell a)
      Accumulates the set of all unique Refs in the given object.
      Parameters:
      a - Ref or Cell
      Returns:
      Set containing all unique refs (accumulated recursively) within the given object
    • accumulateRefSet

      public static Set<Ref<?>> accumulateRefSet(Ref<?> root)
    • totalRefCount

      public static long totalRefCount(ACell a)
      Counts the total number of Refs contained in a data object recursively. Will count duplicate children multiple times.
      Parameters:
      a - Object to count Refs in
      Returns:
      Total number of Refs found
    • uniqueRefCount

      public static long uniqueRefCount(ACell a)
      Counts the number of logically unique Refs for a Cell, i.e. the number of unique cell values (including this Cell)
      Parameters:
      a - Cell to count Refs in
      Returns:
      Number of Refs found
    • printMissingTree

      public static void printMissingTree(StringBuilder sb, ACell value)
      Utility function to locate missing data
      Parameters:
      sb - StringBuilder to append to
      value - Value to search for missing data
    • printMissingTree

      public static String printMissingTree(ACell value)