Class TreeImpl

java.lang.Object
xyz.cofe.collection.TreeImpl

public class TreeImpl
extends java.lang.Object
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.util.WeakHashMap<Tree<?>,​java.util.List<Tree<?>>> nodes  
  • Constructor Summary

    Constructors 
    Constructor Description
    TreeImpl()  
  • Method Summary

    Modifier and Type Method Description
    static <A extends Tree<A>>
    java.util.List<Triple<java.lang.Integer,​A,​A>>
    append​(A tree, A... nodes)
    Добавление дочернего узла в конец списка
    static <A extends Tree<A>>
    void
    append​(A tree, A[] nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
    Добавление дочернего узла в конец списка
    static <A extends Tree<A>>
    void
    append​(A tree, java.lang.Iterable<A> nodes)
    Добавление дочернего узла в конец списка
    static <A extends Tree<A>>
    void
    append​(A tree, java.lang.Iterable<A> nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
    Добавление дочернего узла в конец списка
    static <A extends Tree<A>>
    void
    clear​(Tree<A> tree)
    Удаление всех дочерних узлов
    static <A extends Tree<A>>
    void
    clear​(Tree<A> tree, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
    Удаление всех дочерних узлов
    static <A extends Tree<A>>
    void
    deleteByIndex​(Tree<A> tree, int... index)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByIndex​(Tree<A> tree, int[] index, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByIndex​(Tree<A> tree, java.lang.Iterable<java.lang.Integer> index)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByIndex​(Tree<A> tree, java.lang.Iterable<java.lang.Integer> index, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByValue​(Tree<A> tree, A... value)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByValue​(Tree<A> tree, A[] value, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByValue​(Tree<A> tree, java.lang.Iterable<A> value)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    void
    deleteByValue​(Tree<A> tree, java.lang.Iterable<A> value, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
    Удаление дочернего узла(ов)
    static <A extends Tree<A>>
    java.util.List<Triple<java.lang.Integer,​A,​A>>
    insert​(Tree<A> tree, int index, A... nodes)
    Добавление дочернего узла в указанную позицию списка дочерних улов
    static <A extends Tree<A>>
    void
    insert​(Tree<A> tree, int index, A[] nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
    Добавление дочернего узла в указанную позицию списка дочерних улов
    static <A extends Tree<A>>
    java.util.List<Triple<java.lang.Integer,​A,​A>>
    insert​(Tree<A> tree, int index, java.lang.Iterable<A> nodes)
    Добавление дочернего узла в указанную позицию списка дочерних улов
    static <A extends Tree<A>>
    void
    insert​(Tree<A> tree, int index, java.lang.Iterable<A> nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
    Добавление дочернего узла в указанную позицию списка дочерних улов
    static <A extends Tree<A>>
    A
    node​(Tree<A> tree, int index)
    Получение дочернего элемента по индексу
    static int nodesCount​(Tree tree)
    Получение кол-ва дочерних узлов
    static <A extends Tree<A>>
    java.util.List<A>
    nodesOf​(Tree<A> tree)  
    static <A extends Tree<A>>
    java.util.List<Triple<java.lang.Integer,​A,​A>>
    set​(Tree<A> tree, int index, A... values)
    Замена дочернего узла
    static <A extends Tree<A>>
    void
    set​(Tree<A> tree, int index, A[] values, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> changes)
    Замена дочернего узла
    static <A extends Tree<A>>
    java.util.List<Triple<java.lang.Integer,​A,​A>>
    set​(Tree<A> tree, int index, java.lang.Iterable<A> values)
    Замена дочернего узла
    static <A extends Tree<A>>
    void
    set​(Tree<A> tree, int index, java.lang.Iterable<A> values, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> changes)
    Замена дочернего узла

    Methods inherited from class java.lang.Object

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

    • nodes

      public static final java.util.WeakHashMap<Tree<?>,​java.util.List<Tree<?>>> nodes
  • Constructor Details

  • Method Details

    • nodesOf

      public static <A extends Tree<A>> java.util.List<A> nodesOf​(Tree<A> tree)
    • nodesCount

      public static int nodesCount​(Tree tree)
      Получение кол-ва дочерних узлов
      Parameters:
      tree - родительский узел
      Returns:
      кол-во узлов
    • node

      public static <A extends Tree<A>> A node​(Tree<A> tree, int index)
      Получение дочернего элемента по индексу
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - индекс
      Returns:
      Дочерний узел
    • set

      public static <A extends Tree<A>> java.util.List<Triple<java.lang.Integer,​A,​A>> set​(Tree<A> tree, int index, A... values)
      Замена дочернего узла
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - идекс узлов которые необходимо заменить
      values - дочерние узлы
      Returns:
      Список изменений (index, oldChildNode, newChildNode)
    • set

      public static <A extends Tree<A>> void set​(Tree<A> tree, int index, A[] values, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> changes)
      Замена дочернего узла
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - идекс узлов которые необходимо заменить
      values - дочерние узлы
      changes - Список изменений (index, oldChildNode, newChildNode)
    • set

      public static <A extends Tree<A>> java.util.List<Triple<java.lang.Integer,​A,​A>> set​(Tree<A> tree, int index, java.lang.Iterable<A> values)
      Замена дочернего узла
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - идекс узлов которые необходимо заменить
      values - дочерние узлы
      Returns:
      Список изменений (index, oldChildNode, newChildNode)
    • set

      public static <A extends Tree<A>> void set​(Tree<A> tree, int index, java.lang.Iterable<A> values, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> changes)
      Замена дочернего узла
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - идекс узлов которые необходимо заменить
      values - дочерние узлы
      changes - Список изменений (index, oldChildNode, newChildNode)
    • insert

      public static <A extends Tree<A>> java.util.List<Triple<java.lang.Integer,​A,​A>> insert​(Tree<A> tree, int index, A... nodes)
      Добавление дочернего узла в указанную позицию списка дочерних улов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - индекс (0..) позиции вставки
      nodes - дочерние узлы
      Returns:
      список добавленных узлов - fn( index, null, insertedChildNode )
    • insert

      public static <A extends Tree<A>> void insert​(Tree<A> tree, int index, A[] nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
      Добавление дочернего узла в указанную позицию списка дочерних улов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - индекс (0..) позиции вставки
      nodes - дочерние узлы
      added - список добавленных узлов - fn( index, null, insertedChildNode )
    • insert

      public static <A extends Tree<A>> java.util.List<Triple<java.lang.Integer,​A,​A>> insert​(Tree<A> tree, int index, java.lang.Iterable<A> nodes)
      Добавление дочернего узла в указанную позицию списка дочерних улов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
      Returns:
      список добавленных узлов - fn( index, null, insertedChildNode )
    • insert

      public static <A extends Tree<A>> void insert​(Tree<A> tree, int index, java.lang.Iterable<A> nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
      Добавление дочернего узла в указанную позицию списка дочерних улов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
      index - индекс (0..) позиции вставки
      added - список добавленных узлов - fn( index, null, insertedChildNode )
    • append

      public static <A extends Tree<A>> java.util.List<Triple<java.lang.Integer,​A,​A>> append​(A tree, A... nodes)
      Добавление дочернего узла в конец списка
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
      Returns:
      список добавленных узлов - fn( index, null, insertedChildNode )
    • append

      public static <A extends Tree<A>> void append​(A tree, A[] nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
      Добавление дочернего узла в конец списка
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
      added - список добавленных узлов - fn( index, null, insertedChildNode )
    • append

      public static <A extends Tree<A>> void append​(A tree, java.lang.Iterable<A> nodes)
      Добавление дочернего узла в конец списка
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
    • append

      public static <A extends Tree<A>> void append​(A tree, java.lang.Iterable<A> nodes, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> added)
      Добавление дочернего узла в конец списка
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      nodes - дочерние узлы
      added - список добавленных узлов - fn( index, null, insertedChildNode )
    • deleteByIndex

      public static <A extends Tree<A>> void deleteByIndex​(Tree<A> tree, int... index)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - иднекс дочернего элемента(ов)
    • deleteByIndex

      public static <A extends Tree<A>> void deleteByIndex​(Tree<A> tree, int[] index, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - иднекс дочернего элемента(ов)
      deleted - возможно null, уведомление о удаленных элементах: fn( index, deletedChildNode, null )
    • deleteByIndex

      public static <A extends Tree<A>> void deleteByIndex​(Tree<A> tree, java.lang.Iterable<java.lang.Integer> index)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - иднекс дочернего элемента(ов)
    • deleteByIndex

      public static <A extends Tree<A>> void deleteByIndex​(Tree<A> tree, java.lang.Iterable<java.lang.Integer> index, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      index - иднекс дочернего элемента(ов)
      deleted - возможно null, уведомление о удаленных элементах: fn( index, deletedChildNode, null )
    • deleteByValue

      public static <A extends Tree<A>> void deleteByValue​(Tree<A> tree, A... value)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      value - дочерние удаляемые элементы
    • deleteByValue

      public static <A extends Tree<A>> void deleteByValue​(Tree<A> tree, java.lang.Iterable<A> value)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      value - дочерние удаляемые элементы
    • deleteByValue

      public static <A extends Tree<A>> void deleteByValue​(Tree<A> tree, A[] value, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      value - дочерние удаляемые элементы
      deleted - возможно null, уведомление о удаленных элементах: fn( index, deletedChildNode, null )
    • deleteByValue

      public static <A extends Tree<A>> void deleteByValue​(Tree<A> tree, java.lang.Iterable<A> value, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
      Удаление дочернего узла(ов)
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      value - дочерние удаляемые элементы
      deleted - возможно null, уведомление о удаленных элементах: fn( index, deletedChildNode, null )
    • clear

      public static <A extends Tree<A>> void clear​(Tree<A> tree)
      Удаление всех дочерних узлов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
    • clear

      public static <A extends Tree<A>> void clear​(Tree<A> tree, java.util.function.Consumer<Triple<java.lang.Integer,​A,​A>> deleted)
      Удаление всех дочерних узлов
      Type Parameters:
      A - Тип узла
      Parameters:
      tree - родительский узел
      deleted - возможно null, уведомление о удаленных элементах: fn( index, deletedChildNode, null )