# PathIterator

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/graphics/PathIterator#nestedclasses)\|[Constants](https://developer.android.com/reference/android/graphics/PathIterator#constants)\|[Methods](https://developer.android.com/reference/android/graphics/PathIterator#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/graphics/PathIterator#inhmethods)  

# PathIterator

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/graphics/PathIterator "View this page in Kotlin")\|Java

`
public


class
PathIterator
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Iterator](https://developer.android.com/reference/java/util/Iterator)`<`[PathIterator.Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment)`>


`

|---|-------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.PathIterator |

<br />

*** ** * ** ***

`PathIterator`can be used to query a given[Path](https://developer.android.com/reference/android/graphics/Path)object, to discover its operations and point values.

## Summary

|                                                                                                                                     ### Nested classes                                                                                                                                      ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [PathIterator.Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment) This class holds the data for a given segment in a path, as returned by[PathIterator.next()](https://developer.android.com/reference/android/graphics/PathIterator#next()). |

|                                                ### Constants                                                 ||
|-------|-------------------------------------------------------------------------------------------------------|
| `int` | [VERB_CLOSE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CLOSE) <br /> |
| `int` | [VERB_CONIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CONIC) <br /> |
| `int` | [VERB_CUBIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CUBIC) <br /> |
| `int` | [VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE) <br />   |
| `int` | [VERB_LINE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_LINE) <br />   |
| `int` | [VERB_MOVE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_MOVE) <br />   |
| `int` | [VERB_QUAD](https://developer.android.com/reference/android/graphics/PathIterator#VERB_QUAD) <br />   |

|                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                  ||
|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                                                               | ` `[hasNext](https://developer.android.com/reference/android/graphics/PathIterator#hasNext())`() ` Returns true if the there are more elements in this iterator to be returned.                                                                                                                                                            |
| ` int`                                                                                                   | ` `[next](https://developer.android.com/reference/android/graphics/PathIterator#next(float[],%20int))`(float[] points, int offset) ` Returns the next verb in this iterator's[Path](https://developer.android.com/reference/android/graphics/Path), and fills entries in the`points`array with the point data (if any) for that operation. |
| ` `[PathIterator.Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment) | ` `[next](https://developer.android.com/reference/android/graphics/PathIterator#next())`() ` Returns the next[Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment)element in this iterator.                                                                                                             |
| ` int`                                                                                                   | ` `[peek](https://developer.android.com/reference/android/graphics/PathIterator#peek())`() ` Returns the next verb in the iteration, or[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE)if there are no more elements.                                                                          |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.util.Iterator](https://developer.android.com/reference/java/util/Iterator)` ` |-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`                                                                                                   | ` `[forEachRemaining](https://developer.android.com/reference/java/util/Iterator#forEachRemaining(java.util.function.Consumer<?%20super%20E>))`(`[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<? super E> action) ` Performs the given action for each remaining element until all elements have been processed or the action throws an exception. | | ` abstract boolean`                                                                                               | ` `[hasNext](https://developer.android.com/reference/java/util/Iterator#hasNext())`() ` Returns`true`if the iteration has more elements.                                                                                                                                                                                                                                              | | ` abstract `[PathIterator.Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment) | ` `[next](https://developer.android.com/reference/java/util/Iterator#next())`() ` Returns the next element in the iteration.                                                                                                                                                                                                                                                          | | ` default void`                                                                                                   | ` `[remove](https://developer.android.com/reference/java/util/Iterator#remove())`() ` Removes from the underlying collection the last element returned by this iterator (optional operation).                                                                                                                                                                                         | ||

## Constants

### VERB_CLOSE

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_CLOSE
```

<br />

<br />

Constant Value: 5 (0x00000005)  

### VERB_CONIC

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_CONIC
```

<br />

<br />

Constant Value: 3 (0x00000003)  

### VERB_CUBIC

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_CUBIC
```

<br />

<br />

Constant Value: 4 (0x00000004)  

### VERB_DONE

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_DONE
```

<br />

<br />

Constant Value: 6 (0x00000006)  

### VERB_LINE

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_LINE
```

<br />

<br />

Constant Value: 1 (0x00000001)  

### VERB_MOVE

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_MOVE
```

<br />

<br />

Constant Value: 0 (0x00000000)  

### VERB_QUAD

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VERB_QUAD
```

<br />

<br />

Constant Value: 2 (0x00000002)

## Public methods

### hasNext

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean hasNext ()
```

Returns true if the there are more elements in this iterator to be returned. A return value of`false`means there are no more elements, and an ensuing call to[next()](https://developer.android.com/reference/android/graphics/PathIterator#next())or[next(float[], int)](https://developer.android.com/reference/android/graphics/PathIterator#next(float[],%20int)))} will return[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE).

<br />

|                                          Returns                                          ||
|-----------|--------------------------------------------------------------------------------|
| `boolean` | true if there are more elements to be iterated through, false otherwise <br /> |

|                                                                                           Throws                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [ConcurrentModificationException](https://developer.android.com/reference/java/util/ConcurrentModificationException) | if the underlying path was modified since this iterator was created. |

### next

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int next (float[] points, 
                int offset)
```

Returns the next verb in this iterator's[Path](https://developer.android.com/reference/android/graphics/Path), and fills entries in the`points`array with the point data (if any) for that operation. Each two floats represent the data for a single point of that operation. The number of pairs of floats supplied in the resulting array depends on the verb:

- [VERB_MOVE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_MOVE): 1 pair (indices 0 to 1)
- [VERB_LINE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_LINE): 2 pairs (indices 0 to 3)
- [VERB_QUAD](https://developer.android.com/reference/android/graphics/PathIterator#VERB_QUAD): 3 pairs (indices 0 to 5)
- [VERB_CONIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CONIC): 3.5 pairs (indices 0 to 6), the seventh entry has the conic weight
- [VERB_CUBIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CUBIC): 4 pairs (indices 0 to 7)
- [VERB_CLOSE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CLOSE): 0 pairs
- [VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE): 0 pairs

<br />

<br />

|                                                                             Parameters                                                                              ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `points` | `float`: The point data for this operation, must have at least 8 items available to hold up to 4 pairs of point values This value cannot be`null`. <br /> |
| `offset` | `int`: An offset into the`points`array where entries should be placed. <br />                                                                             |

|                                                                                                                                                                                                                                                                                                                                                                                          Returns                                                                                                                                                                                                                                                                                                                                                                                          ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the operation for the next element in the iteration This value cannot be`null`. Value is[VERB_MOVE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_MOVE),[VERB_LINE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_LINE),[VERB_QUAD](https://developer.android.com/reference/android/graphics/PathIterator#VERB_QUAD),[VERB_CONIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CONIC),[VERB_CUBIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CUBIC),[VERB_CLOSE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CLOSE), or[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE) <br /> |

|                                                                                           Throws                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [ArrayIndexOutOfBoundsException](https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException)   | if the points array is too small                                     |
| [ConcurrentModificationException](https://developer.android.com/reference/java/util/ConcurrentModificationException) | if the underlying path was modified since this iterator was created. |

### next

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PathIterator.Segment next ()
```

Returns the next[Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment)element in this iterator. There are two versions of`next()`. This version is slightly more expensive at runtime, since it allocates a new[Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment)object with every call. The other version,[next(float[], int)](https://developer.android.com/reference/android/graphics/PathIterator#next(float[],%20int))requires no such allocation, but requires a little more manual effort to use.

<br />

|                                                                                   Returns                                                                                   ||
|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [PathIterator.Segment](https://developer.android.com/reference/android/graphics/PathIterator.Segment) | the next segment in this iterator This value cannot be`null`. <br /> |

|                                                                                           Throws                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [ConcurrentModificationException](https://developer.android.com/reference/java/util/ConcurrentModificationException) | if the underlying path was modified since this iterator was created. |

### peek

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int peek ()
```

Returns the next verb in the iteration, or[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE)if there are no more elements.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                              Returns                                                                                                                                                                                                                                                                                                                                                                                                                                              ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the next verb in the iteration, or[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE)if there are no more elements This value cannot be`null`. Value is[VERB_MOVE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_MOVE),[VERB_LINE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_LINE),[VERB_QUAD](https://developer.android.com/reference/android/graphics/PathIterator#VERB_QUAD),[VERB_CONIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CONIC),[VERB_CUBIC](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CUBIC),[VERB_CLOSE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_CLOSE), or[VERB_DONE](https://developer.android.com/reference/android/graphics/PathIterator#VERB_DONE) <br /> |

|                                                                                           Throws                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [ConcurrentModificationException](https://developer.android.com/reference/java/util/ConcurrentModificationException) | if the underlying path was modified since this iterator was created. |