Class CasCompare.Prev

  • Enclosing class:
    CasCompare

    private static class CasCompare.Prev
    extends java.lang.Object
    hold info about previous compares, to break cycles in references The comparison records cycles and can distinguish different cyclic graphs. When a cycle exists, it looks like: a b c d e f g h i a cycle starting with a, with refs ending up at i ^ v and then looping back to f *-----* This data structure measures both the cycle Length (in this example, 4) and the size of the starting part before hitting the loop (in this case 5) Note: when using, if two FSs end up comparing equal, the instances must be rolled back 1 item to allow further items to be compared in the chain. Example: a -> b -> c -> d d's compared equal, c may have ref next to "e".
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int cycleLen
      length of the cycle, excluding any leading ref chain -1 until some cycle is detected
      private int cycleStart
      length of the leading ref chain, excludes any cycle part -1 until some cycle is detected
      private java.util.ArrayList<TOP> fsList
      ordered list of traversed FSs, including duplicates
      (package private) TOP prevCompareTop
      ref to the top of the chain; used as a boolean flag
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Prev()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void add​(TOP fs)  
      (package private) void addTop()  
      (package private) void clear()  
      (package private) int compareCycleLen​(CasCompare.Prev other)  
      (package private) int compareUsize​(CasCompare.Prev other)  
      (package private) void rmvLast​(TOP fs)
      called when returning from compare with equal result If a loop exists, and the item being removed is the one that started the loopback, reset the loop info.
      (package private) int size()
      return size of ref chain including duplicates due to ref loops
      (package private) int usize()
      return -2 or the length of the cycle including 1 loop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fsList

        private final java.util.ArrayList<TOP> fsList
        ordered list of traversed FSs, including duplicates
      • cycleLen

        private int cycleLen
        length of the cycle, excluding any leading ref chain -1 until some cycle is detected
      • cycleStart

        private int cycleStart
        length of the leading ref chain, excludes any cycle part -1 until some cycle is detected
      • prevCompareTop

        TOP prevCompareTop
        ref to the top of the chain; used as a boolean flag
    • Constructor Detail

      • Prev

        private Prev()
    • Method Detail

      • clear

        void clear()
      • rmvLast

        void rmvLast​(TOP fs)
        called when returning from compare with equal result If a loop exists, and the item being removed is the one that started the loopback, reset the loop info.
        Parameters:
        fs -
      • addTop

        void addTop()
      • add

        void add​(TOP fs)
      • size

        int size()
        return size of ref chain including duplicates due to ref loops
      • usize

        int usize()
        return -2 or the length of the cycle including 1 loop