21.19 Enumerators

An enumerator is an immutable list that need not store its elements explicitly but knows, from a set of basic data, how to determine the i-th element and the position of a given object. A typical example of this is a vector space over a finite field with q elements, say, for which it is very easy to enumerate all elements using q-adic expansions of integers.

Using this enumartion can be even quicker than a binary search in a sorted list of vectors:

  • IsQuickPositionList( list ) F

    This filter indicates that a position test in list is quicker than about 5 or 6 element comparisons for ``smaller''. If this is the case it can be beneficial to use Position in list and a bit list than ordered lists to represent subsets of list.

    On the one hand, element access to an enumerator may take more time than element access to an internally represented list containing the same elements. On the other hand, an enumerator may save a vast amount of memory. Take for example a permutation group of size a few millions. Even for moderate degree it is unlikely that a list of all its elements will fit into memory whereas it is no problem to construct an enumerator from a stabilizer chain (see Stabilizer Chains).

    There are situations where one only wants to loop over the elements of a domain, without using the special facilities of an enumerator, namely the particular order of elements and the possibility to find the position of elements. For such cases, GAP provides iterators (see Iterators).

    For constructing enumerators, see Enumerator and EnumeratorSorted.

    [Top] [Previous] [Up] [Index]

    GAP 4 manual
    February 2000