tree_breadth_first_iterator

class tree_breadth_first_iterator #(type T =  int) extends iterator#( T )

Provides a breadth-first iterator to a tree.

Parameter

Toptional The type of data collected in a tree.  The default is int.
Summary
tree_breadth_first_iteratorProvides a breadth-first iterator to a tree.
Types
tree_node_typeThe shorthand of the tree_node type specialized with type T.
tree_typeThe shorthand of the tree type specialized with type T.
newCreates a tree iterator.
has_nextvirtual Returns 1 if the iterator has more elements.
nextvirtual Returns the next element.
next_nodevirtual Returns the next tree_node.
removevirtual Removes the last element returned by the iterator.

Types

tree_node_type

typedef tree_node#(T) tree_node_type

The shorthand of the tree_node type specialized with type T.

tree_type

typedef tree#(T) tree_type

The shorthand of the tree type specialized with type T.

new

function new(tree_type t)

Creates a tree iterator.

Argument

tA tree to be iterated.

has_next

virtual function bit has_next()

virtual Returns 1 if the iterator has more elements.

Returns

If the iterator has more elements, returns 1.  Otherwise, returns 0.

next

virtual function T next()

virtual Returns the next element.

Returns

The next element in the iterator.

next_node

virtual function tree_node_type next_node()

virtual Returns the next tree_node.

Returns

The next tree node in the tree.

remove

virtual function void remove()

virtual Removes the last element returned by the iterator.  This function can be called once per call to next or next_node.

Returns

None.

class tree_breadth_first_iterator #(type T =  int) extends iterator#( T )
Provides a breadth-first iterator to a tree.
class tree #(type T =  int) extends collection#( T )
Implements a tree structure.
typedef tree_node#(T) tree_node_type
The shorthand of the tree_node type specialized with type T.
class tree_node #(type T =  int)
Implements a node of a tree.
typedef tree#(T) tree_type
The shorthand of the tree type specialized with type T.
function new(tree_type t)
Creates a tree iterator.
virtual function bit has_next()
virtual Returns 1 if the iterator has more elements.
virtual function T next()
virtual Returns the next element.
virtual function tree_node_type next_node()
virtual Returns the next tree_node.
virtual function void remove()
virtual Removes the last element returned by the iterator.