mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
parent
91f94b8155
commit
88225a50ff
1 changed files with 48 additions and 11 deletions
|
@ -15,26 +15,63 @@
|
|||
*/
|
||||
package ghidra.program.model.block;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* An iterator interface over CodeBlocks.
|
||||
*
|
||||
* <P>Note: this iterator is also {@link Iterable}. The {@link #hasNext()} and {@link #next()}
|
||||
* methods of this interface throw a {@link CancelledException} if the monitor is cancelled. The
|
||||
* iterator returned from {@link #iterator()} does <b>not</b> throw a cancelled exception. If
|
||||
* you need to know the cancelled state of this iterator, then you must check the cancelled state
|
||||
* of the monitor passed into this iterator via the {@link CodeBlockModel}. See
|
||||
* {@link TaskMonitor#isCancelled()}.
|
||||
*
|
||||
* @see ghidra.program.model.block.CodeBlock
|
||||
* @see CollectionUtils#asIterable
|
||||
*/
|
||||
public interface CodeBlockIterator {
|
||||
*/
|
||||
public interface CodeBlockIterator extends Iterable<CodeBlock> {
|
||||
|
||||
/**
|
||||
* Return true if next() will return a CodeBlock.
|
||||
* @throws CancelledException thrown if the operation is cancelled.
|
||||
*/
|
||||
/**
|
||||
* Return true if next() will return a CodeBlock.
|
||||
* @return true if next() will return a CodeBlock.
|
||||
* @throws CancelledException thrown if the operation is cancelled.
|
||||
*/
|
||||
public boolean hasNext() throws CancelledException;
|
||||
|
||||
/**
|
||||
* Return the next CodeBlock.
|
||||
* @throws CancelledException thrown if the operation is cancelled.
|
||||
*/
|
||||
public CodeBlock next() throws CancelledException;
|
||||
/**
|
||||
* Return the next CodeBlock.
|
||||
* @return the next CodeBlock.
|
||||
* @throws CancelledException thrown if the operation is cancelled.
|
||||
*/
|
||||
public CodeBlock next() throws CancelledException;
|
||||
|
||||
@Override
|
||||
default Iterator<CodeBlock> iterator() {
|
||||
return new Iterator<>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
try {
|
||||
return CodeBlockIterator.this.hasNext();
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeBlock next() {
|
||||
try {
|
||||
return CodeBlockIterator.this.next();
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue