Package ghidra.app.decompiler

# Class TokenIterator

java.lang.Object
ghidra.app.decompiler.TokenIterator

All Implemented Interfaces:
  `Iterator<ClangToken>`

public class TokenIterator extends Object implements Iterator<ClangToken>
An iterator over ClangToken objects. The iterator walks a tree of ClangNode objects based on the Parent() and Child() methods, returning successive ClangNode leaf objects that are also ClangToken objects. The iterator can run either forward or backward over the tokens. The constructor TokenIterator(ClangToken,int) initializes the iterator to start at the given token, which can be in the middle of the sequence.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TokenIterator(ClangTokenGroup group, boolean forward)`
  Create iterator across all tokens under the given ClangTokenGroup.
  `TokenIterator(ClangToken token, boolean forward)`
  Initialize an iterator to a point to a specific ClangToken, which may be anywhere in the sequence.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `hasNext()`
  `ClangToken`
  `next()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.Iterator

  `forEachRemaining, remove`

- ## Constructor Details

  - ### TokenIterator

    public TokenIterator(ClangToken token, boolean forward)
    Initialize an iterator to a point to a specific ClangToken, which may be anywhere in the sequence.
    Parameters:
      `token` - is the specific ClangToken
      `forward` - is true for a forward iterator, false for a backward iterator

  - ### TokenIterator

    public TokenIterator(ClangTokenGroup group, boolean forward)
    Create iterator across all tokens under the given ClangTokenGroup. The iterator will walk the entire tree of token groups under the given group. The iterator will run over tokens in display order (forward=true) or in reverse of display order (forward=false)
    Parameters:
      `group` - is the given ClangTokenGroup
      `forward` - is true for a forward iterator, false for a backward iterator

- ## Method Details

  - ### hasNext

    public boolean hasNext()
    Specified by:
      `hasNext` in interface `Iterator<ClangToken>`

  - ### next

    public ClangToken next()
    Specified by:
      `next` in interface `Iterator<ClangToken>`