Class AVLGroupTree

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<Centroid>, java.util.Collection<Centroid>

    final class AVLGroupTree
    extends java.util.AbstractCollection<Centroid>
    implements java.io.Serializable
    A tree of t-digest centroids.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(double centroid, int count, java.util.List<java.lang.Double> data)
      Add the provided centroid to the tree.
      boolean add​(Centroid centroid)  
      (package private) void checkAggregates()  
      private void checkAggregates​(int node)  
      (package private) void checkBalance()  
      int count​(int node)
      Return the count for the provided node.
      java.util.List<java.lang.Double> data​(int node)
      Return the data for the provided node.
      int first()
      Return the least node in the tree.
      int floor​(double centroid)
      Return the last node whose centroid is less than centroid.
      int floorSum​(long sum)
      Return the last node so that the sum of counts of nodes that are before it is less than or equal to sum.
      long headSum​(int node)
      Compute the number of elements and sum of counts for every entry that is strictly before node.
      java.util.Iterator<Centroid> iterator()  
      private java.util.Iterator<Centroid> iterator​(int startNode)  
      double mean​(int node)
      Return the mean for the provided node.
      int next​(int node)
      Return the next node.
      int prev​(int node)
      Return the previous node.
      int size()
      Return the number of centroids in the tree.
      int sum()
      Return the total count of points that have been added to the tree.
      void update​(int node, double centroid, int count, java.util.List<java.lang.Double> data)
      Update values associated with a node, readjusting the tree if necessary.
      • Methods inherited from class java.util.AbstractCollection

        addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • centroid

        private double centroid
      • count

        private int count
      • data

        private java.util.List<java.lang.Double> data
      • centroids

        private double[] centroids
      • counts

        private int[] counts
      • datas

        private java.util.List<java.lang.Double>[] datas
      • aggregatedCounts

        private int[] aggregatedCounts
    • Constructor Detail

      • AVLGroupTree

        AVLGroupTree()
      • AVLGroupTree

        AVLGroupTree​(boolean record)
    • Method Detail

      • size

        public int size()
        Return the number of centroids in the tree.
        Specified by:
        size in interface java.util.Collection<Centroid>
        Specified by:
        size in class java.util.AbstractCollection<Centroid>
      • prev

        public int prev​(int node)
        Return the previous node.
      • next

        public int next​(int node)
        Return the next node.
      • mean

        public double mean​(int node)
        Return the mean for the provided node.
      • count

        public int count​(int node)
        Return the count for the provided node.
      • data

        public java.util.List<java.lang.Double> data​(int node)
        Return the data for the provided node.
      • add

        public void add​(double centroid,
                        int count,
                        java.util.List<java.lang.Double> data)
        Add the provided centroid to the tree.
      • add

        public boolean add​(Centroid centroid)
        Specified by:
        add in interface java.util.Collection<Centroid>
        Overrides:
        add in class java.util.AbstractCollection<Centroid>
      • update

        public void update​(int node,
                           double centroid,
                           int count,
                           java.util.List<java.lang.Double> data)
        Update values associated with a node, readjusting the tree if necessary.
      • floor

        public int floor​(double centroid)
        Return the last node whose centroid is less than centroid.
      • floorSum

        public int floorSum​(long sum)
        Return the last node so that the sum of counts of nodes that are before it is less than or equal to sum.
      • first

        public int first()
        Return the least node in the tree.
      • headSum

        public long headSum​(int node)
        Compute the number of elements and sum of counts for every entry that is strictly before node.
      • iterator

        public java.util.Iterator<Centroid> iterator()
        Specified by:
        iterator in interface java.util.Collection<Centroid>
        Specified by:
        iterator in interface java.lang.Iterable<Centroid>
        Specified by:
        iterator in class java.util.AbstractCollection<Centroid>
      • iterator

        private java.util.Iterator<Centroid> iterator​(int startNode)
      • sum

        public int sum()
        Return the total count of points that have been added to the tree.
      • checkBalance

        void checkBalance()
      • checkAggregates

        void checkAggregates()
      • checkAggregates

        private void checkAggregates​(int node)