deferred class TRAVERSABLE [E_]

Features exported to ANY

A TRAVERSABLE[E_] is a finite readable sequence of objects of type E_. For instance, COLLECTIONs and STRINGs are TRAVERSABLE.

A good performance should always be obtained by sequentially acessing a TRAVERSABLE with increasing indexes (from lower to upper), as demonstrated in the following code snippet :

 from
    i := a_traversable.lower
 until
    i > a_traversable.upper
 loop
    do_something_with(a_traversable.item(i))
    i := i + 1
 end
Other accessing methods (including random access and sequential access from upper to lower) may or may not lead to acceptable performance, depending on the particular implementation of TRAVERSABLE.

Direct parents

non-conformant parents

ANY

Known children

conformant children

BIJECTIVE_DICTIONARY, BIT_STRING, COLLECTION, DICTIONARY, STRING, UNICODE_STRING

Summary

exported features

Indexing:

Counting:

Accessing:

Other features:

Details

deferred lower: INTEGER

Minimum index.

See also upper, valid_index, item.

deferred upper: INTEGER

Maximum index.

See also lower, valid_index, item.

valid_index (i: INTEGER): BOOLEAN

True when i is valid (i.e., inside actual bounds).

See also lower, upper, item.

ensure

  • definition: Result = (lower <= i and i <= upper)

deferred count: INTEGER

Number of available indices.

See also is_empty, lower, upper.

ensure

  • definition: Result = upper - lower + 1

deferred is_empty: BOOLEAN

Is collection empty ?

See also count.

ensure

  • definition: Result = (count = 0)

deferred item (i: INTEGER): E_

Item at the corresponding index i.

See also lower, upper, valid_index.

require

  • valid_index(i)

deferred first: E_

The very first item.

See also last, item.

require

  • not is_empty

ensure

  • definition: Result = item(lower)

deferred last: E_

The last item.

See also first, item.

require

  • not is_empty

ensure

  • definition: Result = item(upper)

deferred get_new_iterator: ITERATOR[E_]