Up: Traversable Collections   [Index]


5.4.1 Traversal Mode Definition Example

The any type traversal mode description for the list library ‘list’ type is:

static const struct x1f4_progress_type progress_1 = {
    {	"lt_next(;1, ;*, ;0)",	1,	1,	1,	19		},
    {	"lt_first(;1, ;*, ;0)",	1,	1,	1,	20		},
	X1f4_E4_INTEGER,	X1f4_E4_SLIP,		0,	2
};

See struct x1f4_progress_type.

See List Library.

See (aime)List Statements.

The ‘list’ traversal is over two variables, the first of which must be of the intrinsic integer type (X1f4_E4_INTEGER), while the second may be of any type (X1f4_E4_SLIP says so). The second variable is to match (type wise) the traversed ‘list’ content. The type for the traversed collection is yet to be filled in (it is set as 0).

See Symbolic Types.

It prescribes ‘lt_first’ and ‘lt_next’ calls for the if and while statements, respectively. The former sets the traversal variables to 0 (first position) and the data in the first position, if the traversed ‘list’ is not empty. The latter increments the position bound first variable and sets the second to the position associated data.

For only this traversal node, the struct x1f4_lxnote_type fold method returns 1 and leaves its second parameter unchanged (as no memory is required to store the traversal mode definition in excess of the one struct x1f4_progress_type). The struct x1f4_lxnote_type pass method copies the traversal definition, fills in the type id for the ‘list’ type and increments the struct x1f4_progress_type copying address.

See struct x1f4_lxnote_type.