Iterator Functions

Array, struct, set, vertex and edge data types are iterable. The foreach loop uses iterators internally.

Return a copy of a container and set its inner iterator to the beginning.

iterator(object) : object

Check if a container has a next item.

hasNext(object) : bool

Get the next item.

next(object) : object

Reset the inner iterator to the beginning.

resetIterator(object) : object

Examples

function main(argv)
{
	// Define and fill an iterable object
	iterable = struct();
	iterable.number = 42;
	iterable.pi = 3.14;
	iterable.iterabler = "bagr";

	// Iterate using iterators
	it = iterable.iterator();
	while(it.hasNext())
		println(it.next());

	println("");

	// Iterate using foreach loop
	foreach(var; iterable)
		println(var);
}
42
3.14
bagr

42
3.14
bagr