# VectorApplier

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/vector/VectorCompose.kt+class:androidx.compose.ui.graphics.vector.VectorApplier) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  class VectorApplier : AbstractApplier<VNode>
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.compose.runtime.AbstractApplier](https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier)\<[VNode](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode)\> ||
|   | ↳ | [androidx.compose.ui.graphics.vector.VectorApplier](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier) |

*** ** * ** ***

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#VectorApplier(androidx.compose.ui.graphics.vector.VNode)(root: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode)` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#insertBottomUp(kotlin.Int,androidx.compose.ui.graphics.vector.VNode)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, instance: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode)` Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)` should be inserted as a child of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` at `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#insertTopDown(kotlin.Int,androidx.compose.ui.graphics.vector.VNode)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, instance: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode)` Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` should be inserted as a child to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` at `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#move(kotlin.Int,kotlin.Int,kotlin.Int)(from: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, to: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` children of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` should be moved from index `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` to index `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#remove(kotlin.Int,kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Indicates that the children of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` + `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` should be removed. | Cmn |

| ### Protected functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VectorApplier#onClear()()` Called to perform clearing of the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#root()` when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#clear()` is called. | Cmn |

### Inherited functions

From [androidx.compose.runtime.AbstractApplier](https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier) `final https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#clear()()`

Move to the root and remove all nodes from the root, preparing both this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier` and its root to be used as the target of a new composition in the future.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#down(kotlin.Any)(node: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode)`

Indicates that the applier is getting traversed "down" the tree.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#(kotlin.collections.MutableList).move(kotlin.Int,kotlin.Int,kotlin.Int)(from: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, to: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#(kotlin.collections.MutableList).remove(kotlin.Int,kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#up()()`

Indicates that the applier is getting traversed "up" the tree.
Cmn From [androidx.compose.runtime.Applier](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#apply(kotlin.Function2,kotlin.Any)(block: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode.(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

Apply a change to the current node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#onBeginChanges()()`

Called when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composer` is about to begin applying changes using this applier.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#onEndChanges()()`

Called when the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composer` is finished applying changes using this applier.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#reuse()()`

Notify `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` is is being reused in reusable content.
Cmn

### Inherited properties

From [androidx.compose.runtime.AbstractApplier](https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier) `open https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#current()`

The node that operations will be applied on at any given time.
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/VNode` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#root()` Cmn

## Public constructors

### VectorApplier

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
VectorApplier(root: VNode)
```

## Public functions

### insertBottomUp

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun insertBottomUp(index: Int, instance: VNode): Unit
```

Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)` should be inserted as a child of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` at `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)`. An applier should insert the node into the tree either in `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` or `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)`, not both. See the description of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` to which describes when to implement `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` and when to use `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)`.

### insertTopDown

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun insertTopDown(index: Int, instance: VNode): Unit
```

Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` should be inserted as a child to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` at `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)`. An applier should insert the node into the tree either in `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` or `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)`, not both.

The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` method is called before the children of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` have been created and inserted into it. `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)` is called after all children have been created and inserted.

Some trees are faster to build top-down, in which case the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)` method should be used to insert the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertTopDown(kotlin.Int,kotlin.Any)`. Other trees are faster to build bottom-up in which case `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#insertBottomUp(kotlin.Int,kotlin.Any)` should be used.

To give example of building a tree top-down vs. bottom-up consider the following tree,

```kotlin
      R
      |
      B
     / \
    A   C
```

where the node `B` is being inserted into the tree at `R`. Top-down building of the tree first inserts `B` into `R`, then inserts `A` into `B` followed by inserting `C` into B\`. For example,

```kotlin
    1           2           3
    R           R           R
    |           |           |
    B           B           B
               /           / \
              A           A   C
```

A bottom-up building of the tree starts with inserting `A` and `C` into `B` then inserts `B` tree into `R`.

```kotlin
    1           2           3
    B           B           R
    |          / \          |
    A         A   C         B
                           / \
                          A   C
```

To see how building top-down vs. bottom-up can differ significantly in performance consider a tree where whenever a child is added to the tree all parent nodes, up to the root, are notified of the new child entering the tree. If the tree is built top-down,

1. `R` is notified of `B` entering.

2. `B` is notified of `A` entering, `R` is notified of `A` entering.

3. `B` is notified of `C` entering, `R` is notified of `C` entering.

for a total of 5 notifications. The number of notifications grows exponentially with the number of inserts.

For bottom-up, the notifications are,

1. `B` is notified `A` entering.

2. `B` is notified `C` entering.

3. `R` is notified `B` entering.

The notifications are linear to the number of nodes inserted.

If, on the other hand, all children are notified when the parent enters a tree, then the notifications are, for top-down,

1. `B` is notified it is entering `R`.

2. `A` is notified it is entering `B`.

3. `C` is notified it is entering `B`.

which is linear to the number of nodes inserted.

For bottom-up, the notifications look like,

1. `A` is notified it is entering `B`.

2. `C` is notified it is entering `B`.

3. `B` is notified it is entering `R`, `A` is notified it is entering `R`, `C` is notified it is entering `R`.

   which exponential to the number of nodes inserted.

### move

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun move(from: Int, to: Int, count: Int): Unit
```

Indicates that `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` children of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` should be moved from index `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` to index `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)`.

The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` index is relative to the position before the change, so, for example, to move an element at position 1 to after the element at position 2, `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` should be `1` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#move(kotlin.Int,kotlin.Int,kotlin.Int)` should be `3`. If the elements were A B C D E, calling `move(1, 3, 1)` would result in the elements being reordered to A C B D E.

### remove

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun remove(index: Int, count: Int): Unit
```

Indicates that the children of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#current()` from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` + `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier#remove(kotlin.Int,kotlin.Int)` should be removed.

## Protected functions

### onClear

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
protected open fun onClear(): Unit
```

Called to perform clearing of the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#root()` when `https://developer.android.com/reference/kotlin/androidx/compose/runtime/AbstractApplier#clear()` is called.